将地图打点业务下沉到公共业务模块
This commit is contained in:
@@ -10,6 +10,7 @@ import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.carchattingprovider.ICarsChattingProvider;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.drawer.MarkerDrawer;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.gps.simulator.IMogoGpsSimulatorManager;
|
||||
@@ -193,7 +194,7 @@ public class MarkerServiceHandler {
|
||||
*/
|
||||
@Deprecated
|
||||
public static IMogoMarker drawMapMarker( MarkerShowEntity markerShowEntity ) {
|
||||
return getMapMarkerManager().drawMapMarker( markerShowEntity, ServiceConst.MARKER_Z_INDEX_HIGH );
|
||||
return getMapMarkerManager().drawMapMarker( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -112,10 +112,6 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final int MSG_LOCK_CAR = 0x202;
|
||||
|
||||
public static final int MARKER_Z_INDEX_HIGH = 100;
|
||||
public static final int MARKER_Z_INDEX_LOW = 2;
|
||||
|
||||
|
||||
/**
|
||||
* 切换卡片内容-上一个
|
||||
*/
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-15
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface IMarkerView {
|
||||
|
||||
View getView();
|
||||
|
||||
default Bitmap getBitmap(int type){
|
||||
return null;
|
||||
}
|
||||
|
||||
void setMarker( IMogoMarker marker );
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.service.R;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-01-1015:55
|
||||
* desc : 地图Marker的适配器
|
||||
* version: 1.0
|
||||
*/
|
||||
public class MapMarkerAdapter {
|
||||
|
||||
/**
|
||||
* 获取 MarkerShowEntity 填充好的 MarkerView
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param markerShowEntity 要填充的数据
|
||||
* @return MarkerView
|
||||
*/
|
||||
public static IMarkerView getMarkerView(Context context, MarkerShowEntity markerShowEntity, MogoMarkerOptions options) {
|
||||
|
||||
if ( TextUtils.equals( markerShowEntity.getMarkerType(), ModuleNames.CARD_TYPE_USER_DATA ) ) {
|
||||
return OnlineCarMarkerView.getInstance();
|
||||
} else {
|
||||
if (markerShowEntity.isChecked()) {
|
||||
return new MapMarkerInfoView(context, markerShowEntity, options);
|
||||
} else {
|
||||
return new MapMarkerView(context, markerShowEntity, options);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.service.imageloader.IMogoImageLoaderListener;
|
||||
import com.mogo.service.imageloader.MogoImageView;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-01-1310:55
|
||||
* desc : 地图上抽离的Marker的共性
|
||||
* version: 1.0
|
||||
*/
|
||||
public abstract class MapMarkerBaseView extends LinearLayout implements IMarkerView {
|
||||
private String TAG = "MapMarkerBaseView";
|
||||
|
||||
protected Context mContext;
|
||||
protected MogoMarkerOptions mOptions;
|
||||
protected MogoImageView ivUserHead;
|
||||
protected ImageView ivIcon;
|
||||
protected ImageView ivCar;
|
||||
protected IMogoMarker mMarker;
|
||||
|
||||
public MapMarkerBaseView(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public MapMarkerBaseView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mContext = context;
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public MapMarkerBaseView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
mContext = context;
|
||||
initView(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarker( IMogoMarker marker ) {
|
||||
this.mMarker = marker;
|
||||
}
|
||||
|
||||
protected abstract void initView( Context context);
|
||||
|
||||
public abstract void updateView(MarkerShowEntity markerShowEntity);
|
||||
|
||||
protected void loadImageWithMarker(final MarkerShowEntity markerShowEntity) {
|
||||
|
||||
if ( Looper.myLooper() != Looper.getMainLooper() ) {
|
||||
UiThreadHandler.post( ()-> {
|
||||
runOnUiThread( markerShowEntity );
|
||||
});
|
||||
} else {
|
||||
runOnUiThread( markerShowEntity );
|
||||
}
|
||||
}
|
||||
|
||||
private void runOnUiThread(final MarkerShowEntity markerShowEntity){
|
||||
if (!TextUtils.isEmpty(markerShowEntity.getIconUrl())) {
|
||||
MarkerServiceHandler.getImageloader().displayImage(markerShowEntity.getIconUrl(),
|
||||
ivUserHead,
|
||||
WindowUtils.dip2px(mContext, 50), WindowUtils.dip2px(mContext, 50),
|
||||
new IMogoImageLoaderListener() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompleted(Bitmap bitmap) {
|
||||
Logger.d(TAG, "loadImageWithMarker loaded.");
|
||||
// 使用view渲染地图marker,刷新纹理的时候,需要重新用view生成纹理,然后在设置
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setIcon( fromView( MapMarkerBaseView.this ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
Logger.e(TAG, "loadImageWithMarker onFailure.");
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
ivUserHead.setBackgroundResource(R.drawable.icon_default_user_head);
|
||||
}
|
||||
}
|
||||
|
||||
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 ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerPoiTypeEnum;
|
||||
import com.mogo.module.common.entity.MarkerShareMusic;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-01-0619:55
|
||||
* desc : 地图Marker图标带文本信息
|
||||
* version: 1.0
|
||||
*/
|
||||
public class MapMarkerInfoView extends MapMarkerBaseView {
|
||||
private String TAG = "MapMarkerInfoView";
|
||||
|
||||
private TextView tvMarkerContent;
|
||||
private ConstraintLayout clMarkerContent;
|
||||
private ImageView ivReverseTriangle;
|
||||
|
||||
public MapMarkerInfoView( Context context ) {
|
||||
super( context );
|
||||
}
|
||||
|
||||
public MapMarkerInfoView( Context context, @Nullable AttributeSet attrs ) {
|
||||
super( context, attrs );
|
||||
}
|
||||
|
||||
public MapMarkerInfoView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
}
|
||||
|
||||
public MapMarkerInfoView( Context context, MarkerShowEntity markerShowEntity, MogoMarkerOptions options ) {
|
||||
super( context );
|
||||
mOptions = options;
|
||||
updateView( markerShowEntity );
|
||||
}
|
||||
|
||||
protected void initView( Context context ) {
|
||||
LayoutInflater.from( context ).inflate( R.layout.modudle_services_marker_layout_info, this );
|
||||
ivUserHead = findViewById( R.id.ivUserHead );
|
||||
ivIcon = findViewById( R.id.ivIcon );
|
||||
clMarkerContent = findViewById( R.id.clMarkerContent );
|
||||
ivReverseTriangle = findViewById( R.id.ivReverseTriangle );
|
||||
ivCar = findViewById( R.id.ivCar );
|
||||
tvMarkerContent = findViewById( R.id.tvMarkerContent );
|
||||
}
|
||||
|
||||
public void updateView( MarkerShowEntity markerShowEntity ) {
|
||||
try {
|
||||
|
||||
Object bindObj = markerShowEntity.getBindObj();
|
||||
|
||||
ivCar.setImageResource( R.drawable.icon_map_marker_location_yellow );
|
||||
clMarkerContent.setBackgroundResource( R.drawable.bg_map_marker_yellow_info );
|
||||
ivReverseTriangle.setImageResource( R.drawable.bg_shape_reverse_yellow );
|
||||
switch ( markerShowEntity.getMarkerType() ) {
|
||||
case ServiceConst.CARD_TYPE_CARS_CHATTING:
|
||||
case ServiceConst.CARD_TYPE_USER_DATA:
|
||||
ivUserHead.setVisibility( View.VISIBLE );
|
||||
ivIcon.setVisibility( View.INVISIBLE );
|
||||
loadImageWithMarker( markerShowEntity );
|
||||
ivCar.setImageResource( R.drawable.icon_map_marker_car_gray );
|
||||
//ivCar.setRotation(new Random().nextInt(360));
|
||||
ivCar.setRotation( ( float ) markerShowEntity.getMarkerLocation().getAngle() );
|
||||
break;
|
||||
case ServiceConst.CARD_TYPE_ROAD_CONDITION:
|
||||
case ServiceConst.CARD_TYPE_NOVELTY:
|
||||
ivUserHead.setVisibility( View.INVISIBLE );
|
||||
ivIcon.setVisibility( View.VISIBLE );
|
||||
|
||||
if ( bindObj instanceof MarkerExploreWay && ( ( MarkerExploreWay ) bindObj ).getPoiType() != null ) {
|
||||
switch ( ( ( MarkerExploreWay ) bindObj ).getPoiType() ) {
|
||||
case MarkerPoiTypeEnum.GAS_STATION:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_refuel );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.TRAFFIC_CHECK:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_check2_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.ROAD_CLOSED:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_block_off2_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.SHOP_DISCOUNT:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_shop_discount );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_4S:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_4s );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_ROAD_WORK:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_work2_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_BLOCK_UP:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_block_up2_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_PONDING:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_pondingl2_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_SHOP_FREE:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_shop );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_FOG:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_dark_frog2_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_ICE:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_freeze2_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_PARKING:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_parking2 );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_ACCIDENT:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_accident3_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_NEALY:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_shear_news );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_LIVING:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_living_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.ILLEGAL_PARK_LIVING:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_illegal_park_white );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.ROAD_SLIPPERY:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_road_slippery_light );
|
||||
break;
|
||||
default:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_block_up2_white );
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ServiceConst.CARD_TYPE_SHARE_MUSIC:
|
||||
ivUserHead.setVisibility( View.INVISIBLE );
|
||||
ivIcon.setVisibility( View.VISIBLE );
|
||||
|
||||
if ( bindObj instanceof MarkerShareMusic ) {
|
||||
// 2 为书籍听书,3 为新闻,1 为qq音乐,int
|
||||
switch ( ( ( MarkerShareMusic ) bindObj ).getShareType() ) {
|
||||
case 1:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_misic );
|
||||
break;
|
||||
case 2:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_book );
|
||||
break;
|
||||
case 3:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_news );
|
||||
break;
|
||||
default:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_misic );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
if ( !TextUtils.isEmpty( markerShowEntity.getTextContent() ) ) {
|
||||
String content;
|
||||
if ( markerShowEntity.getTextContent().length() > 8 ) {
|
||||
content = markerShowEntity.getTextContent().substring( 0, 7 ) + "...";
|
||||
} else {
|
||||
content = markerShowEntity.getTextContent();
|
||||
}
|
||||
tvMarkerContent.setText( content );
|
||||
}
|
||||
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package com.mogo.module.service.marker;
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.text.TextUtils;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
@@ -11,27 +10,26 @@ import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.marker.anim.OnMarkerAnimationListener;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.api.CallChatApi;
|
||||
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
|
||||
import com.mogo.module.common.drawer.MarkerDrawer;
|
||||
import com.mogo.module.common.drawer.OnlineCarDrawer;
|
||||
import com.mogo.module.common.drawer.RoadConditionDrawer;
|
||||
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
|
||||
import com.mogo.module.common.entity.MarkerCarPois;
|
||||
import com.mogo.module.common.drawer.marker.IMarkerView;
|
||||
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
|
||||
import com.mogo.module.common.drawer.marker.OnlineCarMarkerView;
|
||||
import com.mogo.module.common.entity.MarkerCardResult;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
import com.mogo.module.common.entity.MarkerNoveltyInfo;
|
||||
import com.mogo.module.common.entity.MarkerOnlineCar;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.common.entity.MarkerShareMusic;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.common.entity.MogoSnapshotSetData;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.service.Utils;
|
||||
import com.mogo.module.service.network.RefreshCallback;
|
||||
import com.mogo.module.service.network.RefreshModel;
|
||||
import com.mogo.module.service.utils.ViewUtils;
|
||||
@@ -44,7 +42,6 @@ import com.mogo.service.module.IMogoBizActionDoneListener;
|
||||
import com.mogo.utils.ResourcesHelper;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONArray;
|
||||
@@ -195,7 +192,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
Map< String, Object > properties = new HashMap<>();
|
||||
|
||||
if ( marker.getObject() instanceof MarkerShowEntity ) {
|
||||
final String sn = getCarSnFromMarker( marker );
|
||||
final String sn = MarkerDrawer.getInstance().getCarSnFromMarker( marker );
|
||||
if ( TextUtils.isEmpty( sn ) ) {
|
||||
return false;
|
||||
}
|
||||
@@ -375,260 +372,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
*/
|
||||
private void drawAllMarker( MarkerCardResult markerCardResult ) {
|
||||
List< MarkerExploreWay > exploreWayList = markerCardResult.getExploreWay();
|
||||
drawRoadConditionMarker( exploreWayList, ServiceConst.MAX_AMOUNT_ALL );
|
||||
RoadConditionDrawer.getInstance().drawRoadConditionMarker( exploreWayList, ServiceConst.MAX_AMOUNT_ALL, this );
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制在线车辆marker
|
||||
*
|
||||
* @param onlineCarList
|
||||
*/
|
||||
private void drawOnlineCarMarkers( List< MarkerOnlineCar > onlineCarList,
|
||||
int maxAmount,
|
||||
boolean clearOld,
|
||||
boolean showBounds,
|
||||
Rect bound,
|
||||
MogoLatLng centerPoint ) {
|
||||
// 将数据同步给在线车辆,避免每次 perform 的时候去拉取,造成消耗
|
||||
if ( onlineCarList == null || onlineCarList.isEmpty() ) {
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_USER_DATA );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( clearOld ) {
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_USER_DATA );
|
||||
}
|
||||
|
||||
int size = getAppropriateSize( maxAmount, onlineCarList );
|
||||
|
||||
Map< String, IMogoMarker > existCarMap = purgeMarkerData( onlineCarList, ModuleNames.CARD_TYPE_USER_DATA );
|
||||
|
||||
List< MogoLatLng > carPoints = new ArrayList<>();
|
||||
for ( int i = 0; i < size; i++ ) {
|
||||
MarkerOnlineCar markerOnlineCar = onlineCarList.get( i );
|
||||
MarkerLocation markerLocation = markerOnlineCar.getLocation();
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setBindObj( markerOnlineCar );
|
||||
markerShowEntity.setMarkerLocation( markerLocation );
|
||||
markerShowEntity.setMarkerType( markerOnlineCar.getType() );
|
||||
|
||||
if ( markerOnlineCar.getCarInfo() != null ) {
|
||||
markerShowEntity.setTextContent( markerOnlineCar.getUserInfo().getUserName() );
|
||||
markerShowEntity.setIconUrl( markerOnlineCar.getUserInfo().getUserHead() );
|
||||
}
|
||||
|
||||
if ( i <= 5 ) {
|
||||
carPoints.add( new MogoLatLng( markerLocation.getLat(), markerLocation.getLon() ) );
|
||||
}
|
||||
|
||||
String sn = getPrimaryKeyFromEntity( markerOnlineCar );
|
||||
IMogoMarker mogoMarker = existCarMap.get( sn );
|
||||
if ( mogoMarker == null || mogoMarker.isDestroyed() ) {
|
||||
mogoMarker = drawMapMarker( markerShowEntity, ServiceConst.MARKER_Z_INDEX_LOW );
|
||||
}
|
||||
if ( mogoMarker != null ) {
|
||||
mogoMarker.setVisible( true );
|
||||
}
|
||||
startSmooth( mogoMarker, markerOnlineCar, markerLocation );
|
||||
}
|
||||
|
||||
if ( showBounds && bound != null ) {
|
||||
// 将前6个点显示在固定范围内
|
||||
MarkerServiceHandler.getMapUIController().showBounds( TAG, centerPoint, carPoints, bound, false );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 探路数据
|
||||
*
|
||||
* @param exploreWayList
|
||||
*/
|
||||
private void drawRoadConditionMarker( List< MarkerExploreWay > exploreWayList, int maxAmount ) {
|
||||
// 将数据同步给探路,避免探路每次 perform 的时候去拉取,造成消耗
|
||||
if ( exploreWayList == null || exploreWayList.isEmpty() ) {
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_ROAD_CONDITION );
|
||||
return;
|
||||
}
|
||||
int size = getAppropriateSize( maxAmount, exploreWayList );
|
||||
Map< String, IMogoMarker > existCarMap = purgeMarkerData( exploreWayList, ModuleNames.CARD_TYPE_ROAD_CONDITION );
|
||||
Logger.i( TAG, "existCarMap: size = %d", existCarMap.size() );
|
||||
for ( int i = 0; i < size; i++ ) {
|
||||
MarkerExploreWay markerExploreWay = exploreWayList.get( i );
|
||||
if ( !markerExploreWay.getCanLive() ) {
|
||||
MarkerLocation markerLocation = markerExploreWay.getLocation();
|
||||
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setBindObj( markerExploreWay );
|
||||
markerShowEntity.setMarkerLocation( markerLocation );
|
||||
markerShowEntity.setMarkerType( markerExploreWay.getType() );
|
||||
markerShowEntity.setTextContent( markerExploreWay.getAddr() );
|
||||
|
||||
String sn = getPrimaryKeyFromEntity( markerExploreWay );
|
||||
IMogoMarker mogoMarker = existCarMap.get( sn );
|
||||
if ( mogoMarker == null || mogoMarker.isDestroyed() ) {
|
||||
Logger.d( TAG, "draw road condition, sn = %s", sn );
|
||||
try {
|
||||
if ( DebugConfig.isRoadEventAnimated() ) {
|
||||
post2AddAndStartAnimation( markerShowEntity, i * 100L );
|
||||
} else {
|
||||
mogoMarker = drawMapMarker( markerShowEntity, ServiceConst.MARKER_Z_INDEX_HIGH );
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void post2AddAndStartAnimation( MarkerShowEntity entity, long delay ) {
|
||||
if ( entity == null ) {
|
||||
return;
|
||||
}
|
||||
WorkThreadHandler.getInstance().postDelayed( () -> {
|
||||
if ( entity == null ) {
|
||||
return;
|
||||
}
|
||||
IMogoMarker marker = drawMapMarker( entity, ServiceConst.MARKER_Z_INDEX_HIGH );
|
||||
if ( marker == null ) {
|
||||
return;
|
||||
}
|
||||
marker.startScaleAnimationWithAlpha( 0, 1.2f, 0, 1.2f, 0f, 1f, 300, new LinearInterpolator(), new OnMarkerAnimationListener() {
|
||||
@Override
|
||||
public void onAnimStart() {
|
||||
Logger.d( TAG, " onAnimStart ---1----> " );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimEnd() {
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
marker.startScaleAnimation( 1.2f, 1, 1.2f, 1, 100, new LinearInterpolator(), null );
|
||||
}
|
||||
} );
|
||||
}, delay );
|
||||
}
|
||||
|
||||
/**
|
||||
* S = (A ∩ B) ∪ B
|
||||
* (A ∩ B)作为旧列表需要保留的部分
|
||||
*
|
||||
* @param newList
|
||||
* @return
|
||||
*/
|
||||
private Map< String, IMogoMarker > purgeMarkerData( List newList, String markerType ) {
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
Map< String, IMogoMarker > existMap = new HashMap<>();
|
||||
List< IMogoMarker > allCarsList = MarkerServiceHandler.getMarkerManager().getMarkers( markerType );
|
||||
if ( allCarsList == null || allCarsList.isEmpty() ) {
|
||||
return existMap;
|
||||
}
|
||||
if ( newList == null || newList.isEmpty() ) {
|
||||
return existMap;
|
||||
}
|
||||
|
||||
Map< String, IMogoMarker > allMap = new HashMap<>();
|
||||
for ( IMogoMarker marker : allCarsList ) {
|
||||
String sn = getPrimaryKeyFromMarker( marker );
|
||||
allMap.put( sn, marker );
|
||||
}
|
||||
for ( Object entity : newList ) {
|
||||
String sn = getPrimaryKeyFromEntity( entity );
|
||||
if ( allMap.containsKey( sn ) ) {
|
||||
if ( !isNewVehicleType( entity, allMap.get( sn ) ) ) {
|
||||
existMap.put( sn, allMap.get( sn ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( String sn : allMap.keySet() ) {
|
||||
if ( !existMap.containsKey( sn ) ) {
|
||||
IMogoMarker dirtyMarker = allMap.get( sn );
|
||||
allCarsList.remove( dirtyMarker );
|
||||
dirtyMarker.destroy();
|
||||
}
|
||||
}
|
||||
allMap.clear();
|
||||
Logger.i( "timer", "purge data cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
return existMap;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private String getPrimaryKeyFromEntity( Object entity ) {
|
||||
if ( entity instanceof MarkerExploreWay ) {
|
||||
String id = ( ( MarkerExploreWay ) entity ).getInfoId();
|
||||
if ( !TextUtils.isEmpty( id ) ) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
return getCarSnFromEntity( entity );
|
||||
}
|
||||
|
||||
private String getPrimaryKeyFromMarker( IMogoMarker marker ) {
|
||||
if ( marker == null || marker.getObject() == null || marker.isDestroyed() ) {
|
||||
return null;
|
||||
}
|
||||
if ( !( marker.getObject() instanceof MarkerShowEntity ) ) {
|
||||
return null;
|
||||
}
|
||||
return getPrimaryKeyFromEntity( ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() );
|
||||
}
|
||||
|
||||
private String getCarSnFromEntity( Object entity ) {
|
||||
try {
|
||||
if ( entity instanceof MarkerOnlineCar ) {
|
||||
return ( ( MarkerOnlineCar ) entity ).getUserInfo().getSn();
|
||||
} else if ( entity instanceof MarkerShareMusic ) {
|
||||
return ( ( MarkerShareMusic ) entity ).getUserInfo().getSn();
|
||||
} else if ( entity instanceof MarkerNoveltyInfo ) {
|
||||
return ( ( MarkerNoveltyInfo ) entity ).getSn();
|
||||
} else if ( entity instanceof MarkerExploreWay ) {
|
||||
return ( ( MarkerExploreWay ) entity ).getUserInfo().getSn();
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getCarSnFromMarker( IMogoMarker marker ) {
|
||||
if ( marker == null || marker.getObject() == null || marker.isDestroyed() ) {
|
||||
return null;
|
||||
}
|
||||
if ( !( marker.getObject() instanceof MarkerShowEntity ) ) {
|
||||
return null;
|
||||
}
|
||||
return getCarSnFromEntity( ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxAmount 展示的最大数量
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
private int getAppropriateSize( int maxAmount, List list ) {
|
||||
if ( list == null ) {
|
||||
return 0;
|
||||
}
|
||||
return Math.min( maxAmount, list.size() );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 统计地图内数据获取
|
||||
*
|
||||
@@ -714,37 +460,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 大而全数据计数埋点
|
||||
*/
|
||||
private synchronized static JSONObject fillPoiTypeTrackBody( JSONArray arr, String poiType, int poiTypeNum ) {
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
object.put( "poitype", poiType );
|
||||
object.put( "num", poiTypeNum );
|
||||
if ( arr != null ) {
|
||||
arr.put( object );
|
||||
}
|
||||
return object;
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private synchronized static void fillPoiChildTypeTrackBody( JSONArray arr, String childType, int childTypeNum ) {
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
object.put( "contenttype", childType );
|
||||
object.put( "num", childTypeNum );
|
||||
if ( arr != null ) {
|
||||
arr.put( object );
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制Marker,这里绘制的会使用markerShowEntities队列进行维护
|
||||
*
|
||||
@@ -753,39 +468,13 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
*/
|
||||
public synchronized IMogoMarker drawMapMarker( MarkerShowEntity markerShowEntity, int zIndex ) {
|
||||
try {
|
||||
return drawMapMarkerImpl( markerShowEntity, zIndex );
|
||||
return MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, zIndex, this );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "drawMapMarker" );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, int zIndex ) {
|
||||
if ( markerShowEntity == null || markerShowEntity.getMarkerLocation() == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoMarkerOptions options = new MogoMarkerOptions().owner( markerShowEntity.getMarkerType() ).zIndex( zIndex ).object( markerShowEntity ).latitude( markerShowEntity.getMarkerLocation().getLat() ).longitude( markerShowEntity.getMarkerLocation().getLon() );
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView( mContext, markerShowEntity, options );
|
||||
if ( markerView instanceof OnlineCarMarkerView ) {
|
||||
try {
|
||||
options.icon( markerView.getBitmap( ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getCarInfo().getVehicleType() ) );
|
||||
} catch ( Exception e ) {
|
||||
options.icon( markerView.getBitmap( 0 ) );
|
||||
}
|
||||
options.anchor( 0.5f, 0.5f );
|
||||
} else {
|
||||
options.icon( markerView.getView() );
|
||||
}
|
||||
|
||||
IMogoMarker marker = MarkerServiceHandler.getMarkerManager().addMarker( markerShowEntity.getMarkerType(), options );
|
||||
marker.setOwner( markerShowEntity.getMarkerType() );
|
||||
markerView.setMarker( marker );
|
||||
marker.setOnMarkerClickListener( this );
|
||||
markerShowEntity.setMarker( marker );
|
||||
return marker;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class< MarkerResponse > target() {
|
||||
return MarkerResponse.class;
|
||||
@@ -919,7 +608,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
runOnTargetThread( () -> {
|
||||
Logger.d( TAG, "内部 - 请求完毕开始处理" );
|
||||
trackData( size );
|
||||
drawOnlineCarMarkers( onlineCarList, Integer.MAX_VALUE, fitBounds, fitBounds, mMarkerDisplayBounds, latLng );
|
||||
OnlineCarDrawer.getInstance().drawOnlineCarMarkers( onlineCarList, Integer.MAX_VALUE, fitBounds, fitBounds, mMarkerDisplayBounds, latLng, MapMarkerManager.this );
|
||||
UiThreadHandler.postDelayed( runnable, SMOOTH_DURATION * 1000 );
|
||||
} );
|
||||
}
|
||||
@@ -958,77 +647,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_USER_DATA );
|
||||
}
|
||||
|
||||
// 平滑移动
|
||||
private void startSmooth( IMogoMarker iMogoMarker, MarkerOnlineCar markerOnlineCar,
|
||||
MarkerLocation markerLocation ) {
|
||||
if ( iMogoMarker == null ) {
|
||||
return;
|
||||
}
|
||||
List< MarkerCarPois > poiList = markerOnlineCar.getPois();
|
||||
if ( filterErrorPoint( poiList ) ) {
|
||||
return;
|
||||
}
|
||||
if ( poiList == null || poiList.size() < 2 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
List< MogoLatLng > points = new ArrayList<>();
|
||||
|
||||
double lastLat = 0.0d;
|
||||
double lastLon = 0.0d;
|
||||
|
||||
for ( int j = 0; j < poiList.size(); j++ ) {
|
||||
MarkerCarPois poi = poiList.get( j );
|
||||
if ( poi == null || poi.getCoordinates() == null && poi.getCoordinates().size() != 2 ) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
double lat = Double.valueOf( poi.getCoordinates().get( 1 ) + "" );
|
||||
double lng = Double.valueOf( poi.getCoordinates().get( 0 ) + "" );
|
||||
|
||||
float distance = Utils.calculateLineDistance( lastLon, lastLat, lng, lat );
|
||||
lastLon = lng;
|
||||
lastLat = lat;
|
||||
if ( distance < 0.2f ) {// 距离过短,认为静止不动
|
||||
continue;
|
||||
}
|
||||
|
||||
points.add( new MogoLatLng( lat, lng ) );
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
}
|
||||
if ( points.size() >= 1 ) {
|
||||
iMogoMarker.startSmooth( points, SMOOTH_DURATION );
|
||||
} else {
|
||||
Logger.d( TAG, "静止小车,但是有相同的连续坐标" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 有可能出现终点到起点跳跃的情况,需要用"500M"约束起点和终点
|
||||
*
|
||||
* @param poiList
|
||||
*/
|
||||
private boolean filterErrorPoint( List< MarkerCarPois > poiList ) {
|
||||
if ( poiList == null || poiList.size() < 2 ) {
|
||||
return false;
|
||||
}
|
||||
MarkerCarPois start = poiList.get( 0 );
|
||||
MarkerCarPois end = poiList.get( poiList.size() - 1 );
|
||||
|
||||
try {
|
||||
double lat1 = Double.valueOf( start.getCoordinates().get( 1 ) + "" );
|
||||
double lng1 = Double.valueOf( start.getCoordinates().get( 0 ) + "" );
|
||||
double lat2 = Double.valueOf( end.getCoordinates().get( 1 ) + "" );
|
||||
double lng2 = Double.valueOf( end.getCoordinates().get( 0 ) + "" );
|
||||
if ( Utils.calculateLineDistance( new MogoLatLng( lat1, lng1 ), new MogoLatLng( lat2, lng2 ) ) >= 500 ) {
|
||||
Logger.d( TAG, "filter point" );
|
||||
return true;
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean ignoreDrawRequest() {
|
||||
return MarkerServiceHandler.getMogoStatusManager().isSearchUIShow()
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerPoiTypeEnum;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-01-0619:55
|
||||
* desc : 地图Marker图标
|
||||
* version: 1.0
|
||||
*/
|
||||
public class MapMarkerView extends MapMarkerBaseView {
|
||||
private String TAG = "MapMarkerView";
|
||||
|
||||
public MapMarkerView( Context context ) {
|
||||
super( context );
|
||||
}
|
||||
|
||||
public MapMarkerView( Context context, @Nullable AttributeSet attrs ) {
|
||||
super( context, attrs );
|
||||
}
|
||||
|
||||
public MapMarkerView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
}
|
||||
|
||||
public MapMarkerView( Context context, MarkerShowEntity markerShowEntity, MogoMarkerOptions options ) {
|
||||
super( context );
|
||||
mOptions = options;
|
||||
updateView( markerShowEntity );
|
||||
}
|
||||
|
||||
protected void initView( Context context ) {
|
||||
LayoutInflater.from( context ).inflate( R.layout.modudle_services_marker_layout, this );
|
||||
ivIcon = findViewById( R.id.ivIcon );
|
||||
ivCar = findViewById( R.id.ivCar );
|
||||
}
|
||||
|
||||
public void updateView( MarkerShowEntity markerShowEntity ) {
|
||||
try {
|
||||
Object bindObj = markerShowEntity.getBindObj();
|
||||
if ( MogoApisHandler.getInstance().getApis().getMapFrameControllerApi().isVrMode() ) {
|
||||
}
|
||||
switch ( markerShowEntity.getMarkerType() ) {
|
||||
case ServiceConst.CARD_TYPE_ROAD_CONDITION:
|
||||
case ServiceConst.CARD_TYPE_NOVELTY:
|
||||
if ( bindObj instanceof MarkerExploreWay && ( ( MarkerExploreWay ) bindObj ).getPoiType() != null ) {
|
||||
switch ( ( ( MarkerExploreWay ) bindObj ).getPoiType() ) {
|
||||
case MarkerPoiTypeEnum.GAS_STATION:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_refuel );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.TRAFFIC_CHECK:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_check2 );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.ROAD_CLOSED:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_block_off2 );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.SHOP_DISCOUNT:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_shop_discount );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_4S:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_4s );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_ROAD_WORK:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_work2 );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_BLOCK_UP:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_block_up2 );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_PONDING:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_pondingl2 );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_SHOP_FREE:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_shop );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_FOG:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_dark_frog2 );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_ICE:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_freeze2 );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_ACCIDENT:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_accident3 );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_NEALY:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_shear_news );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_LIVING:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_living );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.ILLEGAL_PARK_LIVING:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_illegal_park );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.ROAD_SLIPPERY:
|
||||
ivIcon.setImageResource( R.drawable.module_service_ic_rc_road_slippery );
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_PARKING:
|
||||
default:
|
||||
ivIcon.setImageResource( R.drawable.icon_map_marker_road_block_up2 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.module.common.drawer.MarkerDrawer;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
@@ -28,7 +29,7 @@ public class MogoMarkerServiceImpl implements IMogoMarkerService {
|
||||
@Override
|
||||
public IMogoMarker drawMarker( Object object ) {
|
||||
if ( object instanceof MarkerShowEntity ) {
|
||||
return MarkerServiceHandler.getMapMarkerManager().drawMapMarker( ( ( MarkerShowEntity ) object ), ServiceConst.MARKER_Z_INDEX_HIGH );
|
||||
return MarkerServiceHandler.getMapMarkerManager().drawMapMarker( ( ( MarkerShowEntity ) object ), MarkerDrawer.MARKER_Z_INDEX_HIGH );
|
||||
}
|
||||
Logger.w( TAG, "object must instance of [com.mogo.module.common.entity.MarkerShowEntity]" );
|
||||
return null;
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.service.R;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-30
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class OnlineCarMarkerView implements IMarkerView {
|
||||
|
||||
private static Map< Integer, SoftReference< Bitmap > > sRef = new HashMap<>();
|
||||
private static Map< Integer, SoftReference< Bitmap > > sTypedRef = new HashMap<>();
|
||||
|
||||
private OnlineCarMarkerView() {
|
||||
// private constructor
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
private static final OnlineCarMarkerView INSTANCE = new OnlineCarMarkerView();
|
||||
}
|
||||
|
||||
public static OnlineCarMarkerView getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap getBitmap( int vehicleType ) {
|
||||
if ( sRef.get( vehicleType ) == null || sRef.get( vehicleType ).get() == null
|
||||
|| sRef.get( vehicleType ).get().isRecycled() ) {
|
||||
switch ( vehicleType ) {
|
||||
case 5:
|
||||
sRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_type_taxi ) ) );
|
||||
break;
|
||||
case 6:
|
||||
sRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_type_bus ) ) );
|
||||
break;
|
||||
case 1:
|
||||
sRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_type_110 ) ) );
|
||||
break;
|
||||
case 2:
|
||||
sRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_type_120 ) ) );
|
||||
break;
|
||||
case 7:
|
||||
sRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_type_119 ) ) );
|
||||
break;
|
||||
default:
|
||||
sRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_gray ) ) );
|
||||
}
|
||||
}
|
||||
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,225 +0,0 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.map.marker.IMogoInfoWindowAdapter;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
import com.mogo.module.common.entity.MarkerOnlineCar;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.common.entity.MarkerUserInfo;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.network.RefreshApiService;
|
||||
import com.mogo.module.service.network.RefreshModel;
|
||||
import com.mogo.module.service.network.bean.DemoUserInfoEntity;
|
||||
import com.mogo.service.imageloader.MogoImageView;
|
||||
import com.mogo.service.network.IMogoNetwork;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
import com.zhidao.carchattingprovider.CallChattingProviderConstant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-27
|
||||
* <p>
|
||||
* 在线车辆点击后弹出的info window 样式
|
||||
*/
|
||||
public class UserDataMarkerInfoWindowAdapter implements IMogoInfoWindowAdapter {
|
||||
|
||||
private static final String TAG = "UserDataMarkerInfoWindowAdapter";
|
||||
|
||||
private static volatile UserDataMarkerInfoWindowAdapter sInstance;
|
||||
private final Context mContext;
|
||||
private static RefreshApiService sRefreshApiService;
|
||||
|
||||
private View mInfoWindowView = null;
|
||||
|
||||
private View mContentContainer;
|
||||
private MogoImageView mUserHeader;
|
||||
private TextView mContent;
|
||||
private TextView mTag;
|
||||
private ImageView mCall;
|
||||
|
||||
private UserDataMarkerInfoWindowAdapter( Context context ) {
|
||||
this.mContext = context;
|
||||
IMogoNetwork network = MarkerServiceHandler.getApis().getNetworkApi();
|
||||
sRefreshApiService = network.create( RefreshApiService.class, RefreshModel.getNetHost() );
|
||||
}
|
||||
|
||||
public static UserDataMarkerInfoWindowAdapter getInstance( Context context ) {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( UserDataMarkerInfoWindowAdapter.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new UserDataMarkerInfoWindowAdapter( context );
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getInfoWindow( IMogoMarker marker ) {
|
||||
return inflateView( marker );
|
||||
}
|
||||
|
||||
private View inflateView( IMogoMarker marker ) {
|
||||
if ( marker == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( mInfoWindowView == null ) {
|
||||
mInfoWindowView = LayoutInflater.from( mContext ).inflate( R.layout.modudle_services_marker_info_window_layout, null );
|
||||
mContentContainer = mInfoWindowView.findViewById( R.id.module_service_id_marker_content );
|
||||
mUserHeader = mInfoWindowView.findViewById( R.id.module_service_id_user_header );
|
||||
mContent = mInfoWindowView.findViewById( R.id.module_service_id_content );
|
||||
mTag = mInfoWindowView.findViewById( R.id.module_service_id_tag );
|
||||
mCall = mInfoWindowView.findViewById( R.id.module_service_id_call );
|
||||
}
|
||||
|
||||
if ( DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_BYD ) {
|
||||
mContentContainer.setPadding(
|
||||
mContentContainer.getPaddingLeft(),
|
||||
mContentContainer.getPaddingTop(),
|
||||
mContentContainer.getResources().getDimensionPixelSize( R.dimen.module_service_id_marker_content_paddingRight_widthoutCall ),
|
||||
mContentContainer.getPaddingBottom()
|
||||
);
|
||||
mCall.setVisibility( View.GONE );
|
||||
}
|
||||
|
||||
try {
|
||||
MarkerShowEntity markerShowEntity = ( MarkerShowEntity ) marker.getObject();
|
||||
mContent.setText( markerShowEntity.getTextContent() );
|
||||
loadImageHeader( markerShowEntity );
|
||||
if ( markerShowEntity.getBindObj() instanceof MarkerOnlineCar ) {
|
||||
try {
|
||||
mTag.setText( ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getUserInfo().getSafeLabel() );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
mCall.setOnClickListener( view -> {
|
||||
if ( markerShowEntity.getBindObj() instanceof MarkerOnlineCar ) {
|
||||
if ( DebugConfig.getNetMode() != DebugConfig.NET_MODE_DEMO ) {
|
||||
callToFactUser( markerShowEntity );
|
||||
return;
|
||||
}
|
||||
sRefreshApiService.getMockUsers().subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe( new SubscribeImpl< DemoUserInfoEntity >( RequestOptions.create( mContext ) ) {
|
||||
@Override
|
||||
public void onSuccess( DemoUserInfoEntity o ) {
|
||||
super.onSuccess( o );
|
||||
callToDemoUser( markerShowEntity, o );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError( String message, int code ) {
|
||||
super.onError( message, code );
|
||||
callToFactUser( markerShowEntity );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
|
||||
return mInfoWindowView;
|
||||
}
|
||||
|
||||
private void callToDemoUser( MarkerShowEntity factUser, DemoUserInfoEntity demoUser ) {
|
||||
if ( demoUser == null
|
||||
|| demoUser.getResult() == null
|
||||
|| demoUser.getResult().getUserList() == null
|
||||
|| demoUser.getResult().getUserList().isEmpty() ) {
|
||||
callToFactUser( factUser );
|
||||
return;
|
||||
}
|
||||
List< DemoUserInfoEntity.ResultBean.UserListBean > users = demoUser.getResult().getUserList();
|
||||
for ( DemoUserInfoEntity.ResultBean.UserListBean user : users ) {
|
||||
if ( user == null ) {
|
||||
continue;
|
||||
}
|
||||
if ( TextUtils.equals( "1", user.getSceneType() ) ) {
|
||||
try {
|
||||
( ( MarkerOnlineCar ) factUser.getBindObj() ).getUserInfo().setSn( user.getUserInfo().getSn() );
|
||||
callToFactUser( factUser );
|
||||
return;
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
callToFactUser( factUser );
|
||||
}
|
||||
|
||||
private void callToFactUser( MarkerShowEntity factUser ) {
|
||||
if ( factUser == null ) {
|
||||
return;
|
||||
}
|
||||
Map< String, String > params = new HashMap<>();
|
||||
MarkerUserInfo userInfo = ( ( MarkerOnlineCar ) factUser.getBindObj() ).getUserInfo();
|
||||
if ( userInfo != null ) {
|
||||
params.put( CallChattingProviderConstant.CCPROVIDER_SN, userInfo.getSn() );
|
||||
params.put( CallChattingProviderConstant.CCPROVIDER_USER_IMG, userInfo.getUserHead() );
|
||||
params.put( CallChattingProviderConstant.CCPROVIDER_USER_AGE, userInfo.getAgeNumber() + "" );
|
||||
params.put( CallChattingProviderConstant.CCPROVIDER_NICK_NAME, userInfo.getUserName() );
|
||||
params.put( CallChattingProviderConstant.CCPROVIDER_USER_SEX, userInfo.getGender() + "" );
|
||||
}
|
||||
MarkerLocation location = ( ( MarkerOnlineCar ) factUser.getBindObj() ).getLocation();
|
||||
if ( location != null ) {
|
||||
params.put( CallChattingProviderConstant.CCPROVIDER_ADDRESS, location.getAddress() );
|
||||
params.put( CallChattingProviderConstant.CCPROVIDER_LAT, location.getLat() + "" );
|
||||
params.put( CallChattingProviderConstant.CCPROVIDER_LON, location.getLon() + "" );
|
||||
}
|
||||
Logger.d( TAG, "call parameters: %s", params );
|
||||
if ( MarkerServiceHandler.getApis().getStatusManagerApi().isV2XShow() ) {
|
||||
MarkerServiceHandler.getCarChatting().callShowWindow( params );
|
||||
} else {
|
||||
MarkerServiceHandler.getCarChatting().call( params );
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadImageHeader( final MarkerShowEntity markerShowEntity ) {
|
||||
|
||||
if ( Looper.myLooper() != Looper.getMainLooper() ) {
|
||||
UiThreadHandler.post( () -> {
|
||||
runOnUiThread( markerShowEntity );
|
||||
} );
|
||||
} else {
|
||||
runOnUiThread( markerShowEntity );
|
||||
}
|
||||
}
|
||||
|
||||
private void runOnUiThread( final MarkerShowEntity markerShowEntity ) {
|
||||
if ( !TextUtils.isEmpty( markerShowEntity.getIconUrl() ) ) {
|
||||
MarkerServiceHandler.getImageloader().displayImage( markerShowEntity.getIconUrl(),
|
||||
mUserHeader,
|
||||
WindowUtils.dip2px( mContext, 50 ), WindowUtils.dip2px( mContext, 50 ), null );
|
||||
|
||||
} else {
|
||||
mUserHeader.setBackgroundResource( R.drawable.icon_default_user_head );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user