Merge branch 'feature/v1.0.0' of gitlab.zhidaoauto.com:ecos/yycp-service/Launcher into feature/v1.0.0
This commit is contained in:
@@ -56,7 +56,7 @@ public class MarkerServiceHandler {
|
||||
mMarkerManager = mMapService.getMarkerManager(context);
|
||||
mNavi = mMapService.getNavi(context);
|
||||
mMapUIController = mMapService.getMapUIController();
|
||||
mLocationClient = mMapService.getLocationClient(context);
|
||||
mLocationClient = mMapService.getSingletonLocationClient(context);
|
||||
|
||||
mMapMarkerManager = MapMarkerManager.getInstance(context);
|
||||
mMapMarkerManager.init(context);
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
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.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;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.impl.amap.marker.AMapMarkerWrapper;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.marker.MogoMarkersHandler;
|
||||
import com.mogo.module.common.entity.MarkerCarChat;
|
||||
import com.mogo.module.common.entity.MarkerCardResult;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
@@ -33,6 +29,7 @@ import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.service.Utils;
|
||||
import com.mogo.module.service.datamanager.MogoDataHandler;
|
||||
import com.mogo.module.service.utils.ViewUtils;
|
||||
import com.mogo.service.cardmanager.IMogoCardChangedListener;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -57,7 +54,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
|
||||
private static final String TAG = "MapMarkerManager";
|
||||
// 第一次请求到地图的Marker数据
|
||||
private boolean isFirstMarker = true;
|
||||
private boolean isOnLineCard = false;
|
||||
private static Context mContext;
|
||||
private static IMogoMarker lastMarker;
|
||||
private static MapMarkerManager mMarkerManager;
|
||||
@@ -99,17 +95,15 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
|
||||
public void onSwitched(int position, String moduleName) {
|
||||
Logger.e(TAG, "======moduleName:" + moduleName);
|
||||
highlightedMarker(moduleName, false);
|
||||
|
||||
if (moduleName.equals(ServiceConst.CARD_TYPE_USER_DATA)) {
|
||||
isOnLineCard = true;
|
||||
} else {
|
||||
isOnLineCard = false;
|
||||
}
|
||||
mLastHighLightModule = moduleName;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ACC ON 的时候重置为true
|
||||
public void setFirstMarker(boolean firstMarker) {
|
||||
isFirstMarker = firstMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* 地图上的Marker点击回调
|
||||
@@ -129,26 +123,11 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
|
||||
return false;
|
||||
}
|
||||
// 将上次选中 Marker 设置为未选中状态
|
||||
MarkerShowEntity lastMarkerShowEntity = (MarkerShowEntity) lastMarker.getObject();
|
||||
Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker lastMarkerShowEntity:" + lastMarkerShowEntity);
|
||||
if (lastMarkerShowEntity != null) {
|
||||
lastMarkerShowEntity.setChecked(false);
|
||||
lastMarkerShowEntity.setHighlighted(false);
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, lastMarkerShowEntity, lastMarker.getMogoMarkerOptions());
|
||||
lastMarker.setIcon(fromView(markerView.getView()));
|
||||
}
|
||||
closeMarker(lastMarker);
|
||||
}
|
||||
|
||||
// 将当前的Marker设置为选中
|
||||
MarkerShowEntity markerShowEntity = (MarkerShowEntity) marker.getObject();
|
||||
Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker markerShowEntity:" + markerShowEntity);
|
||||
if (markerShowEntity != null) {
|
||||
markerShowEntity.setChecked(true);
|
||||
markerShowEntity.setHighlighted(true);
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, marker.getMogoMarkerOptions());
|
||||
marker.setIcon(fromView(markerView.getView()));
|
||||
}
|
||||
|
||||
openMarker(marker);
|
||||
lastMarker = marker;
|
||||
|
||||
// 数据统计代码
|
||||
@@ -200,31 +179,6 @@ 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) {
|
||||
highlightedMarker(typeTag, false);
|
||||
@@ -334,22 +288,38 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
|
||||
// 将上次选中 Marker 设置为未选中状态
|
||||
if (marker != null) {
|
||||
Logger.i(TAG, "closeMarkerSelect 将出Marker详情关闭:" + marker);
|
||||
|
||||
// 将上次选中 Marker 设置为未选中状态
|
||||
MarkerShowEntity lastMarkerShowEntity = (MarkerShowEntity) marker.getObject();
|
||||
lastMarkerShowEntity.setChecked(false);
|
||||
lastMarkerShowEntity.setHighlighted(false);
|
||||
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, lastMarkerShowEntity, marker.getMogoMarkerOptions());
|
||||
marker.setIcon(fromView(markerView.getView()));
|
||||
|
||||
closeMarker(marker);
|
||||
lastMarker = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制Marker
|
||||
*/
|
||||
// 展开气泡
|
||||
private void openMarker(IMogoMarker mogoMarker) {
|
||||
if (mogoMarker != null) {
|
||||
Object object = mogoMarker.getObject();
|
||||
if (object != null) {
|
||||
MarkerShowEntity markerShowEntity = (MarkerShowEntity) object;
|
||||
markerShowEntity.setChecked(true);
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions());
|
||||
mogoMarker.setIcon(ViewUtils.fromView(markerView.getView()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 折叠气泡
|
||||
private void closeMarker(IMogoMarker mogoMarker) {
|
||||
if (mogoMarker != null) {
|
||||
Object object = mogoMarker.getObject();
|
||||
if (object != null) {
|
||||
MarkerShowEntity markerShowEntity = (MarkerShowEntity) object;
|
||||
markerShowEntity.setChecked(false);
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions());
|
||||
mogoMarker.setIcon(ViewUtils.fromView(markerView.getView()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 绘制Marker
|
||||
public synchronized void drawMapMarker(MarkerResponse response) {
|
||||
lastMarker = null;
|
||||
|
||||
@@ -374,7 +344,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
|
||||
}
|
||||
}
|
||||
|
||||
List<MarkerCarChat> carChatList = markerCardResult.getCarChat();
|
||||
List<MarkerOnlineCar> onlineCarList = markerCardResult.getOnlineCar();
|
||||
List<MarkerExploreWay> exploreWayList = null;
|
||||
List<MarkerShareMusic> shareMusicList = null;
|
||||
@@ -387,7 +356,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
|
||||
noveltyInfoList = markerCardResult.getNoveltyInfo();
|
||||
}
|
||||
if (onlineCarList != null) {
|
||||
double nearlyDistance = Double.MAX_VALUE;
|
||||
double nearlyDistance = Float.MAX_VALUE;
|
||||
for (MarkerOnlineCar markerOnlineCar : onlineCarList) {
|
||||
MarkerLocation markerLocation = markerOnlineCar.getLocation();
|
||||
|
||||
@@ -401,16 +370,25 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
|
||||
IMogoMarker iMogoMarker = drawMapMarker(markerShowEntity);
|
||||
// 计算在线车辆距离当前车辆的距离,每次都与最后一次距离最近的进行比较,保留距离最近的车辆,进行卡片展示
|
||||
try {
|
||||
double calculateDistance = Utils.calculateLineDistance(
|
||||
new MogoLatLng(markerLocation.getLat(), markerLocation.getLat()),
|
||||
new MogoLatLng(
|
||||
MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation().getLatitude(),
|
||||
MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation().getLongitude()
|
||||
)
|
||||
// 当前车辆的位置
|
||||
MogoLocation currentLocation = MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation();
|
||||
|
||||
// 计算车辆距离指定气泡的距离
|
||||
float calculateDistance = Utils.calculateLineDistance(
|
||||
new MogoLatLng(markerLocation.getLat(), markerLocation.getLon()),
|
||||
new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude())
|
||||
);
|
||||
|
||||
// Logger.d("点之间距离",
|
||||
// "当前车辆经纬度:" +
|
||||
// "\n\tlatitude=" + currentLocation.getLatitude() +
|
||||
// "\n\tlongitude=" + currentLocation.getLongitude() +
|
||||
// "\n气泡经纬度:" + markerLocation +
|
||||
// "\n相距:" + calculateDistance + "米");
|
||||
|
||||
// 进行比较,保留最近的一个数据
|
||||
if (calculateDistance < nearlyDistance) {
|
||||
nearlyDistance = calculateDistance;
|
||||
nearlyMogoMarker = iMogoMarker;
|
||||
}
|
||||
|
||||
@@ -418,6 +396,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Logger.d("点之间距离", "距离当前车辆位置最近的距离为:" + nearlyDistance);
|
||||
fillNumberTrackEventBody(array, 3, onlineCarList.size());
|
||||
}
|
||||
|
||||
@@ -506,7 +485,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
|
||||
|
||||
try {
|
||||
// 在ACC on 之后第一次获取到了在线车辆数据,选中最近的一个Marker
|
||||
if (isFirstMarker && isOnLineCard) {
|
||||
if (isFirstMarker) {
|
||||
if (nearlyMogoMarker != null) {
|
||||
Logger.w(TAG, "ACC ON,或者语音搜索触发,默认选中最近的在线车辆nearlyMogoMarker:" + nearlyMogoMarker);
|
||||
onMarkerClicked(nearlyMogoMarker);
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.mogo.module.service.utils;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-02-2123:51
|
||||
* desc :
|
||||
* version: 1.0
|
||||
*/
|
||||
public class ViewUtils {
|
||||
public static 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;
|
||||
}
|
||||
|
||||
public static 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user