Merge remote-tracking branch 'origin/dev_merge_shunyi_vr_map' into dev_merge_shunyi_vr_map

This commit is contained in:
tongchenfei
2020-12-16 15:10:05 +08:00
24 changed files with 337 additions and 63 deletions

View File

@@ -176,7 +176,7 @@ android {
// 分享时是否隐藏 adas
buildConfigField 'boolean', 'IS_NEED_HIDE_ADAS_WHEN_SHARE', 'false'
// 是否需要实时上报坐标
buildConfigField 'boolean', 'IS_NEED_UPLOAD_COORDINATES_IN_TIME', 'true'
buildConfigField 'boolean', 'IS_NEED_UPLOAD_COORDINATES_IN_TIME', 'false'
}
// e系列采用Launcher方案
e8xx {

View File

@@ -31,7 +31,9 @@ class HttpDnsNoop implements IMogoHttpDns {
@Override
public void getHttpDnsIp( String host, boolean useCache, IHttpDnsCallback callback ) {
if ( callback != null ) {
callback.onParsed( null );
}
}
@Override

View File

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

View File

@@ -19,6 +19,30 @@ import java.util.Map;
*/
public class AMapMarkerClickHandler {
private static volatile AMapMarkerClickHandler sInstance;
private AMapMarkerClickHandler(){}
public static AMapMarkerClickHandler getInstance(){
if( sInstance == null ){
synchronized( AMapMarkerClickHandler.class ) {
if( sInstance == null ){
sInstance = new AMapMarkerClickHandler();
}
}
}
return sInstance;
}
public synchronized void release(){
sInstance = null;
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
public boolean handleMarkerClicked( Marker marker ) {
if ( marker == null ) {
return false;

View File

@@ -25,9 +25,9 @@ import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.map.uicontroller.MapCameraPosition;
import com.mogo.map.uicontroller.MapControlResult;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
import com.zhidaoauto.map.sdk.open.MapAutoApi;
import com.zhidaoauto.map.sdk.open.MapParams;
import com.zhidaoauto.map.sdk.open.abs.MapStatusListener;
import com.zhidaoauto.map.sdk.open.abs.OnCameraChangeListener;
import com.zhidaoauto.map.sdk.open.abs.OnMapClickListener;
@@ -82,6 +82,7 @@ public class AMapViewWrapper implements IMogoMapView,
private CarCursorOption mCarCursorOption = DEFAULT_OPTION;
private Location mLastDriveLocationShadow = null;
private EnumMapUI mCurrentUI;
public AMapViewWrapper( MapAutoView mMapView ) {
startTime = System.currentTimeMillis();
@@ -161,7 +162,7 @@ public class AMapViewWrapper implements IMogoMapView,
private void initListeners() {
mMapView.setOnMarkClickListener( this );
mMarkerClickHandler = new AMapMarkerClickHandler();
mMarkerClickHandler = AMapMarkerClickHandler.getInstance();
mMapView.setOnMapLoadedListener( this );
mMapView.setOnMapTouchListener( this );
mMapView.setOnMapClickListener( this );
@@ -171,6 +172,7 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.registerListener( this, MapAutoApi.LISTENER_TYPE_3D );
mMapView.setMOnCameraChangeListener( this );
mMapView.setOnMapStyleListener( this );
Logger.d( TAG, "styleop - initListeners - setOnMapStyleListener - view %s", mMapView );
// mMapView.setOnPolylineClickListener( this );
// mMapView.setAMapNaviViewListener( this );
@@ -249,7 +251,7 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void setTrafficEnabled( boolean visible ) {
if ( checkAMapView() ) {
mMapView.getMapAutoViewHelper().setTraffic( visible );
// mMapView.getMapAutoViewHelper().setTraffic( visible );
}
}
@@ -257,7 +259,6 @@ public class AMapViewWrapper implements IMogoMapView,
public MapControlResult changeZoom( boolean zoom ) {
if ( checkAMapView() ) {
mDefaultZoomLevel = ( getMap().getZoomLevel() + 0.5f );
if ( zoom ) {
if ( mDefaultZoomLevel >= 20f ) {
return MapControlResult.TARGET;
@@ -290,7 +291,9 @@ public class AMapViewWrapper implements IMogoMapView,
if ( DebugConfig.isDebug() ) {
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
}
if ( mCurrentUI == EnumMapUI.Type_VR ) {
return MapControlResult.ERROR;
}
getMap().changeZoom( zoom );
return MapControlResult.SUCCESS;
}
@@ -305,6 +308,7 @@ public class AMapViewWrapper implements IMogoMapView,
case CarUp_2D:
case CarUp_3D:
case NorthUP_2D:
setUIMode( ui );
break;
case Type_VR:
mMapView.getMapAutoViewHelper().setMapStyle( MapAutoApi.MAP_STYLE_VR );
@@ -762,8 +766,27 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void onChangeMapStyle( int i ) {
if ( i == MapParams.MAP_STYLE_VR ) {
MogoMapListenerHandler.getInstance().onMapModeChanged( EnumMapUI.Type_VR );
if ( i == MapAutoApi.MAP_STYLE_DAY
|| i == MapAutoApi.MAP_STYLE_DAY_NAV ) {
mCurrentUI = EnumMapUI.Type_Light;
} else if ( i == MapAutoApi.MAP_STYLE_NIGHT
|| i == MapAutoApi.MAP_STYLE_NIGHT_NAV ) {
mCurrentUI = EnumMapUI.Type_Night;
} else if ( i == MapAutoApi.MAP_STYLE_VR ) {
mCurrentUI = EnumMapUI.Type_VR;
} else if ( i == MapAutoApi.MAP_PERSPECTIVE_2D ) {
mCurrentUI = EnumMapUI.CarUp_2D;
} else if ( i == MapAutoApi.MAP_PERSPECTIVE_3D ) {
mCurrentUI = EnumMapUI.CarUp_3D;
}
if ( mCurrentUI != null ) {
UiThreadHandler.post( () -> {
try {
MogoMapListenerHandler.getInstance().onMapModeChanged( mCurrentUI );
} catch ( Exception e ) {
e.printStackTrace();
}
} );
}
}
}

View File

@@ -91,7 +91,7 @@ class CustomMapApiBuilder implements IMogoMapApiBuilder {
@Override
public IMogoMapView getMapView( Context context ) {
NavAutoApi.INSTANCE.init( context, MapParams.Companion.init()
.setDebugMode( false )
.setDebugMode( true )
.setCoordinateType( MapParams.COORDINATETYPE_GCJ02 )
.setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D )
.setZoom( 16 )

View File

@@ -2,32 +2,44 @@ package com.mogo.map.impl.custom.marker;
import android.view.View;
import com.mogo.map.impl.custom.AMapMarkerClickHandler;
import com.mogo.map.marker.IMogoInfoWindowAdapter;
import com.mogo.map.marker.IMogoMarker;
import com.zhidaoauto.map.sdk.open.abs.marker.InfoWindowAdapter;
import com.zhidaoauto.map.sdk.open.marker.Marker;
import com.zhidaoauto.map.sdk.open.marker.OnInfoWindowClickListener;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.FileInputStream;
/**
* @author congtaowang
* @since 2019-12-24
* <p>
* 自定义infowindow
*/
public final class AMapInfoWindowAdapter implements InfoWindowAdapter {
public final class AMapInfoWindowAdapter implements InfoWindowAdapter, OnInfoWindowClickListener {
public View getInfoWindow( Marker marker ) {
if ( marker.getMObject() instanceof IMogoMarker ) {
IMogoMarker mogoMarker = ( ( IMogoMarker ) marker.getMObject() );
IMogoInfoWindowAdapter delegate = mogoMarker.getInfoWindowAdapter();
if ( delegate != null ) {
return delegate.getInfoWindow( mogoMarker );
final View infoView = delegate.getInfoWindow( mogoMarker );
marker.setOnInfoWindowClickListener( this );
return infoView;
}
}
return null;
}
@Override
public void onInfoWindowClick( @NotNull Marker marker ) {
AMapMarkerClickHandler.getInstance().handleMarkerClicked( marker );
}
@Nullable
@Override
public View getInfoContents(@Nullable Marker marker) {

View File

@@ -77,7 +77,6 @@ public class ObjectUtils {
// .icons( descriptors )
// .period( opt.getPeriod() )
.rotateAngle( opt.getRotate() )
.marker3DIcon( opt.getIcon3DRes() )
.setFlat( opt.isFlat() )
.visible( opt.isVisible() )
.infoWindowEnable( opt.isInifoWindowEnable() )
@@ -86,6 +85,9 @@ public class ObjectUtils {
// .draggable( opt.isDraggable() )
.setInfoWindowOffset( opt.getOffsetX(), opt.getOffsetY() )
.zIndex( opt.getzIndex() );
if ( opt.getIcon3DRes() != 0 ) {
markerOptions.marker3DIcon( opt.getIcon3DRes() );
}
if ( !TextUtils.isEmpty( opt.getTitle() ) ) {
markerOptions.title( opt.getTitle() );
}
@@ -699,7 +701,7 @@ public class ObjectUtils {
target.setLonLatPoints( points );
}
target.setLineWidth( options.getWidth() );
target.setColor( options.getColor());
target.setColor( options.getColor() );
// target.zIndex( options.getWidth() );
// target.visible( options.isVisible() );
//// target.geodesic( options.isGeodesic() );

View File

@@ -60,10 +60,14 @@ class MarkerDrawer {
}
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, int zIndex, IMogoMarkerClickListener listener ) {
return drawMapMarkerImpl(markerShowEntity, zIndex, 0, listener);
}
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, int zIndex, int icon3DRes, 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() );
MogoMarkerOptions options = new MogoMarkerOptions().icon3DRes( icon3DRes ).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 {

View File

@@ -8,6 +8,7 @@ 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.R;
import com.mogo.module.common.entity.MarkerCarPois;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerOnlineCar;
@@ -104,7 +105,7 @@ class OnlineCarDrawer {
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 );
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_LOW, R.raw.taxi, listener );
}
if ( mogoMarker != null ) {
mogoMarker.setVisible( true );

View File

@@ -9,6 +9,7 @@ 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.drawer.marker.RoadConditionInfoWindow3DAdapter;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerShowEntity;
@@ -84,10 +85,16 @@ class RoadConditionDrawer {
if ( mogoMarker == null || mogoMarker.isDestroyed() ) {
Logger.d( TAG, "draw road condition, sn = %s", sn );
try {
if ( DebugConfig.isRoadEventAnimated() ) {
post2AddAndStartAnimation( markerShowEntity, i * 100L, listener );
} else {
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener );
mogoMarker.setInfoWindowAdapter( new RoadConditionInfoWindow3DAdapter( markerShowEntity, AbsMogoApplication.getApp(), mogoMarker.getMogoMarkerOptions() ) );
mogoMarker.showInfoWindow();
} else {
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();

View File

@@ -0,0 +1,46 @@
package com.mogo.module.common.drawer.marker;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.Nullable;
import com.mogo.map.marker.IMogoMarker;
public
/**
* @author congtaowang
* @since 2020/12/16
*
* 描述
*/
class EmptyMarkerView extends View implements IMarkerView {
public EmptyMarkerView( Context context ) {
this( context, null );
}
public EmptyMarkerView( Context context, @Nullable AttributeSet attrs ) {
this( context, attrs, 0 );
}
public EmptyMarkerView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
super( context, attrs, defStyleAttr );
}
@Override
public View getView() {
return this;
}
@Override
public void setMarker( IMogoMarker marker ) {
}
@Override
protected void onMeasure( int widthMeasureSpec, int heightMeasureSpec ) {
setMeasuredDimension( 1, 1 );
}
}

View File

@@ -5,6 +5,7 @@ import android.text.TextUtils;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.ModuleNames;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.entity.MarkerShowEntity;
/**
@@ -23,17 +24,36 @@ public class MapMarkerAdapter {
* @param markerShowEntity 要填充的数据
* @return MarkerView
*/
public static IMarkerView getMarkerView(Context context, MarkerShowEntity markerShowEntity, MogoMarkerOptions options) {
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);
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
return new EmptyMarkerView( context );
} else {
return new MapMarkerView(context, markerShowEntity, options);
if ( markerShowEntity.isChecked() ) {
return new MapMarkerInfoView( context, markerShowEntity, options );
} else {
return new MapMarkerView( context, markerShowEntity, options );
}
}
}
}
/**
* 获取 MarkerShowEntity 填充好的 MarkerView
*
* @param context 上下文
* @param markerShowEntity 要填充的数据
* @return MarkerView
*/
public static IMarkerView getMarkerInfoWindowView( Context context, MarkerShowEntity markerShowEntity, MogoMarkerOptions options ) {
if ( markerShowEntity.isChecked() ) {
return new MapMarkerInfoView( context, markerShowEntity, options );
} else {
return new MapMarkerView( context, markerShowEntity, options );
}
}
}

View File

@@ -13,6 +13,7 @@ import androidx.constraintlayout.widget.ConstraintLayout;
import com.mogo.map.marker.MogoMarkerOptions;
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.MarkerShareMusic;
import com.mogo.module.common.entity.MarkerShowEntity;
@@ -71,7 +72,11 @@ public class MapMarkerInfoView extends MapMarkerBaseView {
Object bindObj = markerShowEntity.getBindObj();
ivCar.setImageResource( R.drawable.icon_map_marker_location_yellow );
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
ivCar.setImageResource( R.drawable.icon_map_marker_location_yellow_vr );
} else {
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() ) {

View File

@@ -0,0 +1,37 @@
package com.mogo.module.common.drawer.marker;
import android.content.Context;
import android.view.View;
import com.mogo.map.marker.IMogoInfoWindowAdapter;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.entity.MarkerShowEntity;
public
/**
* @author congtaowang
* @since 2020/12/15
*
* 描述
*/
class RoadConditionInfoWindow3DAdapter implements IMogoInfoWindowAdapter {
private MarkerShowEntity mEntity;
private Context mContext;
private MogoMarkerOptions mOptions;
public RoadConditionInfoWindow3DAdapter( MarkerShowEntity entity,
Context context,
MogoMarkerOptions options ) {
this.mEntity = entity;
this.mContext = context;
this.mOptions = options;
}
@Override
public View getInfoWindow( IMogoMarker marker ) {
IMarkerView creator = MapMarkerAdapter.getMarkerInfoWindowView( mContext, mEntity, mOptions );
return creator.getView();
}
}

Binary file not shown.

View File

@@ -432,17 +432,13 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
tvEnterVrMode = findViewById(R.id.module_ext_enter_vr_mode);
tvEnterVrMode.setOnClickListener((v)->{
// 进入vr模式
enterVrMode();
mApis.getStatusManagerApi().setVrMode(TAG, true);
// mApis.getMapFrameControllerApi().changeToVRMode();
mMApUIController.changeMapMode( EnumMapUI.Type_VR );
});
tvExitVrMode = findViewById(R.id.module_ext_exit_vr_mode);
tvExitVrMode.setOnClickListener((v)->{
// 退出vr模式
exitVrMode();
mApis.getStatusManagerApi().setVrMode(TAG, false);
// mApis.getMapFrameControllerApi().changeTo2dMode();
mMApUIController.changeMapMode( EnumMapUI.CarUp_2D );
});
dealWeatherContainer();
@@ -497,8 +493,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
mCameraLiveNoticeHelper.enterVrMode();
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoLocationListener(TAG,this);
mMApUIController.changeMapMode( EnumMapUI.Type_VR );
}
private void exitVrMode(){
@@ -518,8 +512,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
mCameraLiveNoticeHelper.exitVrMode();
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoLocationListener(TAG);
mMApUIController.changeMapMode( EnumMapUI.CarUp_2D );
}
private void debugCrashWarn(){

View File

@@ -89,7 +89,9 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener<M
mMogoMarker = ExtensionServiceManager.getMapService().getMarkerManager(mContext)
.addMarker(PushDataType.TYPE_PUSH_CAMERA_DATA, options);
mMogoMarker.setOwner(PushDataType.TYPE_PUSH_CAMERA_DATA);
if (mMogoMarker != null) {
mMogoMarker.setOwner(PushDataType.TYPE_PUSH_CAMERA_DATA);
}
}
private void removeCameraMarker() {
@@ -117,13 +119,13 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener<M
*/
@Override
public void onMsgReceived(MogoSnapshotSetData obj) {
// Logger.d(TAG, "onMsgReceived cameralive : " + obj);
Logger.d(TAG, "onMsgReceived cameralive : " + obj);
if (obj != null) { //如果多个点,如何处理,点击的时候
mCloudRoadData = obj.getCamera();
if (mCloudRoadData != null) {
Log.d(TAG, "onMsgReceived getRtmpUrl = " + mCloudRoadData.getRtmpUrl());
// Log.d(TAG, "mCurrentlat = " + mCurrentlat + "--mCurrentlon = " +mCurrentlon);
// Log.d(TAG, "mCloudRoadData.getLat() = " + mCloudRoadData.getLat() + "--mCloudRoadData.getLon() = " + mCloudRoadData.getLon());
Log.d(TAG, "mCurrentlat = " + mCurrentlat + "--mCurrentlon = " +mCurrentlon);
Log.d(TAG, "mCloudRoadData.getLat() = " + mCloudRoadData.getLat() + "--mCloudRoadData.getLon() = " + mCloudRoadData.getLon());
if (mCurrentlat == mCloudRoadData.getLat() && mCurrentlon == mCloudRoadData.getLon()) {
//TODO
} else {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -33,6 +33,7 @@ import com.mogo.map.navi.MogoCongestionInfo;
import com.mogo.map.navi.MogoTraffic;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.MogoModule;
import com.mogo.module.common.MogoModulePaths;
import com.mogo.module.common.entity.MarkerResponse;
@@ -938,9 +939,13 @@ public class MogoServices implements IMogoMapListener,
@Override
public void onMapModeChanged( EnumMapUI ui ) {
if ( ui == EnumMapUI.Type_VR ) {
MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode( TAG, true );
MapCenterPointStrategy.resetByChangeMode();
MapMarkerManager.getInstance().redrawMarkerByStyleChanged();
} else {
MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode( TAG, false );
MapCenterPointStrategy.resetByChangeMode();
MapMarkerManager.getInstance().redrawMarkerByStyleChanged();
}
}
}

View File

@@ -262,7 +262,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
MarkerShowEntity markerShowEntity = ( MarkerShowEntity ) object;
markerShowEntity.setChecked( true );
IMarkerView markerView = MapMarkerAdapter.getMarkerView( mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions() );
markerView.setMarker(mogoMarker);
markerView.setMarker( mogoMarker );
if ( markerView instanceof OnlineCarMarkerView ) {
try {
mogoMarker.setIcon( markerView.getBitmap( ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getCarInfo().getVehicleType() ) );
@@ -270,7 +270,12 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
mogoMarker.setIcon( markerView.getBitmap( 0 ) );
}
} else {
mogoMarker.setIcon( ViewUtils.fromView( markerView.getView() ) );
if ( MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode() ) {
mogoMarker.hideInfoWindow();
mogoMarker.showInfoWindow();
} else {
mogoMarker.setIcon( ViewUtils.fromView( markerView.getView() ) );
}
}
mogoMarker.setToTop();
}
@@ -309,7 +314,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
MarkerShowEntity markerShowEntity = ( MarkerShowEntity ) object;
markerShowEntity.setChecked( false );
IMarkerView markerView = MapMarkerAdapter.getMarkerView( mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions() );
markerView.setMarker(mogoMarker);
markerView.setMarker( mogoMarker );
if ( markerView instanceof OnlineCarMarkerView ) {
try {
mogoMarker.setIcon( markerView.getBitmap( ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getCarInfo().getVehicleType() ) );
@@ -317,7 +322,12 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
mogoMarker.setIcon( markerView.getBitmap( 0 ) );
}
} else {
mogoMarker.setIcon( ViewUtils.fromView( markerView.getView() ) );
if ( MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode() ) {
mogoMarker.hideInfoWindow();
mogoMarker.showInfoWindow();
} else {
mogoMarker.setIcon( ViewUtils.fromView( markerView.getView() ) );
}
}
}
}
@@ -693,19 +703,23 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
// if ( !AppUtils.isAppForeground( mContext ) ) {
// return;
// }
if ( mLastDataResult != null ) {
runOnTargetThread( () -> {
MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_ROAD_CONDITION );
drawMarkerByCurrentType( mLastDataResult );
mLastCheckMarker = null;
} );
}
redrawMarkerByStyleChanged();
break;
}
}
public void onCloseCurrentSelectedMarker(){
if ( mLastCheckMarker != null && !mLastCheckMarker.isDestroyed()) {
public void redrawMarkerByStyleChanged() {
if ( mLastDataResult != null ) {
runOnTargetThread( () -> {
MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_ROAD_CONDITION );
drawMarkerByCurrentType( mLastDataResult );
mLastCheckMarker = null;
} );
}
}
public void onCloseCurrentSelectedMarker() {
if ( mLastCheckMarker != null && !mLastCheckMarker.isDestroyed() ) {
closeMarker( mLastCheckMarker );
mLastCheckMarker = null;
}

View File

@@ -3,14 +3,13 @@ package com.mogo.module.small.map;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.RotateAnimation;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import com.mogo.module.common.view.RoundLayout;
import com.mogo.module.small.map.animation.DirectionRotateAnimation;
/**
* 小地图的方向View
@@ -21,6 +20,8 @@ import com.mogo.module.common.view.RoundLayout;
public class SmallMapDirectionView extends RoundLayout {
private ImageView mIvMapBorder;
private DirectionRotateAnimation mRotateAnimation;
private int lastAngle = 0;
public SmallMapDirectionView(Context context) {
this(context, null);
@@ -38,6 +39,7 @@ public class SmallMapDirectionView extends RoundLayout {
private void initView(Context context) {
LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this);
mIvMapBorder = findViewById(R.id.ivMapBorder);
mRotateAnimation = new DirectionRotateAnimation(context, null);
}
@@ -47,18 +49,25 @@ public class SmallMapDirectionView extends RoundLayout {
* @param angle 角度 0 - 359度旋转,相对于自身中心位置
*/
public void changeAngle(int angle) {
Animation mRotateAnimation = new RotateAnimation(
0, angle,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
int tempAngle = angle;
if (angle <= 180) {
tempAngle = angle;
} else {
tempAngle = -(360 - tempAngle);
}
mRotateAnimation.setFromDegrees(lastAngle);
mRotateAnimation.setToDegrees(tempAngle);
//设置线性插值,可以解决旋转一圈后卡顿问题
mRotateAnimation.setInterpolator(new DecelerateInterpolator());
mRotateAnimation.setInterpolator(new LinearInterpolator());
//设置旋转一圈时间
mRotateAnimation.setDuration(1000);
mRotateAnimation.setDuration(300);
//控件动画结束时是否保持动画最后的状态
mRotateAnimation.setFillAfter(true);
mIvMapBorder.startAnimation(mRotateAnimation);
// 刷新最后一次角度
lastAngle = tempAngle;
}
}

View File

@@ -15,6 +15,8 @@ import com.mogo.module.common.machinevision.IMachineVisionInterface;
import com.mogo.module.common.wm.WindowManagerView;
import com.mogo.utils.logger.Logger;
import java.util.Random;
/**
* @author donghongyu
* @date 12/10/20 1:35 PM
@@ -90,7 +92,8 @@ public class SmallMapService extends Service {
mSmallMapDirectionView.postDelayed(new Runnable() {
@Override
public void run() {
mSmallMapDirectionView.changeAngle(-60);
Random random = new Random();
mSmallMapDirectionView.changeAngle(random.nextInt(360));
}
}, 1000);

View File

@@ -0,0 +1,66 @@
package com.mogo.module.small.map.animation;
import android.content.Context;
import android.util.AttributeSet;
import android.view.animation.Animation;
import android.view.animation.Transformation;
/**
* 方向罗盘旋转动画
* @author donghongyu
* @date 12/14/20 7:46 PM
*/
public class DirectionRotateAnimation extends Animation {
private float mFromDegrees;
private float mToDegrees;
private int mPivotXType = Animation.RELATIVE_TO_SELF;
private int mPivotYType = Animation.RELATIVE_TO_SELF;
private float mPivotXValue = 0.5f;
private float mPivotYValue = 0.5f;
private float mPivotX;
private float mPivotY;
public DirectionRotateAnimation(Context context, AttributeSet attrs) {
super(context, attrs);
initializePivotPoint();
}
public void setFromDegrees(float fromDegrees) {
mFromDegrees = fromDegrees;
}
public void setToDegrees(float toDegrees) {
mToDegrees = toDegrees;
}
private void initializePivotPoint() {
if (mPivotXType == ABSOLUTE) {
mPivotX = mPivotXValue;
}
if (mPivotYType == ABSOLUTE) {
mPivotY = mPivotYValue;
}
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float degrees = mFromDegrees + ((mToDegrees - mFromDegrees) * interpolatedTime);
float scale = getScaleFactor();
if (mPivotX == 0.0f && mPivotY == 0.0f) {
t.getMatrix().setRotate(degrees);
} else {
t.getMatrix().setRotate(degrees, mPivotX * scale, mPivotY * scale);
}
}
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
mPivotX = resolveSize(mPivotXType, mPivotXValue, width, parentWidth);
mPivotY = resolveSize(mPivotYType, mPivotYValue, height, parentHeight);
}
}