diff --git a/OsmAnd/src/net/osmand/core/android/TileSourceProxyProvider.java b/OsmAnd/src/net/osmand/core/android/TileSourceProxyProvider.java index 9d67ef5896..32dd427809 100644 --- a/OsmAnd/src/net/osmand/core/android/TileSourceProxyProvider.java +++ b/OsmAnd/src/net/osmand/core/android/TileSourceProxyProvider.java @@ -1,9 +1,12 @@ package net.osmand.core.android; +import android.graphics.Bitmap; + import java.io.IOException; import net.osmand.IndexConstants; import net.osmand.core.jni.AlphaChannelPresence; +import net.osmand.core.jni.MapStubStyle; import net.osmand.core.jni.SWIGTYPE_p_QByteArray; import net.osmand.core.jni.SwigUtilities; import net.osmand.core.jni.TileId; @@ -11,6 +14,7 @@ import net.osmand.core.jni.ZoomLevel; import net.osmand.core.jni.interface_ImageMapLayerProvider; import net.osmand.map.ITileSource; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.resources.ResourceManager; public class TileSourceProxyProvider extends interface_ImageMapLayerProvider { @@ -21,6 +25,11 @@ public class TileSourceProxyProvider extends interface_ImageMapLayerProvider { this.app = app; this.tileSource = tileSource; } + + @Override + public MapStubStyle getDesiredStubsStyle() { + return MapStubStyle.Unspecified; + } @Override public ZoomLevel getMinZoom() { @@ -36,6 +45,19 @@ public class TileSourceProxyProvider extends interface_ImageMapLayerProvider { public SWIGTYPE_p_QByteArray obtainImage(TileId tileId, ZoomLevel zoom) { byte[] image; try { + ResourceManager rm = app.getResourceManager(); + String tileFilename = rm.calculateTileId(tileSource, tileId.getX(), tileId.getY(), + zoom.swigValue()); + + if (!rm.tileExistOnFileSystem(tileFilename, tileSource, tileId.getX(), tileId.getY(), + zoom.swigValue())) { + Bitmap loadedBitmap = null; + while (loadedBitmap == null) { + loadedBitmap = rm.getTileImageForMapSync(tileFilename, tileSource, + tileId.getX(), tileId.getY(), zoom.swigValue(), true); + } + } + image = tileSource.getBytes(tileId.getX(), tileId.getY(), zoom.swigValue(), app.getAppPath(IndexConstants.TILES_INDEX_DIR).getAbsolutePath()); } catch(IOException e) {