增加了切换卡片的动画
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
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.View;
|
||||
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.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;
|
||||
@@ -27,6 +33,7 @@ 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;
|
||||
@@ -49,7 +56,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
|
||||
// 第一次请求到地图的Marker数据
|
||||
private boolean isFirstMarker = true;
|
||||
private boolean isOnLineCard = false;
|
||||
private Context mContext;
|
||||
private static Context mContext;
|
||||
private static IMogoMarker lastMarker;
|
||||
private static MapMarkerManager mMarkerManager;
|
||||
|
||||
@@ -191,30 +198,60 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
|
||||
public synchronized static void highlightedMarker(final String typeTag) {
|
||||
try {
|
||||
|
||||
if ( TextUtils.equals( mLastHighLightModule, typeTag ) ) {
|
||||
if (TextUtils.equals(mLastHighLightModule, typeTag)) {
|
||||
return;
|
||||
}
|
||||
// 上一次高亮的变暗
|
||||
List<IMogoMarker> lastHighLightList = MarkerServiceHandler.getMarkerManager().getMarkers( mLastHighLightModule );
|
||||
List<IMogoMarker> lastHighLightList = MarkerServiceHandler.getMarkerManager().getMarkers(mLastHighLightModule);
|
||||
setMarkersAlpha(lastHighLightList, 0.7f);
|
||||
|
||||
// 将当前高亮
|
||||
List<IMogoMarker> currentHighLightList = MarkerServiceHandler.getMarkerManager().getMarkers( typeTag );
|
||||
List<IMogoMarker> currentHighLightList = MarkerServiceHandler.getMarkerManager().getMarkers(typeTag);
|
||||
setMarkersAlpha(currentHighLightList, 1f);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void setMarkersAlpha(List<IMogoMarker> markers,float alpha){
|
||||
if ( markers == null || markers.isEmpty() ) {
|
||||
private static void setMarkersAlpha(List<IMogoMarker> markers, float alpha) {
|
||||
if (markers == null || markers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for ( IMogoMarker mogoMarker : markers ) {
|
||||
if ( mogoMarker == null || mogoMarker.isDestroyed() ) {
|
||||
for (IMogoMarker mogoMarker : markers) {
|
||||
if (mogoMarker == null || mogoMarker.isDestroyed()) {
|
||||
continue;
|
||||
}
|
||||
mogoMarker.setAlpha( alpha );
|
||||
mogoMarker.setAlpha(alpha);
|
||||
|
||||
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,填写一个需要移动的目标点
|
||||
Animation animation = new TranslateAnimation(target);
|
||||
animation.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))));
|
||||
}
|
||||
}
|
||||
});
|
||||
//整个移动所需要的时间
|
||||
animation.setDuration(1000);
|
||||
//设置动画
|
||||
if (mogoMarker instanceof AMapMarkerWrapper) {
|
||||
((AMapMarkerWrapper) mogoMarker).getMarker().setAnimation(animation);
|
||||
((AMapMarkerWrapper) mogoMarker).getMarker().startAnimation();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "error.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,7 +512,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
|
||||
options.icon(markerView.getView());
|
||||
|
||||
IMogoMarker marker = MarkerServiceHandler.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
|
||||
markerView.setMarker( marker );
|
||||
markerView.setMarker(marker);
|
||||
marker.setOnMarkerClickListener(this);
|
||||
return marker;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user