Toggle tile cache final API (#2723)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
This commit is contained in:
Alex Cristici
2024-08-21 00:28:00 +03:00
committed by GitHub
parent d544da140b
commit a4258ccbb8
21 changed files with 170 additions and 63 deletions

View File

@@ -324,6 +324,26 @@ public final class MapLibreMap {
return nativeMapView.getPrefetchZoomDelta();
}
/**
* Indicating whether the map may cache tiles for different zoom levels or not.
*
* @param enabled true causes the map view to consume more memory and have a smoother user
* experience when zoom in/out. The default value of this property is `true`.
*/
public void setTileCacheEnabled(boolean enabled) {
nativeMapView.setTileCacheEnabled(enabled);
}
/**
* Check whether tile cache is enabled or not.
*
* @return true if enabled
* @see MapLibreMap#setTileCacheEnabled(boolean)
*/
public boolean getTileCacheEnabled() {
return nativeMapView.getTileCacheEnabled();
}
//
// MinZoom
//
@@ -2504,18 +2524,4 @@ public final class MapLibreMap {
listener.onDeveloperAnimationStarted();
}
}
//
// Tile cache
//
/**
* Indicating whether the map may cache tiles for different zoom levels or not.
*
* @param enabled true causes the map view to consume more memory and have a smoother user
* experience when zoom in/out. The default value of this property is `true`.
*/
public void experimental_setTileCacheEnabled(boolean enabled) {
nativeMapView.setTileCacheEnabled(enabled);
}
}

View File

@@ -33,8 +33,6 @@ interface NativeMap {
void resizeView(int width, int height);
void setTileCacheEnabled(boolean enabled);
void onLowMemory();
void destroy();
@@ -235,6 +233,10 @@ interface NativeMap {
@IntRange(from = 0)
int getPrefetchZoomDelta();
void setTileCacheEnabled(boolean enabled);
boolean getTileCacheEnabled();
void setGestureInProgress(boolean inProgress);
float getPixelRatio();

View File

@@ -619,14 +619,6 @@ final class NativeMapView implements NativeMap {
nativeSetVisibleCoordinateBounds(coordinates, padding, direction, duration);
}
@Override
public void setTileCacheEnabled(boolean enabled) {
if (checkState("setTileCacheEnabled")) {
return;
}
nativeSetTileCacheEnabled(enabled);
}
@Override
public void onLowMemory() {
if (checkState("onLowMemory")) {
@@ -815,6 +807,21 @@ final class NativeMapView implements NativeMap {
return nativeGetPrefetchZoomDelta();
}
@Override
public void setTileCacheEnabled(boolean enabled) {
if (checkState("setTileCacheEnabled")) {
return;
}
nativeSetTileCacheEnabled(enabled);
}
@Override
public boolean getTileCacheEnabled() {
if (checkState("getTileCacheEnabled")) {
return false;
}
return nativeGetTileCacheEnabled();
}
// Runtime style Api
@Override
@@ -1340,9 +1347,6 @@ final class NativeMapView implements NativeMap {
private native void nativeSetVisibleCoordinateBounds(LatLng[] coordinates, RectF padding,
double direction, long duration);
@Keep
private native void nativeSetTileCacheEnabled(boolean enabled);
@Keep
private native void nativeOnLowMemory();
@@ -1510,6 +1514,12 @@ final class NativeMapView implements NativeMap {
@Keep
private native void nativeSetPrefetchZoomDelta(int delta);
@Keep
private native void nativeSetTileCacheEnabled(boolean enabled);
@Keep
private native boolean nativeGetTileCacheEnabled();
@Keep
private native int nativeGetPrefetchZoomDelta();