first approach to a marker continuosly chasing another

This commit is contained in:
Antonio Zugaldia
2016-06-09 15:15:44 -04:00
committed by Tobrun
parent 2f8fd61ac7
commit 27da49c5fb
4 changed files with 144 additions and 13 deletions

View File

@@ -12,6 +12,7 @@ import android.view.animation.AnimationUtils;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.utils.AnimatorUtils;
/**
* MarkerView is an annotation that shows an View at a geographical location.
@@ -55,6 +56,7 @@ public class MarkerView extends Marker {
private long startTime;
private long duration;
private long remainingTime;
private AnimatorUtils.OnAnimationEndListener animationEndListener;
/**
* Publicly hidden default constructor
@@ -358,6 +360,12 @@ public class MarkerView extends Marker {
}
public void setPosition(LatLng position, long duration) {
setPosition(position, duration, null);
}
public void setPosition(LatLng position, long duration, AnimatorUtils.OnAnimationEndListener animationEndListener) {
this.animationEndListener = animationEndListener;
if (duration <= 0) {
// update position instantly
super.setPosition(position);
@@ -414,6 +422,10 @@ public class MarkerView extends Marker {
this.startTime = startTime;
}
AnimatorUtils.OnAnimationEndListener getAnimationEndListener() {
return animationEndListener;
}
PointF getScreenLocation(@NonNull View convertView) {
return new PointF(convertView.getX() + offsetX, convertView.getY() + offsetY);
}