Merge branch 'demo/shunyi_vr_map' of gitlab.zhidaoauto.com:ecos/yycp-service/Launcher into demo/shunyi_vr_map

This commit is contained in:
tongchenfei
2020-10-28 18:23:19 +08:00
90 changed files with 1736 additions and 685 deletions

View File

@@ -1,5 +1,6 @@
package com.mogo.launcher;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
@@ -37,6 +38,8 @@ import com.zhidao.boot.persistent.lib.PersistentManager;
import com.zhidao.mogo.module.left.panel.LeftPanelConst;
import com.zhidao.mogo.tanlu.api.TanluApiConst;
import java.util.List;
import static com.mogo.module.guide.GuideConstant.PATH_GUIDE_FRAGMENT;
import static com.mogo.module.guide.GuideConstant.PATH_GUIDE_MODULE_NAME;
@@ -110,9 +113,23 @@ public class MogoApplication extends AbsMogoApplication {
@Override
protected boolean shouldInit() {
return !LeakCanary.isInAnalyzerProcess( this );
return isMainProcess();
}
private boolean isMainProcess() {
ActivityManager am = ( ( ActivityManager ) getSystemService( Context.ACTIVITY_SERVICE ) );
List< ActivityManager.RunningAppProcessInfo > processInfos = am.getRunningAppProcesses();
String mainProcessName = getPackageName();
int myPid = android.os.Process.myPid();
for ( ActivityManager.RunningAppProcessInfo info : processInfos ) {
if ( info.pid == myPid && mainProcessName.equals( info.processName ) ) {
return true;
}
}
return false;
}
private void initDebugConfig() {
if ( !shouldInit() ) {
return;

View File

@@ -55,7 +55,7 @@ dependencies {
implementation project(':foudations:mogo-commons')
}
implementation 'com.zhidaoauto.machine:map:1.0.0-online-21'
implementation 'com.zhidaoauto.machine:map:1.0.0-online-23'
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -102,7 +102,7 @@ class AdasRecognizedResultDrawer {
points.add( new MogoLatLng( latLng.lat, latLon.lon ) );
}
if ( points.size() >= 1 ) {
marker.startSmooth( points, 1000 );
marker.startSmooth( points, 1 );
}
}
}
@@ -153,7 +153,7 @@ class AdasRecognizedResultDrawer {
}
MogoMarkerOptions options = new MogoMarkerOptions()
.owner( DataTypes.TYPE_MARKER_ADAS )
.icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.map_custom_ic_current_location2 ) )
.icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.module_common_online_car_vr_middle ) )
.position( new MogoLatLng( recognizedListResult.latLonList.get( 0 ).lat, recognizedListResult.latLonList.get( 0 ).lon ) );
return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( ModuleNames.CARD_TYPE_ROAD_CONDITION, options );
}

View File

@@ -0,0 +1,261 @@
package com.mogo.module.common.drawer;
import android.text.TextUtils;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
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.drawer.marker.OnlineCarMarkerView;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerNoveltyInfo;
import com.mogo.module.common.entity.MarkerOnlineCar;
import com.mogo.module.common.entity.MarkerShareMusic;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.utils.logger.Logger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public
/**
* @author congtaowang
* @since 2020/10/28
* <p>
* 描述
*/
class MarkerDrawer {
public static final int MARKER_Z_INDEX_HIGH = 100;
public static final int MARKER_Z_INDEX_LOW = 2;
private static volatile MarkerDrawer sInstance;
private MarkerDrawer() {
}
public static MarkerDrawer getInstance() {
if ( sInstance == null ) {
synchronized ( MarkerDrawer.class ) {
if ( sInstance == null ) {
sInstance = new MarkerDrawer();
}
}
}
return sInstance;
}
public synchronized void release() {
sInstance = null;
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, int zIndex, IMogoMarkerClickListener listener ) {
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( AbsMogoApplication.getApp(), 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 = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).addMarker( markerShowEntity.getMarkerType(), options );
marker.setOwner( markerShowEntity.getMarkerType() );
markerView.setMarker( marker );
marker.setOnMarkerClickListener( listener );
markerShowEntity.setMarker( marker );
return marker;
}
/**
* S = (A ∩ B) B
* A ∩ B)作为旧列表需要保留的部分
*
* @param newList
* @return
*/
public Map< String, IMogoMarker > purgeMarkerData( List newList, String markerType ) {
final long start = System.currentTimeMillis();
Map< String, IMogoMarker > existMap = new HashMap<>();
List< IMogoMarker > allCarsList = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).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;
}
/**
* @param maxAmount 展示的最大数量
* @param list
* @return
*/
public int getAppropriateSize( int maxAmount, List list ) {
if ( list == null ) {
return 0;
}
return Math.min( maxAmount, list.size() );
}
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();
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 "";
}
public 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 point1 点一坐标
* @param point2 点二坐标
* @return 两坐标的距离 单位M
*/
public static float calculateLineDistance( MogoLatLng point1, MogoLatLng point2 ) {
if ( point1 != null && point2 != null ) {
return calculateLineDistance( point1.lon, point1.lat, point2.lon, point2.lat );
} else {
return 0.0F;
}
}
/**
* @param lon1
* @param lat1
* @param lon2
* @param lat2
* @return 两坐标的距离 单位M
*/
public static float calculateLineDistance( double lon1, double lat1, double lon2, double lat2 ) {
try {
double var2 = lon1;
double var4 = lat1;
double var6 = lon2;
double var8 = lat2;
var2 *= 0.01745329251994329D;
var4 *= 0.01745329251994329D;
var6 *= 0.01745329251994329D;
var8 *= 0.01745329251994329D;
double var10 = Math.sin( var2 );
double var12 = Math.sin( var4 );
double var14 = Math.cos( var2 );
double var16 = Math.cos( var4 );
double var18 = Math.sin( var6 );
double var20 = Math.sin( var8 );
double var22 = Math.cos( var6 );
double var24 = Math.cos( var8 );
double[] var28 = new double[3];
double[] var29 = new double[3];
var28[0] = var16 * var14;
var28[1] = var16 * var10;
var28[2] = var12;
var29[0] = var24 * var22;
var29[1] = var24 * var18;
var29[2] = var20;
return ( float ) ( Math.asin( Math.sqrt( ( var28[0] - var29[0] ) * ( var28[0] - var29[0] ) + ( var28[1] - var29[1] ) * ( var28[1] - var29[1] ) + ( var28[2] - var29[2] ) * ( var28[2] - var29[2] ) ) / 2.0D ) * 1.27420015798544E7D );
} catch ( Throwable var26 ) {
var26.printStackTrace();
return 0.0F;
}
}
}

