增加了切换卡片的动画
This commit is contained in:
@@ -533,6 +533,18 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getLocationMogoLatLngInScreen(Point point) {
|
||||
if ( checkAMapView() ) {
|
||||
try {
|
||||
return ObjectUtils.fromAMap(mMapView.getMap().getProjection().fromScreenLocation( point ));
|
||||
} catch ( Exception e ) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startJumpAnimation( IMogoMarker marker, float high, Interpolator interpolator, long duration ) {
|
||||
if ( marker == null || high <= 0.0f || interpolator == null || duration < 0 ) {
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package com.mogo.map.impl.amap.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.amap.api.maps.model.BitmapDescriptor;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
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.TranslateAnimation;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.impl.amap.utils.ObjectUtils;
|
||||
import com.mogo.map.marker.IMogoInfoWindowAdapter;
|
||||
@@ -16,6 +20,8 @@ import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.IMogoMarkerIconViewCreator;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Observable;
|
||||
@@ -29,6 +35,8 @@ import java.util.Observer;
|
||||
*/
|
||||
public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
|
||||
private final String TAG = AMapMarkerWrapper.class.getName();
|
||||
|
||||
private Marker mMarker;
|
||||
private Object mObject;
|
||||
private IMogoMarkerClickListener mMogoMarkerClickListener;
|
||||
|
||||
@@ -156,6 +156,14 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getLocationMogoLatLngInScreen(Point point) {
|
||||
if ( mClient != null ) {
|
||||
return mClient.getLocationMogoLatLngInScreen( point );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startJumpAnimation( IMogoMarker marker, float high, Interpolator interpolator, long duration ) {
|
||||
if ( mClient != null ) {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
|
||||
|
||||
@@ -115,6 +115,14 @@ public interface IMogoMapUIController {
|
||||
*/
|
||||
Point getLocationPointInScreen( MogoLatLng latLng );
|
||||
|
||||
/**
|
||||
* 获取像素点对应的经纬度
|
||||
*
|
||||
* @param point
|
||||
* @return
|
||||
*/
|
||||
MogoLatLng getLocationMogoLatLngInScreen( Point point );
|
||||
|
||||
/**
|
||||
* marker 跳跃动画
|
||||
*
|
||||
|
||||
@@ -149,6 +149,14 @@ public class MogoMapUIController implements IMogoMapUIController {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getLocationMogoLatLngInScreen(Point point) {
|
||||
if (mDelegate != null) {
|
||||
return mDelegate.getLocationMogoLatLngInScreen(point);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startJumpAnimation( IMogoMarker marker, float high, Interpolator interpolator, long duration ) {
|
||||
if ( mDelegate != null ) {
|
||||
|
||||
@@ -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