Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-02-20 14:54:55 +01:00
commit 0fe3457909

View file

@ -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) {