@@ -75,6 +75,11 @@ public class LocationLayerOptions implements Parcelable {
7575 */
7676 private static final long STALE_STATE_DELAY_MS = 30000 ;
7777
78+ /**
79+ * Default animation duration multiplier
80+ */
81+ private static final float TRACKING_ANIMATION_DURATION_MULTIPLIER_DEFAULT = 1.1f ;
82+
7883 private float accuracyAlpha ;
7984 private int accuracyColor ;
8085 private int backgroundDrawableStale ;
@@ -105,6 +110,7 @@ public class LocationLayerOptions implements Parcelable {
105110 private float trackingInitialMoveThreshold ;
106111 private float trackingMultiFingerMoveThreshold ;
107112 private String layerBelow ;
113+ private float trackingAnimationDurationMultiplier ;
108114
109115 public LocationLayerOptions (
110116 float accuracyAlpha ,
@@ -136,7 +142,8 @@ public LocationLayerOptions(
136142 float minZoomIconScale ,
137143 float trackingInitialMoveThreshold ,
138144 float trackingMultiFingerMoveThreshold ,
139- String layerBelow ) {
145+ String layerBelow ,
146+ float trackingAnimationDurationMultiplier ) {
140147 this .accuracyAlpha = accuracyAlpha ;
141148 this .accuracyColor = accuracyColor ;
142149 this .backgroundDrawableStale = backgroundDrawableStale ;
@@ -170,6 +177,7 @@ public LocationLayerOptions(
170177 this .trackingInitialMoveThreshold = trackingInitialMoveThreshold ;
171178 this .trackingMultiFingerMoveThreshold = trackingMultiFingerMoveThreshold ;
172179 this .layerBelow = layerBelow ;
180+ this .trackingAnimationDurationMultiplier = trackingAnimationDurationMultiplier ;
173181 }
174182
175183 /**
@@ -288,6 +296,11 @@ public static LocationLayerOptions createFromAttributes(@NonNull Context context
288296 builder .minZoomIconScale (minScale );
289297 builder .maxZoomIconScale (maxScale );
290298
299+ float trackingAnimationDurationMultiplier = typedArray .getFloat (
300+ R .styleable .mapbox_LocationLayer_mapbox_trackingAnimationDurationMultiplier ,
301+ TRACKING_ANIMATION_DURATION_MULTIPLIER_DEFAULT
302+ );
303+ builder .trackingAnimationDurationMultiplier (trackingAnimationDurationMultiplier );
291304 typedArray .recycle ();
292305
293306 return builder .build ();
@@ -715,6 +728,16 @@ public String layerBelow() {
715728 return layerBelow ;
716729 }
717730
731+ /**
732+ * Get the tracking animation duration multiplier.
733+ *
734+ * @return tracking animation duration multiplier
735+ * @since 0.9.0
736+ */
737+ public float trackingAnimationDurationMultiplier () {
738+ return trackingAnimationDurationMultiplier ;
739+ }
740+
718741 @ Override
719742 public String toString () {
720743 return "LocationLayerOptions{"
@@ -748,6 +771,7 @@ public String toString() {
748771 + "trackingInitialMoveThreshold=" + trackingInitialMoveThreshold + ", "
749772 + "trackingMultiFingerMoveThreshold=" + trackingMultiFingerMoveThreshold + ", "
750773 + "layerBelow=" + layerBelow
774+ + "trackingAnimationDurationMultiplier=" + trackingAnimationDurationMultiplier
751775 + "}" ;
752776 }
753777
@@ -799,7 +823,9 @@ public boolean equals(Object o) {
799823 == Float .floatToIntBits (that .trackingInitialMoveThreshold ()))
800824 && (Float .floatToIntBits (this .trackingMultiFingerMoveThreshold )
801825 == Float .floatToIntBits (that .trackingMultiFingerMoveThreshold ()))
802- && layerBelow .equals (that .layerBelow ));
826+ && layerBelow .equals (that .layerBelow ))
827+ && (Float .floatToIntBits (this .trackingAnimationDurationMultiplier )
828+ == Float .floatToIntBits (that .trackingAnimationDurationMultiplier ()));
803829 }
804830 return false ;
805831 }
@@ -865,52 +891,55 @@ public int hashCode() {
865891 h$ ^= Float .floatToIntBits (trackingInitialMoveThreshold );
866892 h$ *= 1000003 ;
867893 h$ ^= Float .floatToIntBits (trackingMultiFingerMoveThreshold );
894+ h$ *= 1000003 ;
895+ h$ ^= Float .floatToIntBits (trackingAnimationDurationMultiplier );
868896 return h$ ;
869897 }
870898
871899 public static final Parcelable .Creator <LocationLayerOptions > CREATOR =
872900 new Parcelable .Creator <LocationLayerOptions >() {
873- @ Override
874- public LocationLayerOptions createFromParcel (Parcel in ) {
875- return new LocationLayerOptions (
876- in .readFloat (),
877- in .readInt (),
878- in .readInt (),
879- in .readInt () == 0 ? in .readString () : null ,
880- in .readInt (),
881- in .readInt () == 0 ? in .readString () : null ,
882- in .readInt (),
883- in .readInt () == 0 ? in .readString () : null ,
884- in .readInt (),
885- in .readInt () == 0 ? in .readString () : null ,
886- in .readInt (),
887- in .readInt () == 0 ? in .readString () : null ,
888- in .readInt (),
889- in .readInt () == 0 ? in .readString () : null ,
890- in .readInt () == 0 ? in .readInt () : null ,
891- in .readInt () == 0 ? in .readInt () : null ,
892- in .readInt () == 0 ? in .readInt () : null ,
893- in .readInt () == 0 ? in .readInt () : null ,
894- in .readInt () == 0 ? in .readInt () : null ,
895- in .readFloat (),
896- in .readInt () == 1 ,
897- in .readLong (),
898- in .createIntArray (),
899- in .readDouble (),
900- in .readDouble (),
901- in .readFloat (),
902- in .readFloat (),
903- in .readFloat (),
904- in .readFloat (),
905- in .readString ()
906- );
907- }
901+ @ Override
902+ public LocationLayerOptions createFromParcel (Parcel in ) {
903+ return new LocationLayerOptions (
904+ in .readFloat (),
905+ in .readInt (),
906+ in .readInt (),
907+ in .readInt () == 0 ? in .readString () : null ,
908+ in .readInt (),
909+ in .readInt () == 0 ? in .readString () : null ,
910+ in .readInt (),
911+ in .readInt () == 0 ? in .readString () : null ,
912+ in .readInt (),
913+ in .readInt () == 0 ? in .readString () : null ,
914+ in .readInt (),
915+ in .readInt () == 0 ? in .readString () : null ,
916+ in .readInt (),
917+ in .readInt () == 0 ? in .readString () : null ,
918+ in .readInt () == 0 ? in .readInt () : null ,
919+ in .readInt () == 0 ? in .readInt () : null ,
920+ in .readInt () == 0 ? in .readInt () : null ,
921+ in .readInt () == 0 ? in .readInt () : null ,
922+ in .readInt () == 0 ? in .readInt () : null ,
923+ in .readFloat (),
924+ in .readInt () == 1 ,
925+ in .readLong (),
926+ in .createIntArray (),
927+ in .readDouble (),
928+ in .readDouble (),
929+ in .readFloat (),
930+ in .readFloat (),
931+ in .readFloat (),
932+ in .readFloat (),
933+ in .readString (),
934+ in .readFloat ()
935+ );
936+ }
908937
909- @ Override
910- public LocationLayerOptions [] newArray (int size ) {
911- return new LocationLayerOptions [size ];
912- }
913- };
938+ @ Override
939+ public LocationLayerOptions [] newArray (int size ) {
940+ return new LocationLayerOptions [size ];
941+ }
942+ };
914943
915944 @ Override
916945 public void writeToParcel (Parcel dest , int flags ) {
@@ -999,6 +1028,7 @@ public void writeToParcel(Parcel dest, int flags) {
9991028 dest .writeFloat (trackingInitialMoveThreshold ());
10001029 dest .writeFloat (trackingMultiFingerMoveThreshold ());
10011030 dest .writeString (layerBelow ());
1031+ dest .writeFloat (trackingAnimationDurationMultiplier );
10021032 }
10031033
10041034 @ Override
@@ -1064,6 +1094,7 @@ public LocationLayerOptions build() {
10641094 private Float trackingInitialMoveThreshold ;
10651095 private Float trackingMultiFingerMoveThreshold ;
10661096 private String layerBelow ;
1097+ private Float trackingAnimationDurationMultiplier ;
10671098
10681099 Builder () {
10691100 }
@@ -1099,6 +1130,7 @@ private Builder(LocationLayerOptions source) {
10991130 this .trackingInitialMoveThreshold = source .trackingInitialMoveThreshold ();
11001131 this .trackingMultiFingerMoveThreshold = source .trackingMultiFingerMoveThreshold ();
11011132 this .layerBelow = source .layerBelow ();
1133+ this .trackingAnimationDurationMultiplier = source .trackingAnimationDurationMultiplier ();
11021134 }
11031135
11041136 /**
@@ -1534,6 +1566,17 @@ public LocationLayerOptions.Builder layerBelow(String layerBelow) {
15341566 return this ;
15351567 }
15361568
1569+ /**
1570+ * Sets the tracking animation duration multiplier.
1571+ *
1572+ * @param trackingAnimationDurationMultiplier the tracking animation duration multiplier
1573+ * @since 0.9.0
1574+ */
1575+ public LocationLayerOptions .Builder trackingAnimationDurationMultiplier (float trackingAnimationDurationMultiplier ) {
1576+ this .trackingAnimationDurationMultiplier = trackingAnimationDurationMultiplier ;
1577+ return this ;
1578+ }
1579+
15371580 LocationLayerOptions autoBuild () {
15381581 String missing = "" ;
15391582 if (this .accuracyAlpha == null ) {
@@ -1590,6 +1633,9 @@ LocationLayerOptions autoBuild() {
15901633 if (this .trackingMultiFingerMoveThreshold == null ) {
15911634 missing += " trackingMultiFingerMoveThreshold" ;
15921635 }
1636+ if (this .trackingAnimationDurationMultiplier == null ) {
1637+ missing += " trackingAnimationDurationMultiplier" ;
1638+ }
15931639 if (!missing .isEmpty ()) {
15941640 throw new IllegalStateException ("Missing required properties:" + missing );
15951641 }
@@ -1623,7 +1669,8 @@ LocationLayerOptions autoBuild() {
16231669 this .minZoomIconScale ,
16241670 this .trackingInitialMoveThreshold ,
16251671 this .trackingMultiFingerMoveThreshold ,
1626- this .layerBelow );
1672+ this .layerBelow ,
1673+ this .trackingAnimationDurationMultiplier );
16271674 }
16281675 }
16291676}
0 commit comments