Add runtime API for setting tile prefetch delta for Source class (#184)
* Add runtime API for setting tile prefetch delta for Source class * Use Integer as param. * Update gl native submodule.
This commit is contained in:
@@ -2,6 +2,8 @@ package com.mapbox.mapboxsdk.style.sources;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mapbox.mapboxsdk.LibraryLoader;
|
||||
import com.mapbox.mapboxsdk.utils.ThreadUtils;
|
||||
|
||||
@@ -68,6 +70,28 @@ public abstract class Source {
|
||||
return nativeGetAttribution();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve current pre-fetching zoom delta.
|
||||
*
|
||||
* @return current zoom delta or null if not set.
|
||||
*/
|
||||
@Nullable
|
||||
public Integer getPrefetchZoomDelta() {
|
||||
return nativeGetPrefetchZoomDelta();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tile pre-fetching zoom delta for current source. Pre-fetching makes sure that a low-resolution
|
||||
* tile at the (current_zoom_level - delta) is rendered as soon as possible at the
|
||||
* expense of a little bandwidth.
|
||||
* If delta has not been set or set to null, it will use the value in MapboxMap instance.
|
||||
*
|
||||
* @param delta zoom delta
|
||||
*/
|
||||
public void setPrefetchZoomDelta(@Nullable Integer delta) {
|
||||
nativeSetPrefetchZoomDelta(delta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal use
|
||||
*
|
||||
@@ -85,6 +109,14 @@ public abstract class Source {
|
||||
@Keep
|
||||
protected native String nativeGetAttribution();
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
protected native Integer nativeGetPrefetchZoomDelta();
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
protected native void nativeSetPrefetchZoomDelta(Integer delta);
|
||||
|
||||
public void setDetached() {
|
||||
detached = true;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.mapbox.mapboxsdk.testapp.activity.style.GridSourceActivity.ID_GRID_LA
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.GridSourceActivity.ID_GRID_SOURCE
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestingAsyncUtils
|
||||
import org.junit.Assert
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class CustomGeometrySourceTest : BaseTest() {
|
||||
@@ -66,4 +67,20 @@ class CustomGeometrySourceTest : BaseTest() {
|
||||
}.count() == THREAD_POOL_LIMIT)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sourceZoomDeltaTest() {
|
||||
validateTestSetup()
|
||||
invoke(mapboxMap) { uiController, mapboxMap ->
|
||||
mapboxMap.prefetchZoomDelta = 3
|
||||
mapboxMap.style!!.getSource(ID_GRID_SOURCE)!!.let {
|
||||
assertNull(it.prefetchZoomDelta)
|
||||
it.prefetchZoomDelta = 5
|
||||
assertNotNull(it.prefetchZoomDelta)
|
||||
assertEquals(5, it.prefetchZoomDelta!!)
|
||||
it.prefetchZoomDelta = null
|
||||
assertNull(it.prefetchZoomDelta)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
vendor/mapbox-gl-native
vendored
2
vendor/mapbox-gl-native
vendored
Submodule vendor/mapbox-gl-native updated: a551f70c6d...43c1aac7e8
Reference in New Issue
Block a user