修复了bug
优化了切换卡片联动气泡动画
This commit is contained in:
@@ -1,20 +1,14 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.animation.Animation;
|
||||
import com.amap.api.maps.model.animation.AnimationSet;
|
||||
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.marker.AMapMarkerWrapper;
|
||||
import com.mogo.map.impl.amap.utils.ObjectUtils;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
@@ -35,7 +29,6 @@ import com.mogo.module.service.Utils;
|
||||
import com.mogo.module.service.datamanager.MogoDataHandler;
|
||||
import com.mogo.service.cardmanager.IMogoCardChangedListener;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONArray;
|
||||
@@ -227,47 +220,29 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
|
||||
|
||||
if (alpha == 1) {
|
||||
try {
|
||||
Point point = MarkerServiceHandler.getMapUIController().getLocationPointInScreen(mogoMarker.getPosition());
|
||||
point.y -= WindowUtils.dip2px(mContext, 100f);
|
||||
MogoLatLng targetMogoLatLng = MarkerServiceHandler.getMapUIController().getLocationMogoLatLngInScreen(point);
|
||||
LatLng target = ObjectUtils.fromMogo2(targetMogoLatLng);
|
||||
// 使用TranslateAnimation,填写一个需要移动的目标点
|
||||
AnimationSet animationSet = new AnimationSet(true);
|
||||
Animation animationTranslate = new TranslateAnimation(target);
|
||||
Animation animationScale = new ScaleAnimation(0.5f,2.5f,0.5f,2.5f);
|
||||
|
||||
animationScale.setInterpolator(new Interpolator() {
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
if (input <= 0.5) {
|
||||
return (float) (0.5f - 2.0 * (0.5 - input) * (0.5 - input));
|
||||
} else {
|
||||
return (float) (0.5f - Math.sqrt((double) ((input - 0.5f) * (1.5f - input))));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
animationSet.setInterpolator(new Interpolator() {
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
if (input <= 0.5) {
|
||||
return (float) (0.5f - 2.0 * (0.5 - input) * (0.5 - input));
|
||||
} else {
|
||||
return (float) (0.5f - Math.sqrt((double) ((input - 0.5f) * (1.5f - input))));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 整个移动所需要的时间
|
||||
animationSet.setDuration(1000);
|
||||
|
||||
// 添加动画集合
|
||||
animationSet.addAnimation(animationTranslate);
|
||||
animationSet.addAnimation(animationScale);
|
||||
ScaleAnimation animationScale = new ScaleAnimation(0.5f, 1.2f, 0.5f, 1.2f);
|
||||
animationScale.setDuration(500);
|
||||
animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
|
||||
|
||||
// 设置动画
|
||||
if (mogoMarker instanceof AMapMarkerWrapper) {
|
||||
((AMapMarkerWrapper) mogoMarker).getMarker().setAnimation(animationSet);
|
||||
((AMapMarkerWrapper) mogoMarker).getMarker().setAnimation(animationScale);
|
||||
((AMapMarkerWrapper) mogoMarker).getMarker().startAnimation();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "error.");
|
||||
}
|
||||
}else{
|
||||
try {
|
||||
// 使用TranslateAnimation,填写一个需要移动的目标点
|
||||
ScaleAnimation animationScale = new ScaleAnimation(1.2f, 1f, 1.2f, 1f);
|
||||
animationScale.setDuration(500);
|
||||
animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
|
||||
|
||||
// 设置动画
|
||||
if (mogoMarker instanceof AMapMarkerWrapper) {
|
||||
((AMapMarkerWrapper) mogoMarker).getMarker().setAnimation(animationScale);
|
||||
((AMapMarkerWrapper) mogoMarker).getMarker().startAnimation();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user