Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] invalidate foreground icon sources even when location layer…
Browse files Browse the repository at this point in the history
… is hidden
  • Loading branch information
LukasPaczos committed Aug 28, 2019
1 parent a5ed89e commit ace3a2f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions platform/android/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This release changes how offline tile requests are billed — they are now bille

### Bug fixes
- Fixed a rendering issue caused by all icons being treated as SDFs if an SDF and non-SDF icon were in the same layer. [#15456](https://github.com/mapbox/mapbox-gl-native/pull/15456)
- Fixed an issue where changing location's render mode when the`LocationComponent` is disable wouldn't invalidate the foreground icon when it's back enabled. [#15507](https://github.com/mapbox/mapbox-gl-native/pull/15507)

## 8.2.2 - August 23, 2019
[Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.2.1...android-v8.2.2) since [Mapbox Maps SDK for Android v8.2.1](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.2.1):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ void setRenderMode(@RenderMode.Mode int renderMode) {
}
this.renderMode = renderMode;

styleForeground(options);
determineIconsSource(options);
if (!isHidden) {
styleForeground(options);
show();
}
determineIconsSource(options);
internalRenderModeChangedListener.onRenderModeChanged(renderMode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,41 @@ public void renderModeChanged_doNotNotifyAboutDuplicates_GPS() {
verify(internalRenderModeChangedListener, times(1)).onRenderModeChanged(RenderMode.GPS);
}

@Test
public void layerHidden_renderModeChanged_layerShown_foregroundIconUpdated() {
OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
LayerSourceProvider sourceProvider = buildLayerProvider();
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
LocationComponentOptions options = mock(LocationComponentOptions.class);
int drawableResId = 123;
int tintColor = 456;
when(options.foregroundDrawable()).thenReturn(drawableResId);
when(options.foregroundTintColor()).thenReturn(tintColor);
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
Bitmap bitmap = mock(Bitmap.class);
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);

LocationLayerController controller =
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);

verify(style).addImage(FOREGROUND_ICON, bitmap);

int drawableGpsResId = 789;
when(options.gpsDrawable()).thenReturn(drawableGpsResId);

Bitmap bitmapGps = mock(Bitmap.class);
when(bitmapProvider.generateBitmap(drawableGpsResId, tintColor)).thenReturn(bitmapGps);

controller.hide();

controller.setRenderMode(RenderMode.GPS);

controller.show();

verify(style).addImage(FOREGROUND_ICON, bitmapGps);
}

private LayerFeatureProvider buildFeatureProvider(@NonNull LocationComponentOptions options) {
LayerFeatureProvider provider = mock(LayerFeatureProvider.class);
when(provider.generateLocationFeature(null, options)).thenReturn(mock(Feature.class));
Expand Down

0 comments on commit ace3a2f

Please sign in to comment.