修复了bug

修改了切换卡片联动的地图气泡动画
This commit is contained in:
董宏宇
2020-02-19 17:11:00 +08:00
parent bf21e6a1ee
commit f62429020f

View File

@@ -4,6 +4,8 @@ import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.view.animation.AnticipateOvershootInterpolator;
import android.view.animation.BounceInterpolator;
import com.amap.api.maps.model.animation.Animation;
import com.amap.api.maps.model.animation.ScaleAnimation;
@@ -35,6 +37,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -122,7 +125,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
lastMarkerShowEntity.setChecked(false);
lastMarkerShowEntity.setHighlighted(false);
drawMapMarker(lastMarkerShowEntity);
drawMapMarker(lastMarkerShowEntity, true);
lastMarker.remove();
}
@@ -134,10 +137,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
markerShowEntity.setChecked(true);
markerShowEntity.setHighlighted(true);
lastMarker = drawMapMarker(markerShowEntity);
if (lastMarker != null) {
lastMarker.setAlpha(1f);
}
lastMarker = drawMapMarker(markerShowEntity, false);
marker.remove();
@@ -192,23 +192,22 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
// 对指定类型高亮处理
public synchronized static void highlightedMarker(final String typeTag) {
try {
if (TextUtils.equals(mLastHighLightModule, typeTag)) {
return;
}
// 上一次高亮的变暗
List<IMogoMarker> lastHighLightList = MarkerServiceHandler.getMarkerManager().getMarkers(mLastHighLightModule);
setMarkersAlpha(lastHighLightList, 0.7f);
setMarkersSmall(lastHighLightList);
// 将当前高亮
List<IMogoMarker> currentHighLightList = MarkerServiceHandler.getMarkerManager().getMarkers(typeTag);
setMarkersAlpha(currentHighLightList, 1f);
setMarkersBig(currentHighLightList);
} catch (Exception e) {
e.printStackTrace();
}
}
private static void setMarkersAlpha(List<IMogoMarker> markers, float alpha) {
private static void setMarkersBig(List<IMogoMarker> markers) {
if (markers == null || markers.isEmpty()) {
return;
}
@@ -216,39 +215,46 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
if (mogoMarker == null || mogoMarker.isDestroyed()) {
continue;
}
mogoMarker.setAlpha(alpha);
mogoMarker.setToTop();
try {
// 使用TranslateAnimation,填写一个需要移动的目标点
ScaleAnimation animationScale = new ScaleAnimation(0.5f, 1f, 0.5f, 1f);
animationScale.setDuration(500);
animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
animationScale.setInterpolator(new AnticipateOvershootInterpolator());
if (alpha == 1) {
mogoMarker.setToTop();
try {
// 使用TranslateAnimation,填写一个需要移动的目标点
ScaleAnimation animationScale = new ScaleAnimation(0.1f, 1.2f, 0.1f, 1.2f);
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) {
Logger.e(TAG, e, "error.");
// 设置动画
if (mogoMarker instanceof AMapMarkerWrapper) {
((AMapMarkerWrapper) mogoMarker).getMarker().setAnimation(animationScale);
((AMapMarkerWrapper) mogoMarker).getMarker().startAnimation();
}
} else {
try {
// 使用TranslateAnimation,填写一个需要移动的目标点
ScaleAnimation animationScale = new ScaleAnimation(1.2f, 0.9f, 1.2f, 0.9f);
animationScale.setDuration(500);
animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
// 设置动画
if (mogoMarker instanceof AMapMarkerWrapper) {
((AMapMarkerWrapper) mogoMarker).getMarker().setAnimation(animationScale);
((AMapMarkerWrapper) mogoMarker).getMarker().startAnimation();
}
} catch (Exception e) {
Logger.e(TAG, e, "error.");
private static void setMarkersSmall(List<IMogoMarker> markers) {
if (markers == null || markers.isEmpty()) {
return;
}
for (IMogoMarker mogoMarker : markers) {
if (mogoMarker == null || mogoMarker.isDestroyed()) {
continue;
}
try {
// 使用TranslateAnimation,填写一个需要移动的目标点
ScaleAnimation animationScale = new ScaleAnimation(1f, 0.5f, 1f, 0.5f);
animationScale.setDuration(400);
animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
// 设置动画
if (mogoMarker instanceof AMapMarkerWrapper) {
((AMapMarkerWrapper) mogoMarker).getMarker().setAnimation(animationScale);
((AMapMarkerWrapper) mogoMarker).getMarker().startAnimation();
}
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
}
@@ -306,21 +312,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
List<MarkerShareMusic> shareMusicList = markerCardResult.getShareMusic();
List<MarkerNoveltyInfo> noveltyInfoList = markerCardResult.getNoveltyInfo();
// if (carChatList != null) {
// for (MarkerCarChat markerCarChat : carChatList) {
// MarkerLocation markerLocation = markerCarChat.getLocation();
//
// MarkerShowEntity markerShowEntity = new MarkerShowEntity();
// markerShowEntity.setBindObj(markerCarChat);
// markerShowEntity.setMarkerLocation(markerLocation);
// markerShowEntity.setMarkerType(markerCarChat.getType());
// markerShowEntity.setTextContent(markerCarChat.getUserInfo().getUserName());
// markerShowEntity.setIconUrl(markerCarChat.getUserInfo().getUserHead());
//
// drawMapMarker(markerShowEntity);
// }
// }
if (onlineCarList != null) {
IMogoMarker nearlyMogoMarker = null;
double nearlyDistance = Double.MAX_VALUE;
@@ -360,10 +351,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
// 在ACC on 之后第一次获取到了在线车辆数据选中最近的一个Marker
if (isFirstMarker && isOnLineCard) {
if (nearlyMogoMarker != null) {
// getMogoCardManager().switch2(ServiceConst.CARD_TYPE_USER_DATA);
// MarkerShowEntity markerShowEntity = (MarkerShowEntity) nearlyMogoMarker.getObject();
// MarkerOnlineCar markerOnlineCar = (MarkerOnlineCar) markerShowEntity.getBindObj();
// onLineCarCardViewProvider.updateView(markerOnlineCar);
MogoMarkersHandler.getInstance().onMarkerClicked(nearlyMogoMarker);
isFirstMarker = false;
}
@@ -496,13 +483,16 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
* @return 绘制的Marker
*/
public synchronized IMogoMarker drawMapMarker(MarkerShowEntity markerShowEntity) {
return drawMapMarker(markerShowEntity, true);
}
private synchronized IMogoMarker drawMapMarker(MarkerShowEntity markerShowEntity, boolean isSmall) {
//Logger.i(TAG, "绘制Marker====drawMapMarker" + markerShowEntity);
try {
if (markerShowEntity.getMarkerLocation() != null) {
MogoMarkerOptions options = new MogoMarkerOptions()
.owner(markerShowEntity.getMarkerType())
.alpha(0.7f)
.object(markerShowEntity)
.latitude(markerShowEntity.getMarkerLocation().getLat())
.longitude(markerShowEntity.getMarkerLocation().getLon());
@@ -512,6 +502,12 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
IMogoMarker marker = MarkerServiceHandler.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
markerView.setMarker(marker);
marker.setOnMarkerClickListener(this);
if (isSmall) {
List<IMogoMarker> markers = new ArrayList<>();
markers.add(marker);
setMarkersSmall(markers);
}
return marker;
} else {
Logger.e(TAG, "Location 必须进行初始化!!!!!");