Merge branch 'master' into android-slow-init-466

This commit is contained in:
Petr Pokorny
2021-03-03 19:51:06 +01:00
committed by GitHub
6 changed files with 52 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [`Con
* Fixed an issue where symbols flickered when zooming out. [#16](https://github.com/maplibre/maplibre-gl-native/issues/16)
* Fixes crash caused by NullPointerException MapKeyListener [#464](https://github.com/mapbox/mapbox-gl-native-android/issues/464), cherry picked from [#466](https://github.com/mapbox/mapbox-gl-native-android/pull/466)
* Fixed an issue where GPS puck keeps previous value when enabled. [#462]https://github.com/mapbox/mapbox-gl-native-android/issues/462, cherry picked from [#470](https://github.com/mapbox/mapbox-gl-native-android/pull/470)
### Other

View File

@@ -482,6 +482,11 @@ final class LocationAnimatorCoordinator {
cancelAnimator(ANIMATOR_TILT);
}
void cancelAndRemoveGpsBearingAnimation() {
cancelAnimator(ANIMATOR_LAYER_GPS_BEARING);
animatorArray.remove(ANIMATOR_LAYER_GPS_BEARING);
}
/**
* Cancel the pulsing circle location animator.
*/

View File

@@ -48,6 +48,7 @@ import static com.mapbox.mapboxsdk.location.LocationComponentConstants.DEFAULT_I
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.DEFAULT_TRACKING_TILT_ANIM_DURATION;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.DEFAULT_TRACKING_ZOOM_ANIM_DURATION;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.TRANSITION_ANIMATION_DURATION_MS;
import static com.mapbox.mapboxsdk.location.modes.RenderMode.GPS;
/**
* The Location Component provides location awareness to your mobile application. Enabling this
@@ -674,6 +675,10 @@ public final class LocationComponent {
*/
public void setRenderMode(@RenderMode.Mode int renderMode) {
checkActivationState();
if (lastLocation != null && renderMode == GPS) {
locationAnimatorCoordinator.cancelAndRemoveGpsBearingAnimation();
locationLayerController.setGpsBearing(lastLocation.getBearing());
}
locationLayerController.setRenderMode(renderMode);
updateLayerOffsets(true);
updateCompassListenerState(true);

View File

@@ -106,6 +106,10 @@ final class LocationLayerController {
}
}
void setGpsBearing(float gpsBearing) {
locationLayerRenderer.setGpsBearing(gpsBearing);
}
void setRenderMode(@RenderMode.Mode int renderMode) {
if (this.renderMode == renderMode) {
return;

View File

@@ -705,6 +705,15 @@ class LocationAnimatorCoordinatorTest {
verify { animatorProvider.floatAnimator(any(), any(), 5) }
}
@Test
fun remove_gps_animator() {
val animator = mockk<MapboxFloatAnimator>(relaxed = true)
locationAnimatorCoordinator.animatorArray.put(ANIMATOR_LAYER_GPS_BEARING, animator)
locationAnimatorCoordinator.cancelAndRemoveGpsBearingAnimation()
assertTrue(locationAnimatorCoordinator.animatorArray.get(ANIMATOR_LAYER_GPS_BEARING) == null)
}
private fun getListenerHoldersSet(vararg animatorTypes: Int): Set<AnimatorListenerHolder> {
return HashSet<AnimatorListenerHolder>().also {
for (type in animatorTypes) {

View File

@@ -469,6 +469,34 @@ class LocationComponentTest {
verify(renderChangeListener).onRenderModeChanged(RenderMode.NORMAL)
}
@Test
fun change_to_gps_mode_symbolLayerBearingValue() {
val location = Location("test")
location.bearing = 50f
val projection: Projection = mock(Projection::class.java)
`when`(projection.getMetersPerPixelAtLatitude(location.latitude)).thenReturn(10.0)
`when`(mapboxMap.projection).thenReturn(projection)
`when`(style.isFullyLoaded).thenReturn(true)
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
locationComponent.activateLocationComponent(
LocationComponentActivationOptions.builder(context, style)
.locationComponentOptions(locationComponentOptions)
.useDefaultLocationEngine(false)
.build()
)
locationComponent.isLocationComponentEnabled = true
locationComponent.onStart()
locationComponent.renderMode = RenderMode.NORMAL
locationComponent.forceLocationUpdate(location)
verify(locationLayerController, times(0)).setGpsBearing(50f)
locationComponent.renderMode = RenderMode.GPS
verify(locationLayerController, times(1)).setGpsBearing(50f)
verify(locationAnimatorCoordinator).cancelAndRemoveGpsBearingAnimation()
}
@Test
fun tiltWhileTracking_notReady() {
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)