Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
adding animation cancel in onDestroy
Browse files Browse the repository at this point in the history
  • Loading branch information
langsmith committed May 13, 2019
1 parent b9402a6 commit 4d4e13a
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
public class IconSizeChangeOnClickActivity extends AppCompatActivity implements
OnMapReadyCallback, MapboxMap.OnMapClickListener {

private ValueAnimator markerAnimator;
private MapView mapView;
private MapboxMap mapboxMap;
private boolean markerSelected = false;
Expand Down Expand Up @@ -138,7 +139,7 @@ public boolean onMapClick(@NonNull LatLng point) {
}

private void selectMarker(final SymbolLayer iconLayer) {
ValueAnimator markerAnimator = new ValueAnimator();
markerAnimator = new ValueAnimator();
markerAnimator.setObjectValues(1f, 2f);
markerAnimator.setDuration(300);
markerAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
Expand All @@ -155,7 +156,6 @@ public void onAnimationUpdate(ValueAnimator animator) {
}

private void deselectMarker(final SymbolLayer iconLayer) {
ValueAnimator markerAnimator = new ValueAnimator();
markerAnimator.setObjectValues(2f, 1f);
markerAnimator.setDuration(300);
markerAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
Expand Down Expand Up @@ -207,6 +207,9 @@ protected void onDestroy() {
if (mapboxMap != null) {
mapboxMap.removeOnMapClickListener(this);
}
if (markerAnimator != null) {
markerAnimator.cancel();
}
mapView.onDestroy();
}

Expand Down

0 comments on commit 4d4e13a

Please sign in to comment.