[2.12.0] local code style change
This commit is contained in:
@@ -1,21 +1,12 @@
|
||||
package com.mogo.module.common.drawer;
|
||||
|
||||
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.module.common.R;
|
||||
import com.mogo.module.common.constants.AdasRecognizedType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/30
|
||||
@@ -24,67 +15,12 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
*/
|
||||
public class BaseDrawer {
|
||||
|
||||
/**
|
||||
* 移除过期的 marker
|
||||
*/
|
||||
public static final int MSG_REMOVE_DIRTY_MARKERS = 9990;
|
||||
|
||||
/**
|
||||
* 地图内部资源md5缓存,便于资源复用
|
||||
*/
|
||||
protected static final ConcurrentHashMap<String, String> mMarkerCachesResMd5Values = new ConcurrentHashMap<>();
|
||||
|
||||
protected final Context mContext;
|
||||
|
||||
public BaseDrawer() {
|
||||
mContext = AbsMogoApplication.getApp();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除无效[为 null 或者 已被销毁]的 marker
|
||||
*/
|
||||
protected void removeUselessMarker(Map<String, IMogoMarker> mMarkersCaches) {
|
||||
if (mMarkersCaches == null || mMarkersCaches.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Iterator<IMogoMarker> iterator = mMarkersCaches.values().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
IMogoMarker marker = iterator.next();
|
||||
if (marker != null) {
|
||||
iterator.remove();
|
||||
marker.remove();
|
||||
marker.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param msg 消息类型
|
||||
* @param data 数据体
|
||||
*/
|
||||
public void sendMessage(int msg, Object data) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是绘制内容
|
||||
*
|
||||
* @param type {@link AdasRecognizedType}
|
||||
* @return render
|
||||
*/
|
||||
public boolean nonRenderType(int type) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
|
||||
return recognizedType != AdasRecognizedType.classIdCar
|
||||
&& recognizedType != AdasRecognizedType.classIdMoto
|
||||
&& recognizedType != AdasRecognizedType.classIdBicycle
|
||||
&& recognizedType != AdasRecognizedType.classIdPerson
|
||||
&& recognizedType != AdasRecognizedType.classIdTrafficBus
|
||||
&& recognizedType != AdasRecognizedType.classIdTrafficTruck
|
||||
&& recognizedType != AdasRecognizedType.classIdUnKnow;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取3D锚点模型资源
|
||||
*
|
||||
@@ -115,118 +51,4 @@ public class BaseDrawer {
|
||||
return R.raw.special_vehicle;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据数据源判断车辆预警颜色
|
||||
*
|
||||
* @param type 车辆类型
|
||||
* @param fromType 数据来源
|
||||
* @param drawLevel 危险等级
|
||||
* @return 实际车辆颜色
|
||||
*/
|
||||
protected String getModelRenderColor(int type, int fromType, int drawLevel) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
|
||||
if (recognizedType == AdasRecognizedType.classIdUnKnow) {
|
||||
return Car3DModelColor.Normal.color;
|
||||
}
|
||||
if (fromType == FROM_ADAS) {
|
||||
switch (drawLevel) {
|
||||
case 0:
|
||||
case 1:
|
||||
return Car3DModelColor.Normal.color;
|
||||
case 2:
|
||||
return Car3DModelColor.Warming.color;
|
||||
case 3:
|
||||
return Car3DModelColor.Dangerous.color;
|
||||
default:
|
||||
return Car3DModelColor.Error.color;
|
||||
}
|
||||
}
|
||||
return Car3DModelColor.Normal.color;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回当前自车经纬度
|
||||
*
|
||||
* @return 0:lon 1:lat
|
||||
*/
|
||||
protected double[] getCurCoordinates() {
|
||||
return new double[]{
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lon(),
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lat()
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型颜色
|
||||
*/
|
||||
public enum Car3DModelColor {
|
||||
Normal("#D8D8D8FF"),
|
||||
Warming("#FFD53EFF"),
|
||||
Dangerous("#FF3C45FF"),
|
||||
Error("#7fb80e");
|
||||
private final String color;
|
||||
|
||||
Car3DModelColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除markers
|
||||
*
|
||||
* @param dirtyMarkers 缓存marker数据
|
||||
*/
|
||||
protected static void removeDirtyMarkers(Map<String, IMogoMarker> dirtyMarkers) {
|
||||
if (dirtyMarkers == null || dirtyMarkers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final Collection<IMogoMarker> dirSet = dirtyMarkers.values();
|
||||
for (IMogoMarker value : dirSet) {
|
||||
if (value == null || value.isDestroyed()) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
value.destroy();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
dirtyMarkers.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存绘制 marker 的 id 和 marker 资源缓存的 md5 的关系
|
||||
*
|
||||
* @param id 缓存资源ID
|
||||
* @param marker {@link IMogoMarker}
|
||||
*/
|
||||
protected static void cacheMarkerIconResMd5Val(String id, IMogoMarker marker) {
|
||||
if (marker == null || marker.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
String md5 = marker.getMarkerResName();
|
||||
if (TextUtils.isEmpty(md5) || TextUtils.isEmpty(id)) {
|
||||
return;
|
||||
}
|
||||
mMarkerCachesResMd5Values.put(id, md5);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用系统时间或卫星时间计算出动画的运动时间,最小值45,防止两个点距离过近设置的最小动画执行时间
|
||||
*
|
||||
* @param lastSatelliteTime 上一个点SNTP时间,精确值
|
||||
* @param curSatelliteTime 当前点SNTP时间,精确值
|
||||
* @return 动画运动时间
|
||||
*/
|
||||
public long computeAnimDuration(long lastSatelliteTime, long curSatelliteTime) {
|
||||
if (lastSatelliteTime == 0 || curSatelliteTime == 0) {
|
||||
return 45;
|
||||
}
|
||||
long interval = curSatelliteTime - lastSatelliteTime;
|
||||
if (interval < 45) {
|
||||
interval = 45;
|
||||
}
|
||||
return interval;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -112,21 +112,6 @@ public class MarkerDrawer {
|
||||
return marker;
|
||||
}
|
||||
|
||||
private boolean isNewVehicleType(Object object, IMogoMarker marker) {
|
||||
if (object instanceof MarkerOnlineCar
|
||||
&& marker != null
|
||||
&& marker.getObject() instanceof MarkerShowEntity
|
||||
&& ((MarkerShowEntity) marker.getObject()).getBindObj() instanceof MarkerOnlineCar) {
|
||||
try {
|
||||
return ((MarkerOnlineCar) object).getCarInfo().getVehicleType()
|
||||
!= ((MarkerOnlineCar) ((MarkerShowEntity) marker.getObject()).getBindObj()).getCarInfo().getVehicleType();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getPrimaryKeyFromEntity(Object entity) {
|
||||
if (entity instanceof MarkerExploreWay) {
|
||||
String id = ((MarkerExploreWay) entity).getInfoId();
|
||||
|
||||
@@ -4,34 +4,26 @@ import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_STOP_
|
||||
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_DATA;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.eagle.core.utilcode.util.ViewUtils;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.drawer.marker.IMarkerView;
|
||||
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
|
||||
|
||||
/**
|
||||
* 云端 预警数据绘制
|
||||
*/
|
||||
public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedListener {
|
||||
public class V2XWarnDataDrawer extends BaseDrawer {
|
||||
|
||||
private static final String TAG = "V2XWarnDataDrawer";
|
||||
private static volatile V2XWarnDataDrawer sInstance;
|
||||
|
||||
private V2XWarnDataDrawer() {
|
||||
super();
|
||||
MogoApisHandler.getInstance().getApis()
|
||||
.getStatusManagerApi()
|
||||
.registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, this);
|
||||
}
|
||||
|
||||
public static V2XWarnDataDrawer getInstance() {
|
||||
@@ -49,21 +41,8 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private boolean mIsVrMode = false;
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
|
||||
CallerLogger.INSTANCE.d(TAG, descriptor + " , "+ isTrue);
|
||||
}
|
||||
|
||||
public boolean isVrMode() {
|
||||
return mIsVrMode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 识别物移动
|
||||
*
|
||||
*/
|
||||
public void renderWarnData(double lon, double lat, int type, double collisionlat, double collisionLon, double angle, long showTime) {
|
||||
MarkerLocation location = new MarkerLocation();
|
||||
@@ -95,7 +74,6 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
public IMogoMarker drawMarker(MarkerShowEntity markerShowEntity, int modeResType) {
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.data(markerShowEntity)
|
||||
@@ -128,10 +106,8 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
|
||||
marker.setRotateAngle(rotate);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绘制停止线 marker
|
||||
*
|
||||
*/
|
||||
public void renderStopLineData(double lon, double lat) {
|
||||
MarkerLocation location = new MarkerLocation();
|
||||
@@ -162,5 +138,4 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
|
||||
return marker;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,16 +11,16 @@ import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.glide.GlideImageLoader;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.eagle.core.utilcode.util.ViewUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.WindowUtils;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.R;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.service.imageloader.IMogoImageLoaderListener;
|
||||
import com.mogo.service.imageloader.MogoImageView;
|
||||
import com.mogo.eagle.core.utilcode.mogo.imageloader.IMogoImageLoaderListener;
|
||||
import com.mogo.eagle.core.utilcode.mogo.imageloader.MogoImageView;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
@@ -93,7 +93,7 @@ public abstract class MapMarkerBaseView extends LinearLayout implements IMarkerV
|
||||
if (!url.isEmpty()) {
|
||||
ivIcon.setPlaceHolder(res);
|
||||
ivIcon.setFailureHolder(res);
|
||||
MogoApisHandler.getInstance().getApis().getImageLoaderApi().displayImage(url,
|
||||
GlideImageLoader.getInstance().displayImage(url,
|
||||
ivIcon, WindowUtils.dip2px(mContext, 50), WindowUtils.dip2px(mContext, 50),
|
||||
new IMogoImageLoaderListener() {
|
||||
@Override
|
||||
@@ -118,7 +118,7 @@ public abstract class MapMarkerBaseView extends LinearLayout implements IMarkerV
|
||||
|
||||
private void runOnUiThread(final MarkerShowEntity markerShowEntity) {
|
||||
if (!TextUtils.isEmpty(markerShowEntity.getIconUrl())) {
|
||||
MogoApisHandler.getInstance().getApis().getImageLoaderApi().displayImage(markerShowEntity.getIconUrl(),
|
||||
GlideImageLoader.getInstance().displayImage(markerShowEntity.getIconUrl(),
|
||||
ivUserHead,
|
||||
WindowUtils.dip2px(mContext, 50), WindowUtils.dip2px(mContext, 50),
|
||||
new IMogoImageLoaderListener() {
|
||||
|
||||
@@ -35,11 +35,6 @@ public class OnlineCarMarkerView implements IMarkerView {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView() {
|
||||
return null;
|
||||
@@ -72,20 +67,6 @@ public class OnlineCarMarkerView implements IMarkerView {
|
||||
return sRef.get( vehicleType ).get();
|
||||
}
|
||||
|
||||
public Bitmap getSelectedBitmap( int vehicleType ) {
|
||||
if ( sTypedRef.get( vehicleType ) == null || sTypedRef.get( vehicleType ).get() == null
|
||||
|| sTypedRef.get( vehicleType ).get().isRecycled() ) {
|
||||
switch ( vehicleType ) {
|
||||
case 2:
|
||||
sTypedRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_type2 ) ) );
|
||||
break;
|
||||
default:
|
||||
sTypedRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_gray_selected ) ) );
|
||||
}
|
||||
}
|
||||
return sTypedRef.get( vehicleType ).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarker( IMogoMarker marker ) {
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
package com.mogo.module.common.entity;
|
||||
|
||||
|
||||
/**
|
||||
* 新鲜事儿Marker数据
|
||||
*/
|
||||
@@ -8,9 +9,6 @@ public class MarkerNoveltyInfo {
|
||||
private String type;
|
||||
private String sn;
|
||||
private MarkerLocation location;
|
||||
/**
|
||||
* @see com.mogo.module.common.enums.EventTypeEnum
|
||||
*/
|
||||
private String poiType;
|
||||
private ContentData contentData;
|
||||
|
||||
|
||||
@@ -447,7 +447,7 @@ enum class EventTypeEnum(
|
||||
fun getPoiTypeBg(poiType: String, isVrMode: Boolean): Int {
|
||||
return when (poiType) {
|
||||
FOURS_BLOCK_UP.poiType, FOURS_LIVING.poiType-> if (isVrMode) R.drawable.bg_v2x_event_type_orange_vr else R.drawable.bg_v2x_event_type_orange
|
||||
TRAFFIC_CHECK.poiType, ROAD_CLOSED.poiType, FOURS_ROAD_WORK.poiType,AI_ROAD_WORK.poiType,
|
||||
TRAFFIC_CHECK.poiType, ROAD_CLOSED.poiType, FOURS_ROAD_WORK.poiType, AI_ROAD_WORK.poiType,
|
||||
FOURS_PONDING.poiType, FOURS_FOG.poiType, FOURS_ICE.poiType, FOURS_ACCIDENT.poiType,
|
||||
FOURS_ACCIDENT_01.poiType, FOURS_ACCIDENT_02.poiType, FOURS_ACCIDENT_03.poiType,
|
||||
FOURS_ACCIDENT_04.poiType, FOURS_ACCIDENT_05.poiType -> if (isVrMode) R.drawable.bg_v2x_event_type_red_vr else R.drawable.bg_v2x_event_type_read
|
||||
@@ -463,7 +463,7 @@ enum class EventTypeEnum(
|
||||
FOURS_BLOCK_UP.poiType, FOURS_LIVING.poiType ->
|
||||
R.drawable.bg_v2x_event_type_orange
|
||||
TRAFFIC_CHECK.poiType, ROAD_CLOSED.poiType,
|
||||
FOURS_ROAD_WORK.poiType,AI_ROAD_WORK.poiType, FOURS_PONDING.poiType,
|
||||
FOURS_ROAD_WORK.poiType, AI_ROAD_WORK.poiType, FOURS_PONDING.poiType,
|
||||
FOURS_FOG.poiType, FOURS_ICE.poiType,
|
||||
FOURS_ACCIDENT.poiType, FOURS_ACCIDENT_01.poiType,
|
||||
FOURS_ACCIDENT_02.poiType, FOURS_ACCIDENT_03.poiType,
|
||||
@@ -480,7 +480,7 @@ enum class EventTypeEnum(
|
||||
fun isRoadEvent(poiType: String?): Boolean {
|
||||
return when (poiType) {
|
||||
TRAFFIC_CHECK.poiType, ROAD_CLOSED.poiType,
|
||||
FOURS_ROAD_WORK.poiType,AI_ROAD_WORK.poiType, FOURS_BLOCK_UP.poiType,
|
||||
FOURS_ROAD_WORK.poiType, AI_ROAD_WORK.poiType, FOURS_BLOCK_UP.poiType,
|
||||
FOURS_PONDING.poiType, FOURS_FOG.poiType,
|
||||
FOURS_ICE.poiType, FOURS_ACCIDENT.poiType,
|
||||
FOURS_ACCIDENT_01.poiType, FOURS_ACCIDENT_02.poiType,
|
||||
@@ -496,7 +496,7 @@ enum class EventTypeEnum(
|
||||
@JvmStatic
|
||||
fun isNeedRoadEventUgc(poiType: String?): Boolean {
|
||||
return when (poiType) {
|
||||
ROAD_CLOSED.poiType, FOURS_ROAD_WORK.poiType,AI_ROAD_WORK.poiType,
|
||||
ROAD_CLOSED.poiType, FOURS_ROAD_WORK.poiType, AI_ROAD_WORK.poiType,
|
||||
FOURS_BLOCK_UP.poiType, FOURS_ACCIDENT.poiType,
|
||||
FOURS_ACCIDENT_01.poiType, FOURS_ACCIDENT_02.poiType,
|
||||
FOURS_ACCIDENT_03.poiType, FOURS_ACCIDENT_04.poiType,
|
||||
|
||||
Reference in New Issue
Block a user