View File

@@ -0,0 +1,193 @@
package com.mogo.module.common.drawer;
import android.graphics.Rect;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.module.common.ModuleNames;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.entity.MarkerCarPois;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerOnlineCar;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public
/**
* @author congtaowang
* @since 2020/10/28
*
* 描述
*/
class OnlineCarDrawer {
private static final String TAG = "OnlineCarDrawer";
// 平滑移动事件间隔(单位:秒)
private static final int SMOOTH_DURATION = 15;
private static volatile OnlineCarDrawer sInstance;
private OnlineCarDrawer() {
}
public static OnlineCarDrawer getInstance() {
if ( sInstance == null ) {
synchronized ( OnlineCarDrawer.class ) {
if ( sInstance == null ) {
sInstance = new OnlineCarDrawer();
}
}
}
return sInstance;
}
public synchronized void release() {
sInstance = null;
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
/**
* 绘制在线车辆marker
*
* @param onlineCarList
*/
public void drawOnlineCarMarkers( List< MarkerOnlineCar > onlineCarList,
int maxAmount,
boolean clearOld,
boolean showBounds,
Rect bound,
MogoLatLng centerPoint,
IMogoMarkerClickListener listener ) {
// 将数据同步给在线车辆,避免每次 perform 的时候去拉取,造成消耗
if ( onlineCarList == null || onlineCarList.isEmpty() ) {
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).removeMarkers( ModuleNames.CARD_TYPE_USER_DATA );
return;
}
if ( clearOld ) {
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).removeMarkers( ModuleNames.CARD_TYPE_USER_DATA );
}
int size = MarkerDrawer.getInstance().getAppropriateSize( maxAmount, onlineCarList );
Map< String, IMogoMarker > existCarMap = MarkerDrawer.getInstance().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 = MarkerDrawer.getInstance().getPrimaryKeyFromEntity( markerOnlineCar );
IMogoMarker mogoMarker = existCarMap.get( sn );
if ( mogoMarker == null || mogoMarker.isDestroyed() ) {
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_LOW, listener );
}
if ( mogoMarker != null ) {
mogoMarker.setVisible( true );
}
startSmooth( mogoMarker, markerOnlineCar, markerLocation );
}
if ( showBounds && bound != null ) {
// 将前6个点显示在固定范围内
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().showBounds( TAG, centerPoint, carPoints, bound, false );
}
}
// 平滑移动
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 = MarkerDrawer.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 ( MarkerDrawer.calculateLineDistance( new MogoLatLng( lat1, lng1 ), new MogoLatLng( lat2, lng2 ) ) >= 500 ) {
Logger.d( TAG, "filter point" );
return true;
}
} catch ( Exception e ) {
}
return false;
}
}

View File

