opt: sink marker animation
This commit is contained in:
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.view.View;
|
||||
import android.view.animation.BounceInterpolator;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.amap.api.maps.model.BitmapDescriptor;
|
||||
@@ -12,6 +13,7 @@ import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.model.animation.Animation;
|
||||
import com.amap.api.maps.model.animation.ScaleAnimation;
|
||||
import com.amap.api.maps.model.animation.TranslateAnimation;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.impl.amap.utils.ObjectUtils;
|
||||
@@ -310,4 +312,19 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
public MogoMarkerOptions getMogoMarkerOptions() {
|
||||
return mMogoMarkerOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startScaleAnimation( float fromX, float toX, float fromY, float toY, int duration, Interpolator interpolator ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScaleAnimation animationScale = new ScaleAnimation(fromX, toX, fromY, toY);
|
||||
animationScale.setDuration(duration);
|
||||
animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
|
||||
animationScale.setInterpolator(interpolator);
|
||||
|
||||
mMarker.setAnimation( animationScale );
|
||||
mMarker.startAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,8 +227,23 @@ public interface IMogoMarker {
|
||||
|
||||
/**
|
||||
* Marker 配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
MogoMarkerOptions getMogoMarkerOptions();
|
||||
|
||||
|
||||
/**
|
||||
* 开始缩放动画
|
||||
*
|
||||
* @param duration
|
||||
* @param interpolator
|
||||
*/
|
||||
void startScaleAnimation( float fromX,
|
||||
float toX,
|
||||
float fromY,
|
||||
float toY,
|
||||
int duration,
|
||||
Interpolator interpolator );
|
||||
|
||||
}
|
||||
|
||||
@@ -7,10 +7,7 @@ import android.text.TextUtils;
|
||||
import android.view.animation.BounceInterpolator;
|
||||
import android.view.animation.OvershootInterpolator;
|
||||
|
||||
import com.amap.api.maps.model.animation.Animation;
|
||||
import com.amap.api.maps.model.animation.ScaleAnimation;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.impl.amap.marker.AMapMarkerWrapper;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
@@ -229,18 +226,8 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
|
||||
}
|
||||
mogoMarker.setToTop();
|
||||
try {
|
||||
// 使用TranslateAnimation,填写一个需要移动的目标点
|
||||
ScaleAnimation animationScale = new ScaleAnimation(0.6f, 1f, 0.6f, 1f);
|
||||
animationScale.setDuration(1000);
|
||||
animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
|
||||
animationScale.setInterpolator(new BounceInterpolator());
|
||||
|
||||
// 设置动画
|
||||
if (mogoMarker instanceof AMapMarkerWrapper) {
|
||||
((AMapMarkerWrapper) mogoMarker).getMarker().setAnimation(animationScale);
|
||||
((AMapMarkerWrapper) mogoMarker).getMarker().startAnimation();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
mogoMarker.startScaleAnimation( 0.6f, 1f, 0.6f, 1f,1000, new BounceInterpolator( ) );
|
||||
} catch( Exception e ){
|
||||
Logger.e(TAG, e, "error.");
|
||||
}
|
||||
}
|
||||
@@ -260,17 +247,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// 使用TranslateAnimation,填写一个需要移动的目标点
|
||||
ScaleAnimation animationScale = new ScaleAnimation(1f, 0.6f, 1f, 0.6f);
|
||||
animationScale.setDuration(300);
|
||||
animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
|
||||
animationScale.setInterpolator(new OvershootInterpolator());
|
||||
|
||||
// 设置动画
|
||||
if (mogoMarker instanceof AMapMarkerWrapper) {
|
||||
((AMapMarkerWrapper) mogoMarker).getMarker().setAnimation(animationScale);
|
||||
((AMapMarkerWrapper) mogoMarker).getMarker().startAnimation();
|
||||
}
|
||||
mogoMarker.startScaleAnimation( 1f, 0.6f, 1f, 0.6f,300, new OvershootInterpolator( ) );
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "error.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user