修复了bug

修改了切换卡片的地图气泡动画
This commit is contained in:
董宏宇
2020-02-19 21:04:59 +08:00
parent 764806a977
commit 0723694dba
3 changed files with 114 additions and 46 deletions

View File

@@ -132,10 +132,10 @@ public class MarkerServiceHandler {
/**
* 对指定类型高亮处理
* 建议使用
* @see MapMarkerManager#highlightedMarker(String)
* @see MapMarkerManager#highlightedMarker(String,boolean)
*/
@Deprecated
public static void highlightedMarker(String typeTag) {
getMapMarkerManager().highlightedMarker(typeTag);
getMapMarkerManager().highlightedMarker(typeTag,false);
}
}

View File

@@ -554,6 +554,8 @@ public class MogoServiceProvider implements IMogoModuleProvider,
if ( isTrue ) {
// V2X_UI时不在自动刷新打点策略
stopAutoRefreshStrategy();
// 清除所有的打点信息记录
MarkerServiceHandler.getMapMarkerManager().alreadySmallMarker.clear();
} else {
// 主动刷新
refreshStrategy();

View File

@@ -1,11 +1,15 @@
package com.mogo.module.service.marker;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.view.animation.AnticipateOvershootInterpolator;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.BounceInterpolator;
import android.view.animation.OvershootInterpolator;
import android.widget.TextView;
import com.amap.api.maps.model.animation.Animation;
import com.amap.api.maps.model.animation.ScaleAnimation;
@@ -58,7 +62,10 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
private static IMogoMarker lastMarker;
private static MapMarkerManager mMarkerManager;
private static String mLastHighLightModule = null;
private static String mLastHighLightModule = "";
// 记录其它已经缩小的Marker
public static ArrayList<String> alreadySmallMarker = new ArrayList<>();
private MapMarkerManager() {
}
@@ -90,7 +97,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
@Override
public void onSwitched(int position, String moduleName) {
Logger.e(TAG, "======moduleName" + moduleName);
highlightedMarker(moduleName);
highlightedMarker(moduleName, false);
if (moduleName.equals(ServiceConst.CARD_TYPE_USER_DATA)) {
isOnLineCard = true;
@@ -116,31 +123,26 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
Logger.w(TAG, "onMarkerClicked 与上一次点击的Marker一样不做处理" + marker);
return false;
}
// 将上次选中 Marker 设置为未选中状态
MarkerShowEntity lastMarkerShowEntity = (MarkerShowEntity) lastMarker.getObject();
Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker lastMarkerShowEntity" + lastMarkerShowEntity);
lastMarkerShowEntity.setChecked(false);
lastMarkerShowEntity.setHighlighted(false);
drawMapMarker(lastMarkerShowEntity, true);
lastMarker.remove();
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, lastMarkerShowEntity, lastMarker.getMogoMarkerOptions());
lastMarker.setIcon(fromView(markerView.getView()));
}
// 将当前的Marker设置为选中
MarkerShowEntity markerShowEntity = (MarkerShowEntity) marker.getObject();
Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker markerShowEntity" + markerShowEntity);
markerShowEntity.setChecked(true);
markerShowEntity.setHighlighted(true);
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, marker.getMogoMarkerOptions());
marker.setIcon(fromView(markerView.getView()));
lastMarker = drawMapMarker(markerShowEntity, false);
marker.remove();
lastMarker = marker;
// 数据统计代码
final Map<String, Object> properties = new HashMap<>();
switch (lastMarker.getOwner()) {
case ServiceConst.CARD_TYPE_CARS_CHATTING:
@@ -189,19 +191,66 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
}
private Bitmap fromView(View view) {
view.setDrawingCacheEnabled(true);
processChildView(view);
view.destroyDrawingCache();
view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
Bitmap bitmap = null;
return (bitmap = view.getDrawingCache()) != null ? bitmap.copy(Bitmap.Config.ARGB_8888, false) : null;
}
private void processChildView(View view) {
if (!(view instanceof ViewGroup)) {
if (view instanceof TextView) {
((TextView) view).setHorizontallyScrolling(false);
}
} else {
for (int var1 = 0; var1 < ((ViewGroup) view).getChildCount(); ++var1) {
processChildView(((ViewGroup) view).getChildAt(var1));
}
}
}
// 对指定类型高亮处理
public synchronized static void highlightedMarker(final String typeTag) {
public synchronized static void highlightedMarker(final String typeTag, final boolean netDataRefresh) {
try {
if (TextUtils.equals(mLastHighLightModule, typeTag)) {
Logger.e(TAG, "上一次选中的卡片类型mLastHighLightModule==" + mLastHighLightModule);
if (!TextUtils.isEmpty(mLastHighLightModule) && TextUtils.equals(mLastHighLightModule, typeTag) && !netDataRefresh) {
return;
}
// 上一次高亮的变暗
List<IMogoMarker> lastHighLightList = MarkerServiceHandler.getMarkerManager().getMarkers(mLastHighLightModule);
setMarkersSmall(lastHighLightList);
// 将当前高亮
// 从已经缩小的记录删除
alreadySmallMarker.remove(typeTag);
List<IMogoMarker> currentHighLightList = MarkerServiceHandler.getMarkerManager().getMarkers(typeTag);
setMarkersBig(currentHighLightList);
if (currentHighLightList == null || currentHighLightList.size() == 0) {
alreadySmallMarker.clear();
// 放大所有的气泡
Map<String, List<IMogoMarker>> lastHighLightList = MarkerServiceHandler.getMarkerManager().getAllMarkers();
for (String markerName : lastHighLightList.keySet()) {
setMarkersBig(lastHighLightList.get(markerName));
}
} else {
// 将当前卡片选中的气泡放大
setMarkersBig(currentHighLightList);
// 缩小其他的气泡
Map<String, List<IMogoMarker>> lastHighLightList = MarkerServiceHandler.getMarkerManager().getAllMarkers();
for (String markerName : lastHighLightList.keySet()) {
if (!markerName.equals(typeTag)) {
if (!alreadySmallMarker.contains(markerName)) {
alreadySmallMarker.add(markerName);
setMarkersSmall(lastHighLightList.get(markerName));
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
@@ -218,10 +267,10 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
mogoMarker.setToTop();
try {
// 使用TranslateAnimation,填写一个需要移动的目标点
ScaleAnimation animationScale = new ScaleAnimation(0.5f, 1f, 0.5f, 1f);
animationScale.setDuration(500);
ScaleAnimation animationScale = new ScaleAnimation(0.6f, 1f, 0.6f, 1f);
animationScale.setDuration(1000);
animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
animationScale.setInterpolator(new AnticipateOvershootInterpolator());
animationScale.setInterpolator(new BounceInterpolator());
// 设置动画
if (mogoMarker instanceof AMapMarkerWrapper) {
@@ -239,23 +288,28 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
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);
smallMarker(mogoMarker);
}
}
// 设置动画
if (mogoMarker instanceof AMapMarkerWrapper) {
((AMapMarkerWrapper) mogoMarker).getMarker().setAnimation(animationScale);
((AMapMarkerWrapper) mogoMarker).getMarker().startAnimation();
}
} catch (Exception e) {
Logger.e(TAG, e, "error.");
private static void smallMarker(IMogoMarker mogoMarker) {
if (mogoMarker == null || mogoMarker.isDestroyed()) {
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();
}
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}
}
@@ -274,8 +328,8 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
lastMarkerShowEntity.setChecked(false);
lastMarkerShowEntity.setHighlighted(false);
drawMapMarker(lastMarkerShowEntity);
marker.remove();
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, lastMarkerShowEntity, marker.getMogoMarkerOptions());
marker.setIcon(fromView(markerView.getView()));
lastMarker = null;
}
@@ -438,6 +492,11 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
fillNumberTrackEventBody(array, 8, num_fours_shop);
}
analyticData(array);
// 同步新绘制的气泡状态
alreadySmallMarker.clear();
highlightedMarker(mLastHighLightModule, true);
MarkerServiceHandler.getMapUIController().changeZoom(12);
}
}
@@ -483,14 +542,21 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
* @return 绘制的Marker
*/
public synchronized IMogoMarker drawMapMarker(MarkerShowEntity markerShowEntity) {
return drawMapMarker(markerShowEntity, true);
if (!TextUtils.isEmpty(mLastHighLightModule)
&& lastMarker != null
&& !TextUtils.isEmpty(lastMarker.getOwner())
&& TextUtils.equals(mLastHighLightModule, lastMarker.getOwner())
) {
return drawMapMarker(markerShowEntity, true);
} else {
return drawMapMarker(markerShowEntity, false);
}
}
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())
.object(markerShowEntity)