@@ -0,0 +1,128 @@
package com.mogo.module.common.drawer;
import android.view.animation.LinearInterpolator;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.marker.anim.OnMarkerAnimationListener;
import com.mogo.module.common.ModuleNames;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.utils.WorkThreadHandler;
import com.mogo.utils.logger.Logger;
import java.util.List;
import java.util.Map;
public
/**
* @author congtaowang
* @since 2020/10/28
*
* 描述
*/
class RoadConditionDrawer {
private static final String TAG = "RoadConditionDrawer";
private static volatile RoadConditionDrawer sInstance;
private RoadConditionDrawer() {
}
public static RoadConditionDrawer getInstance() {
if ( sInstance == null ) {
synchronized ( RoadConditionDrawer.class ) {
if ( sInstance == null ) {
sInstance = new RoadConditionDrawer();
}
}
}
return sInstance;
}
public synchronized void release() {
sInstance = null;
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
/**
* 探路数据
*
* @param exploreWayList
*/
public void drawRoadConditionMarker( List< MarkerExploreWay > exploreWayList, int maxAmount, IMogoMarkerClickListener listener ) {
// 将数据同步给探路,避免探路每次 perform 的时候去拉取,造成消耗
if ( exploreWayList == null || exploreWayList.isEmpty() ) {
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).removeMarkers( ModuleNames.CARD_TYPE_ROAD_CONDITION );
return;
}
int size = MarkerDrawer.getInstance().getAppropriateSize( maxAmount, exploreWayList );
Map< String, IMogoMarker > existCarMap = MarkerDrawer.getInstance().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 = MarkerDrawer.getInstance().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, listener );
} else {
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener );
}
} catch ( Exception e ) {
e.printStackTrace();
}
}
}
}
}
private void post2AddAndStartAnimation( MarkerShowEntity entity, long delay, IMogoMarkerClickListener listener ) {
if ( entity == null ) {
return;
}
WorkThreadHandler.getInstance().postDelayed( () -> {
if ( entity == null ) {
return;
}
IMogoMarker marker = MarkerDrawer.getInstance().drawMapMarkerImpl( entity, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener );
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 );
}
}

View File

@@ -108,7 +108,7 @@ class SnapshotSetDataDrawer {
points.add( new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ) );
}
if ( points.size() >= 1 ) {
marker.startSmooth( points, 1000 );
marker.startSmooth( points, 1 );
}
}
}
@@ -160,7 +160,7 @@ class SnapshotSetDataDrawer {
}
MogoMarkerOptions options = new MogoMarkerOptions()
.owner( DataTypes.TYPE_MARKER_CLOUD_DATA )
.icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.map_custom_ic_current_location2 ) )
.icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.module_common_online_car_vr_middle ) )
.position( new MogoLatLng( data.getLat(), data.getLon() ) );
return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( ModuleNames.CARD_TYPE_ROAD_CONDITION, options );
}

View File

