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

Commit

Permalink
consolidating pulse ui update methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Langston Smith committed Apr 1, 2020
1 parent 0d2ec13 commit f099ffd
Showing 1 changed file with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,26 +302,18 @@ private void updateAccuracyRadius(float accuracy) {
}

/**
* Updates the {@link LocationComponentConstants#PROPERTY_PULSING_RADIUS} property value and refreshes
* Updates the {@link LocationComponentConstants} property values and refreshes
* the LocationComponent source. This leads to a smooth update to the visuals of the pulsing
* LocationComponent circle.
*
* @param radius The new radius in the animation.
*/
private void updatePulsingLocationCircleRadius(float radius) {
locationFeature.addNumberProperty(PROPERTY_PULSING_RADIUS, radius);
refreshSource();
}

/**
* Updates the {@link LocationComponentConstants#PROPERTY_PULSING_OPACITY} property value and refreshes
* the LocationComponent source. This leads to a smooth update to the visuals of the pulsing
* LocationComponent circle. This is used if the fade option is set to true while setting pulsing options.
*
* @param opacity The new opacity in the animation.
*/
private void updatePulsingLocationCircleOpacity(float opacity) {
locationFeature.addNumberProperty(PROPERTY_PULSING_OPACITY, opacity);
private void updatePulsingUi(float radius, @Nullable Float opacity) {
locationFeature.addNumberProperty(PROPERTY_PULSING_RADIUS, radius);
if (opacity != null) {
locationFeature.addNumberProperty(PROPERTY_PULSING_OPACITY, opacity);
}
refreshSource();
}

Expand Down Expand Up @@ -517,17 +509,15 @@ public void onNewAnimationValue(Float value) {
private final MapboxAnimator.AnimationsValueChangeListener<Float> pulsingCircleRadiusListener =
new MapboxAnimator.AnimationsValueChangeListener<Float>() {
@Override
public void onNewAnimationValue(Float newPulsingRadiusValue) {
updatePulsingLocationCircleRadius(newPulsingRadiusValue);
public void onNewAnimationValue(Float newPulseRadiusValue) {
Float newPulseOpacityValue = null;
if (options.pulseFadeEnabled()) {
double newPulsingOpacityValue = 1 - ((newPulsingRadiusValue / 100) * 3);
updatePulsingLocationCircleOpacity((float) newPulsingOpacityValue);
newPulseOpacityValue = (float) 1 - ((newPulseRadiusValue / 100) * 3);
}
updatePulsingUi(newPulseRadiusValue, newPulseOpacityValue);
}
};



Set<AnimatorListenerHolder> getAnimationListeners() {
Set<AnimatorListenerHolder> holders = new HashSet<>();
holders.add(new AnimatorListenerHolder(MapboxAnimator.ANIMATOR_LAYER_LATLNG, latLngValueListener));
Expand Down

0 comments on commit f099ffd

Please sign in to comment.