From 1170e4a91af00eb00988a7224ac30d103d4f1cd3 Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Sat, 25 Jan 2014 10:04:26 +0100 Subject: [PATCH] implement LwHttp.Buffer.mark()/reset() - fixes bitmap tile loading --- .../org/oscim/tiling/source/common/LwHttp.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/vtm/src/org/oscim/tiling/source/common/LwHttp.java b/vtm/src/org/oscim/tiling/source/common/LwHttp.java index aeea40c8..4db1fb58 100644 --- a/vtm/src/org/oscim/tiling/source/common/LwHttp.java +++ b/vtm/src/org/oscim/tiling/source/common/LwHttp.java @@ -110,6 +110,7 @@ public class LwHttp { static class Buffer extends BufferedInputStream { OutputStream mCache; int sumRead = 0; + int marked = -1; int mContentLength; public Buffer(InputStream is) { @@ -129,6 +130,20 @@ public class LwHttp { 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 public int read() throws IOException { if (sumRead >= mContentLength)