@@ -1,4 +1,4 @@
package com.mogo.module.service.marker;
package com.mogo.module.common.drawer.marker;
import android.graphics.Bitmap;
import android.view.View;
@@ -15,7 +15,7 @@ public interface IMarkerView {
View getView();
default Bitmap getBitmap(int type){
default Bitmap getBitmap( int type ){
return null;
}

View File

@@ -1,17 +1,11 @@
package com.mogo.module.service.marker;
package com.mogo.module.common.drawer.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

View File

@@ -1,4 +1,4 @@
package com.mogo.module.service.marker;
package com.mogo.module.common.drawer.marker;
import android.content.Context;
import android.graphics.Bitmap;
@@ -7,19 +7,17 @@ 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.MogoApisHandler;
import com.mogo.module.common.R;
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;
@@ -83,7 +81,7 @@ public abstract class MapMarkerBaseView extends LinearLayout implements IMarkerV
private void runOnUiThread(final MarkerShowEntity markerShowEntity){
if (!TextUtils.isEmpty(markerShowEntity.getIconUrl())) {
MarkerServiceHandler.getImageloader().displayImage(markerShowEntity.getIconUrl(),
MogoApisHandler.getInstance().getApis().getImageLoaderApi().displayImage(markerShowEntity.getIconUrl(),
ivUserHead,
WindowUtils.dip2px(mContext, 50), WindowUtils.dip2px(mContext, 50),
new IMogoImageLoaderListener() {
@@ -108,7 +106,7 @@ public abstract class MapMarkerBaseView extends LinearLayout implements IMarkerV
});
} else {
ivUserHead.setBackgroundResource(R.drawable.icon_default_user_head);
ivUserHead.setBackgroundResource( R.drawable.icon_default_user_head);
}
}
@@ -116,7 +114,7 @@ public abstract class MapMarkerBaseView extends LinearLayout implements IMarkerV
view.setDrawingCacheEnabled( true );
processChildView( view );
view.destroyDrawingCache();
view.measure( View.MeasureSpec.makeMeasureSpec( 0, View.MeasureSpec.UNSPECIFIED ), View.MeasureSpec.makeMeasureSpec( 0, View.MeasureSpec.UNSPECIFIED ) );
view.measure( MeasureSpec.makeMeasureSpec( 0, MeasureSpec.UNSPECIFIED ), MeasureSpec.makeMeasureSpec( 0, 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;

View File

@@ -1,4 +1,4 @@
package com.mogo.module.service.marker;
package com.mogo.module.common.drawer.marker;
import android.content.Context;
import android.text.TextUtils;
@@ -12,12 +12,12 @@ import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.ModuleNames;
import com.mogo.module.common.R;
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
@@ -70,8 +70,8 @@ public class MapMarkerInfoView extends MapMarkerBaseView {
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:
case ModuleNames.CARD_TYPE_CARS_CHATTING:
case ModuleNames.CARD_TYPE_USER_DATA:
ivUserHead.setVisibility( View.VISIBLE );
ivIcon.setVisibility( View.INVISIBLE );
loadImageWithMarker( markerShowEntity );
@@ -79,8 +79,8 @@ public class MapMarkerInfoView extends MapMarkerBaseView {
//ivCar.setRotation(new Random().nextInt(360));
ivCar.setRotation( ( float ) markerShowEntity.getMarkerLocation().getAngle() );
break;
case ServiceConst.CARD_TYPE_ROAD_CONDITION:
case ServiceConst.CARD_TYPE_NOVELTY:
case ModuleNames.CARD_TYPE_ROAD_CONDITION:
case ModuleNames.CARD_TYPE_NOVELTY:
ivUserHead.setVisibility( View.INVISIBLE );
ivIcon.setVisibility( View.VISIBLE );
@@ -143,7 +143,7 @@ public class MapMarkerInfoView extends MapMarkerBaseView {
}
}
break;
case ServiceConst.CARD_TYPE_SHARE_MUSIC:
case ModuleNames.CARD_TYPE_SHARE_MUSIC:
ivUserHead.setVisibility( View.INVISIBLE );
ivIcon.setVisibility( View.VISIBLE );

View File

@@ -1,4 +1,4 @@
package com.mogo.module.service.marker;
package com.mogo.module.common.drawer.marker;
import android.content.Context;
import android.util.AttributeSet;
@@ -7,12 +7,12 @@ import android.view.LayoutInflater;
import androidx.annotation.Nullable;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.ModuleNames;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.R;
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
@@ -52,10 +52,13 @@ public class MapMarkerView extends MapMarkerBaseView {
try {
Object bindObj = markerShowEntity.getBindObj();
if ( MogoApisHandler.getInstance().getApis().getMapFrameControllerApi().isVrMode() ) {
ivCar.setImageResource( R.drawable.icon_map_marker_location_yellow_vr );
} else {
ivCar.setImageResource( R.drawable.icon_map_marker_location_yellow );
}
switch ( markerShowEntity.getMarkerType() ) {
case ServiceConst.CARD_TYPE_ROAD_CONDITION:
case ServiceConst.CARD_TYPE_NOVELTY:
case ModuleNames.CARD_TYPE_ROAD_CONDITION:
case ModuleNames.CARD_TYPE_NOVELTY:
if ( bindObj instanceof MarkerExploreWay && ( ( MarkerExploreWay ) bindObj ).getPoiType() != null ) {
switch ( ( ( MarkerExploreWay ) bindObj ).getPoiType() ) {
case MarkerPoiTypeEnum.GAS_STATION:

View File

@@ -1,4 +1,4 @@
package com.mogo.module.service.marker;
package com.mogo.module.common.drawer.marker;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -6,8 +6,7 @@ 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 com.mogo.module.common.R;
import java.lang.ref.SoftReference;
import java.util.HashMap;

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="0"
android:endColor="#FFCC00"
android:startColor="#FFA417" />
<corners android:radius="90dp" />
<padding
android:bottom="@dimen/dp_6"
android:left="@dimen/dp_6"
android:right="@dimen/dp_40"
android:top="@dimen/dp_6" />
</shape >

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/shape_id" >
<!-- 倒三角 -->
<rotate
android:fromDegrees="45"
android:pivotX="135%"
android:pivotY="15%"
android:toDegrees="45" >
<shape android:shape="rectangle" >
<solid android:color="#feb712" />
</shape >
</rotate >
</item >
</layer-list >

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="1px"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
<FrameLayout
android:id="@+id/clMarkerTopView"
android:layout_width="@dimen/module_service_marker_bubble_width"
android:background="@drawable/module_services_marker_bkg"
android:layout_height="@dimen/module_service_marker_bubble_height">
<ImageView
android:id="@+id/ivIcon"
android:layout_width="@dimen/module_service_marker_bubble_icon_width"
android:layout_height="@dimen/module_service_marker_bubble_icon_height"
android:layout_gravity="center"
android:layout_marginBottom="@dimen/module_service_marker_bubble_icon_marginBottom"
tools:src="@drawable/icon_map_marker_road_block_up2" />
</FrameLayout>
<ImageView
android:id="@+id/ivCar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/module_service_marker_dot_marginTop"
android:src="@drawable/icon_map_marker_location_yellow" />
</LinearLayout>

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="1px"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/clMarkerContent"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_90"
android:background="@drawable/bg_map_marker_yellow_info"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.mogo.service.imageloader.MogoImageView
android:id="@+id/ivUserHead"
android:layout_width="@dimen/dp_76"
android:layout_height="@dimen/dp_76"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:miv_failureHolder="@drawable/icon_default_user_head"
app:miv_overlayImageId="@drawable/icon_default_user_head"
app:miv_placeHolder="@drawable/icon_default_user_head"
app:miv_shape="circle" />
<ImageView
android:id="@+id/ivIcon"
android:layout_width="@dimen/module_service_marker_bubble_icon_width"
android:layout_height="@dimen/module_service_marker_bubble_icon_height"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/dp_15"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/icon_map_marker_road_block_up"
tools:visibility="visible" />
<TextView
android:id="@+id/tvMarkerContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:ellipsize="end"
android:gravity="center"
android:singleLine="true"
android:textColor="#ffffff"
android:textSize="@dimen/sp_32"
app:layout_constraintBottom_toBottomOf="@+id/ivUserHead"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/ivUserHead"
app:layout_constraintTop_toTopOf="@+id/ivUserHead"
tools:text="诗一样的女子" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="@+id/clMarkerContent"
app:layout_constraintStart_toStartOf="@+id/clMarkerContent"
app:layout_constraintTop_toBottomOf="@+id/clMarkerContent">
<ImageView
android:id="@+id/ivReverseTriangle"
android:layout_width="@dimen/module_service_marker_anchor_size"
android:layout_height="@dimen/module_service_marker_anchor_size"
android:src="@drawable/bg_shape_reverse_yellow" />
<ImageView
android:id="@+id/ivCar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_map_marker_location_yellow" />
</LinearLayout>
</LinearLayout>

View File

@@ -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 );
}
/**

View File

@@ -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;
/**
* 切换卡片内容-上一个
*/

View File

@@ -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()

View File

@@ -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;

View File

@@ -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 );
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B

View File

@@ -101,10 +101,6 @@ public class V2XMessageListener_401003 implements IMogoOnMessageListener<V2XPush
showTip(alarmMessage.getTts());
ADASUtils.broadcastToADAS_TTS(V2XServiceManager.getContext(), alarmMessage);
break;
//以下为V推送场景
case "200006"://对向来车
showTip(alarmMessage.getTts());
break;
default:
ADASUtils.broadcastToADAS_TTS(V2XServiceManager.getContext(), alarmMessage);
break;

View File

@@ -10,6 +10,8 @@ import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.module.common.drawer.marker.IMarkerView;
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
import com.mogo.module.common.entity.MarkerCardResult;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerLocation;
@@ -18,8 +20,6 @@ import com.mogo.module.common.entity.MarkerOnlineCar;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.service.ServiceConst;
import com.mogo.module.service.Utils;
import com.mogo.module.service.marker.IMarkerView;
import com.mogo.module.service.marker.MapMarkerAdapter;
import com.mogo.module.service.utils.ViewUtils;
import com.mogo.module.v2x.MoGoV2XServicePaths;
import com.mogo.module.v2x.V2XConst;

View File

@@ -6,8 +6,8 @@ import android.view.LayoutInflater;
import androidx.annotation.Nullable;
import com.mogo.module.common.drawer.marker.MapMarkerBaseView;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.service.marker.MapMarkerBaseView;
import com.mogo.module.v2x.R;
/**

View File

@@ -13,8 +13,6 @@ import com.mogo.service.windowview.IMogoTopViewStatusListener;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
@@ -25,6 +23,7 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
public class V2XPushVREventScenario
extends AbsV2XScenario<V2XPushMessageEntity>
implements IMogoTopViewStatusListener {
private String TAG = "V2XPushVREventWindow";
private static V2XPushVREventScenario mV2XPushEventScenario;
@@ -37,6 +36,7 @@ public class V2XPushVREventScenario
if (mV2XPushEventScenario == null) {
mV2XPushEventScenario = new V2XPushVREventScenario();
mV2XPushEventScenario.setV2XMarker(new V2XPushVREventMarker());
mV2XPushEventScenario.setV2XWindow(new V2XPushVREventWindow());
}
}
}
@@ -46,15 +46,17 @@ public class V2XPushVREventScenario
@Override
public void init(@Nullable V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity) {
Logger.w(MODULE_NAME, "处理推送VR场景" + GsonUtil.jsonFromObject(v2XMessageEntity));
Logger.w(V2XConst.MODULE_NAME + "_" + TAG, "处理推送VR场景" + GsonUtil.jsonFromObject(v2XMessageEntity));
if (!isSameScenario(v2XMessageEntity)
&& V2XServiceManager.getMoGoStatusManager().isMainPageLaunched()) {
setV2XMessageEntity(v2XMessageEntity);
show();
} else {
closeWindow();
setV2XMessageEntity(v2XMessageEntity);
Logger.w(V2XConst.MODULE_NAME, "要处理的场景已经存在,丢弃这次初始化");
show();
Logger.w(V2XConst.MODULE_NAME + "_" + TAG, "要处理的场景已经存在,丢弃这次初始化");
}
}
@@ -70,7 +72,7 @@ public class V2XPushVREventScenario
@Override
public void showWindow() {
if (getV2XWindow() != null) {
//TODO 这里调用 showLeftNoticeByType 进行展示左下角的弹窗
getV2XWindow().show(getV2XMessageEntity().getContent());
}
}
@@ -115,22 +117,22 @@ public class V2XPushVREventScenario
////////////////////////////////////////////////////////////////////////////////////////////////////
@Override
public void onViewAdded(View view) {
Logger.d(MODULE_NAME, "展示 Window 动画结束");
Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "展示 Window 动画结束");
}
@Override
public void onViewRemoved(View view) {
Logger.d(MODULE_NAME, "关闭 Window 动画结束");
Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "关闭 Window 动画结束");
}
@Override
public void beforeViewAddAnim(View view) {
Logger.d(MODULE_NAME, "展示 Window 开始");
Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "展示 Window 开始");
}
@Override
public void beforeViewRemoveAnim(View view) {
Logger.d(MODULE_NAME, "关闭 Window 开始");
Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "关闭 Window 开始");
V2XServiceManager.getMoGoV2XStatusManager().setPushWindowShow(TAG, false);
// 重置场景提示的消息
setV2XMessageEntity(null);

View File

@@ -0,0 +1,93 @@
package com.mogo.module.v2x.scenario.scene.pushVR;
import android.os.Handler;
import android.view.View;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
import com.mogo.module.v2x.scenario.view.IV2XWindow;
import com.mogo.service.entrance.IMogoEntranceButtonController;
import com.mogo.utils.logger.Logger;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/14 2:37 PM
* desc :
* TODO 只有VR演示场景使用
* version: 1.0
*/
public class V2XPushVREventWindow implements IV2XWindow<V2XPushMessageEntity> {
private String TAG = "V2XPushVREventWindow";
// 处理道路事件30秒倒计时
private Handler handlerV2XEvent = new Handler();
private Runnable runnableV2XEvent;
private int mExpireTime = 30000;
/**
* 展示道路事件详情Windows
*/
@Override
public void show(V2XPushMessageEntity entity) {
Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=推送消息:展示 Window=\n" + entity);
V2XServiceManager
.getMogoEntranceButtonController()
.showLeftNoticeByType(
IMogoEntranceButtonController.NOTICE_TYPE_CONGESTION_RECOMMENDED,
R.drawable.module_v2x_left_notice_seek_help,
entity.getAlarmContent());
countDownV2XEvent();
}
/**
* 关闭详情展示框
*/
@Override
public void close() {
Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=关闭Window");
V2XServiceManager
.getMogoEntranceButtonController()
.hideLeftNoticeByType(IMogoEntranceButtonController.NOTICE_TYPE_CONGESTION_RECOMMENDED);
// 停止倒计时
if (handlerV2XEvent != null && runnableV2XEvent != null) {
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
runnableV2XEvent = null;
}
}
@Override
public View getView() {
return null;
}
@Override
public void setWindowStatusListener(V2XWindowStatusListener listener) {
}
/**
* 窗体倒计时
*/
public void countDownV2XEvent() {
// 倒计时
if (runnableV2XEvent == null) {
runnableV2XEvent = () -> {
Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=30秒倒计时结束。。。");
// 移出Window详细信息
close();
};
} else {
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
}
Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=推送消息 Window 展示开始倒计时:" + mExpireTime);
handlerV2XEvent.postDelayed(runnableV2XEvent, mExpireTime);
}
}

View File

@@ -220,7 +220,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
* 逆向车辆路线预判
* */
btnTriggerReverseVehicleRoutePrediction.setOnClickListener(v -> {
V2XMessageEntity<List<V2XSpecialCarRes.V2XMarkerEntity>> v2XMessageEntity =
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarionVRReverseCarData();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);

View File

@@ -327,7 +327,7 @@ public class TestOnLineCarUtils {
/**
* 逆向车辆路线预判
*/
public static V2XMessageEntity<List<V2XSpecialCarRes.V2XMarkerEntity>> getV2XScenarionVRReverseCarData() {
public static V2XMessageEntity<V2XPushMessageEntity> getV2XScenarionVRReverseCarData() {
try {
InputStream inputStream = V2XUtils.getApp()
.getResources()
@@ -341,14 +341,13 @@ public class TestOnLineCarUtils {
inputStream.close();
// 加载数据源
V2XSpecialCarRes v2xRoadEventEntity =
GsonUtil.objectFromJson(baos.toString(), V2XSpecialCarRes.class);
V2XPushMessageEntity v2xRoadEventEntity = GsonUtil.objectFromJson(baos.toString(), V2XPushMessageEntity.class);
V2XMessageEntity<List<V2XSpecialCarRes.V2XMarkerEntity>> v2xMessageEntity = new V2XMessageEntity<>();
V2XMessageEntity<V2XPushMessageEntity> v2xMessageEntity = new V2XMessageEntity<>();
// 控制类型
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING);
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW);
// 设置数据
v2xMessageEntity.setContent(v2xRoadEventEntity.getCoordinates());
v2xMessageEntity.setContent(v2xRoadEventEntity);
// 控制展示状态
v2xMessageEntity.setShowState(true);
return v2xMessageEntity;

View File

@@ -0,0 +1,820 @@
{
"sceneId": "200006",
"alarmContent": "及时发现前方障碍物并告知车主,降低事故发生概率",
"expireTime": 30000,
"sceneCategory": 0,
"sceneDescription": "利用用户分享数据以及单车识别能力将障碍物告知其他通过车主,从而降低事故发生概率",
"sceneName": "障碍物绕行",
"sceneLevel": 0,
"sceneChannel": "",
"sceneSn": "",
"tts": "前方发现障碍物注意避让",
"zoom": false,
"zoomScale": 15,
"lat": 40.968678,
"lon": 116.405467,
"userHead": "",
"msgImgUrl": "",
"polyline": [
[
116.737779,
40.196461
],
[
116.737689,
40.196462
],
[
116.737545,
40.196464
],
[
116.737396,
40.196465
],
[
116.737215,
40.196466
],
[
116.737064,
40.196467
],
[
116.736875,
40.196468
],
[
116.736744,
40.196468
],
[
116.736602,
40.196469
],
[
116.736458,
40.19647
],
[
116.736304,
40.196471
],
[
116.736175,
40.196472
],
[
116.736044,
40.196472
],
[
116.735883,
40.196473
],
[
116.735228,
40.196477
],
[
116.735117,
40.196478
],
[
116.734994,
40.196478
],
[
116.734878,
40.196479
],
[
116.734748,
40.19648
],
[
116.734636,
40.196481
],
[
116.734557,
40.196481
],
[
116.734472,
40.196481
],
[
116.734392,
40.196482
],
[
116.734293,
40.196482
],
[
116.734226,
40.196482
],
[
116.734138,
40.196483
],
[
116.733983,
40.196484
],
[
116.733862,
40.196485
],
[
116.733725,
40.196486
],
[
116.7336,
40.196486
],
[
116.733432,
40.196485
],
[
116.733331,
40.196484
],
[
116.733259,
40.196482
],
[
116.733173,
40.19648
],
[
116.733106,
40.196477
],
[
116.733002,
40.196471
],
[
116.732923,
40.196467
],
[
116.73282,
40.196459
],
[
116.732724,
40.19645
],
[
116.73263,
40.196441
],
[
116.732529,
40.19643
],
[
116.732431,
40.196419
],
[
116.732376,
40.196413
],
[
116.732295,
40.196403
],
[
116.732215,
40.196391
],
[
116.732154,
40.196382
],
[
116.732076,
40.196371
],
[
116.731991,
40.196356
],
[
116.731927,
40.196345
],
[
116.731847,
40.19633
],
[
116.73177,
40.196316
],
[
116.731728,
40.196307
],
[
116.731664,
40.196294
],
[
116.731571,
40.196274
],
[
116.731509,
40.19626
],
[
116.731435,
40.196244
],
[
116.731357,
40.196224
],
[
116.7313,
40.196211
],
[
116.731226,
40.196191
],
[
116.731148,
40.196171
],
[
116.731076,
40.19615
],
[
116.731016,
40.196133
],
[
116.730949,
40.196113
],
[
116.730892,
40.196096
],
[
116.730827,
40.196075
],
[
116.730761,
40.196053
],
[
116.730675,
40.196025
],
[
116.730616,
40.196005
],
[
116.730549,
40.195981
],
[
116.730353,
40.195908
],
[
116.730214,
40.195852
],
[
116.730081,
40.195798
],
[
116.729945,
40.195742
],
[
116.729836,
40.195699
],
[
116.729727,
40.195659
],
[
116.729611,
40.195616
],
[
116.729486,
40.195572
],
[
116.72935,
40.195529
],
[
116.729181,
40.195479
],
[
116.729013,
40.195434
],
[
116.728924,
40.195412
],
[
116.72877,
40.195374
],
[
116.728622,
40.195341
],
[
116.728469,
40.195308
],
[
116.728325,
40.195281
],
[
116.728174,
40.195254
],
[
116.728018,
40.195229
],
[
116.727794,
40.1952
],
[
116.727599,
40.195179
],
[
116.727432,
40.195165
],
[
116.727299,
40.195156
],
[
116.727073,
40.195145
],
[
116.72695,
40.195142
],
[
116.726733,
40.195139
],
[
116.726488,
40.19514
],
[
116.726312,
40.195141
],
[
116.726115,
40.195143
],
[
116.725869,
40.195148
],
[
116.725651,
40.195155
],
[
116.72537,
40.195161
],
[
116.725188,
40.195163
],
[
116.725092,
40.195162
],
[
116.725091,
40.195123
],
[
116.725335,
40.195123
],
[
116.725499,
40.195123
],
[
116.72602,
40.195109
],
[
116.726235,
40.195106
],
[
116.726424,
40.195105
],
[
116.726658,
40.195104
],
[
116.726733,
40.195105
],
[
116.72688,
40.195106
],
[
116.72704,
40.195109
],
[
116.727217,
40.195115
],
[
116.727388,
40.195124
],
[
116.727562,
40.195136
],
[
116.727735,
40.195155
],
[
116.727887,
40.195174
],
[
116.727979,
40.195186
],
[
116.728056,
40.195198
],
[
116.728165,
40.195216
],
[
116.728237,
40.195228
],
[
116.728345,
40.195247
],
[
116.728411,
40.19526
],
[
116.728533,
40.195283
],
[
116.728589,
40.195295
],
[
116.728694,
40.195318
],
[
116.728761,
40.195334
],
[
116.728868,
40.19536
],
[
116.728918,
40.195372
],
[
116.729088,
40.195416
],
[
116.729262,
40.195462
],
[
116.729424,
40.195512
],
[
116.729547,
40.195553
],
[
116.729584,
40.195566
],
[
116.729692,
40.195606
],
[
116.729739,
40.195624
],
[
116.729844,
40.195661
],
[
116.730011,
40.195726
],
[
116.73014,
40.195778
],
[
116.730309,
40.195849
],
[
116.730467,
40.195911
],
[
116.730608,
40.195962
],
[
116.730673,
40.195984
],
[
116.730766,
40.196015
],
[
116.730831,
40.196036
],
[
116.730935,
40.196069
],
[
116.730993,
40.196087
],
[
116.731086,
40.196113
],
[
116.731164,
40.196135
],
[
116.731285,
40.196165
],
[
116.731315,
40.196173
],
[
116.731434,
40.196202
],
[
116.731486,
40.196214
],
[
116.731586,
40.196238
],
[
116.731652,
40.196253
],
[
116.731749,
40.196273
],
[
116.731818,
40.196287
],
[
116.731924,
40.196305
],
[
116.731991,
40.196317
],
[
116.732108,
40.196336
],
[
116.732269,
40.196361
],
[
116.732333,
40.19637
],
[
116.732464,
40.196385
],
[
116.732507,
40.19639
],
[
116.732628,
40.196404
],
[
116.732678,
40.196409
],
[
116.732784,
40.196418
],
[
116.732851,
40.196424
],
[
116.732985,
40.196433
],
[
116.73314,
40.196439
],
[
116.733198,
40.196441
],
[
116.733379,
40.196445
],
[
116.733548,
40.196445
],
[
116.733722,
40.196445
],
[
116.733903,
40.196445
],
[
116.734081,
40.196447
],
[
116.734251,
40.196446
],
[
116.734439,
40.196445
],
[
116.734624,
40.196444
],
[
116.734805,
40.196442
],
[
116.734982,
40.196442
],
[
116.735164,
40.196441
],
[
116.735329,
40.19644
],
[
116.735519,
40.196438
],
[
116.735682,
40.196437
],
[
116.735855,
40.196437
],
[
116.736034,
40.196436
],
[
116.73621,
40.196435
],
[
116.736385,
40.196433
],
[
116.736566,
40.196433
],
[
116.736742,
40.196431
],
[
116.736926,
40.196431
],
[
116.737046,
40.19643
],
[
116.737173,
40.19643
],
[
116.737298,
40.196429
],
[
116.737449,
40.196427
],
[
116.737582,
40.196427
],
[
116.737662,
40.196425
],
[
116.737748,
40.196425
],
[
116.73778,
40.196424
]
]
}

View File

@@ -1,5 +1,5 @@
{
"sceneId": "200006",
"sceneId": "200007",
"alarmContent": "展现行人预测、提前预警能力",
"expireTime": 30000,
"sceneCategory": 0,

View File

@@ -57,6 +57,11 @@ public interface IMogoEntranceButtonController extends IProvider {
*/
int NOTICE_TYPE_OBSTACLE_CAR_WARN = 1010;
/**
* 拥堵路线推荐
*/
int NOTICE_TYPE_CONGESTION_RECOMMENDED = 1011;
/**
* 获取入口按钮实例
*