-
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port: Allow setting padding when camera is tracking (#2165)
- Loading branch information
Showing
14 changed files
with
399 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...apboxGLAndroidSDK/src/main/java/org/maplibre/android/location/MapLibreAnimatorListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.maplibre.android.location | ||
|
||
import android.animation.Animator | ||
import android.animation.AnimatorListenerAdapter | ||
import org.maplibre.android.maps.MapLibreMap | ||
|
||
internal class MapLibreAnimatorListener(cancelableCallback: MapLibreMap.CancelableCallback?) : | ||
AnimatorListenerAdapter() { | ||
private val cancelableCallback: MapLibreMap.CancelableCallback? | ||
|
||
init { | ||
this.cancelableCallback = cancelableCallback | ||
} | ||
|
||
override fun onAnimationCancel(animation: Animator) { | ||
cancelableCallback?.onCancel() | ||
} | ||
|
||
override fun onAnimationEnd(animation: Animator) { | ||
cancelableCallback?.onFinish() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 1 addition & 23 deletions
24
...AndroidSDK/src/main/java/org/maplibre/android/location/MapLibreCameraAnimatorAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,17 @@ | ||
package org.maplibre.android.location; | ||
|
||
import android.animation.Animator; | ||
import android.animation.AnimatorListenerAdapter; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.annotation.Size; | ||
|
||
import org.maplibre.android.maps.MapLibreMap; | ||
|
||
class MapLibreCameraAnimatorAdapter extends MapLibreFloatAnimator { | ||
@Nullable | ||
private final MapLibreMap.CancelableCallback cancelableCallback; | ||
|
||
MapLibreCameraAnimatorAdapter(@NonNull @Size(min = 2) Float[] values, | ||
AnimationsValueChangeListener updateListener, | ||
@Nullable MapLibreMap.CancelableCallback cancelableCallback) { | ||
super(values, updateListener, Integer.MAX_VALUE); | ||
this.cancelableCallback = cancelableCallback; | ||
addListener(new MapLibreAnimatorListener()); | ||
} | ||
|
||
private final class MapLibreAnimatorListener extends AnimatorListenerAdapter { | ||
@Override | ||
public void onAnimationCancel(Animator animation) { | ||
if (cancelableCallback != null) { | ||
cancelableCallback.onCancel(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAnimationEnd(Animator animation) { | ||
if (cancelableCallback != null) { | ||
cancelableCallback.onFinish(); | ||
} | ||
} | ||
addListener(new MapLibreAnimatorListener(cancelableCallback)); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...MapboxGLAndroidSDK/src/main/java/org/maplibre/android/location/MapLibrePaddingAnimator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.maplibre.android.location | ||
|
||
import android.animation.TypeEvaluator | ||
import androidx.annotation.Size | ||
import org.maplibre.android.maps.MapLibreMap.CancelableCallback | ||
|
||
class MapLibrePaddingAnimator internal constructor( | ||
@Size(min = 2) values: Array<DoubleArray>, | ||
updateListener: AnimationsValueChangeListener<DoubleArray>, | ||
cancelableCallback: CancelableCallback? | ||
) : | ||
MapLibreAnimator<DoubleArray>(values, updateListener, Int.MAX_VALUE) { | ||
init { | ||
addListener(MapLibreAnimatorListener(cancelableCallback)) | ||
} | ||
|
||
public override fun provideEvaluator(): TypeEvaluator<DoubleArray> { | ||
return PaddingEvaluator() | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ndroid/MapboxGLAndroidSDK/src/main/java/org/maplibre/android/location/PaddingEvaluator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.maplibre.android.location | ||
|
||
import android.animation.TypeEvaluator | ||
import androidx.annotation.Size | ||
|
||
internal class PaddingEvaluator : TypeEvaluator<DoubleArray> { | ||
private val padding = DoubleArray(4) | ||
override fun evaluate( | ||
fraction: Float, @Size(min = 4) startValue: DoubleArray, | ||
@Size(min = 4) endValue: DoubleArray | ||
): DoubleArray { | ||
padding[0] = startValue[0] + (endValue[0] - startValue[0]) * fraction | ||
padding[1] = startValue[1] + (endValue[1] - startValue[1]) * fraction | ||
padding[2] = startValue[2] + (endValue[2] - startValue[2]) * fraction | ||
padding[3] = startValue[3] + (endValue[3] - startValue[3]) * fraction | ||
return padding | ||
} | ||
} |
Oops, something went wrong.