implement LwHttp.Buffer.mark()/reset()
- fixes bitmap tile loading
This commit is contained in:
@@ -110,6 +110,7 @@ public class LwHttp {
|
|||||||
static class Buffer extends BufferedInputStream {
|
static class Buffer extends BufferedInputStream {
|
||||||
OutputStream mCache;
|
OutputStream mCache;
|
||||||
int sumRead = 0;
|
int sumRead = 0;
|
||||||
|
int marked = -1;
|
||||||
int mContentLength;
|
int mContentLength;
|
||||||
|
|
||||||
public Buffer(InputStream is) {
|
public Buffer(InputStream is) {
|
||||||
@@ -129,6 +130,20 @@ public class LwHttp {
|
|||||||
return sumRead == mContentLength;
|
return sumRead == mContentLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void mark(int readlimit) {
|
||||||
|
marked = sumRead;
|
||||||
|
super.mark(readlimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void reset() throws IOException {
|
||||||
|
if (marked >= 0)
|
||||||
|
sumRead = marked;
|
||||||
|
// TODO could check if the mark is already invalid
|
||||||
|
super.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read() throws IOException {
|
public int read() throws IOException {
|
||||||
if (sumRead >= mContentLength)
|
if (sumRead >= mContentLength)
|
||||||
|
|||||||
Reference in New Issue
Block a user