opt
This commit is contained in:
@@ -70,7 +70,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
private IMogoMap mIMap;
|
||||
|
||||
private AMapMarkerClickHandler mMarkerClickHandler;
|
||||
private EnumMapUI mCurrentUIMode;
|
||||
private EnumMapUI mCurrentCarUIMode;
|
||||
|
||||
private boolean mIsCarLocked = false;
|
||||
private int mLockZoom = 16;
|
||||
@@ -87,6 +87,8 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
private EnumMapUI mCurrentUI;
|
||||
private boolean mIsLightStyle = false;
|
||||
private boolean mMapLoaded = false;
|
||||
private boolean mIsFirstLocated = true;
|
||||
private boolean mIsDelayed = false;
|
||||
|
||||
public AMapViewWrapper( MapAutoView mMapView ) {
|
||||
startTime = System.currentTimeMillis();
|
||||
@@ -218,8 +220,6 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
if ( mMapView != null ) {
|
||||
mMapView.onCreate( bundle );
|
||||
Logger.d( TAG, "map onCreate" );
|
||||
initMapView();
|
||||
initMyLocation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,6 +243,12 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
public void onDestroy() {
|
||||
if ( mMapView != null ) {
|
||||
mMapView.onDestroy();
|
||||
mMapView.setOnMarkClickListener( null );
|
||||
mMapView.setOnMapLoadedListener( null );
|
||||
mMapView.setOnMapTouchListener( null );
|
||||
mMapView.setOnMapClickListener( null );
|
||||
mMapView.getLocationClient().unRegisterListener( this );
|
||||
mMapView.setMOnCameraChangeListener( null );
|
||||
Logger.d( TAG, "map onDestroy" );
|
||||
}
|
||||
}
|
||||
@@ -315,6 +321,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
if ( ui == null ) {
|
||||
return;
|
||||
}
|
||||
Logger.d( TAG, "设置的样式 = %s", ui );
|
||||
if ( checkAMapView() ) {
|
||||
switch ( ui ) {
|
||||
case CarUp_2D:
|
||||
@@ -349,7 +356,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
}
|
||||
|
||||
private void setUIMode( EnumMapUI ui ) {
|
||||
this.mCurrentUIMode = ui;
|
||||
this.mCurrentCarUIMode = ui;
|
||||
if ( mMapView.getMapAutoViewHelper() != null ) {
|
||||
switch ( ui ) {
|
||||
case CarUp_2D:
|
||||
@@ -614,7 +621,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
|
||||
@Override
|
||||
public EnumMapUI getCurrentUiMode() {
|
||||
return mCurrentUIMode;
|
||||
return mCurrentCarUIMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -699,10 +706,21 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
|
||||
NaviClient.getInstance( getContext() ).syncCarLocation( sysLocation );
|
||||
if ( checkAMapView() && mMapLoaded ) {
|
||||
// 避免设置之后被其他初始化给重置为其他模式
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
// 地图初始化完成后,每隔5s自动判断当前地图的模式
|
||||
if ( mIsFirstLocated ) {
|
||||
if ( !mIsDelayed ) {
|
||||
mIsDelayed = true;
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
Logger.d( TAG, "倒计时结束" );
|
||||
mIsFirstLocated = false;
|
||||
}, 5_000L );
|
||||
}
|
||||
} else {
|
||||
mIsFirstLocated = true;
|
||||
mIsDelayed = false;
|
||||
Logger.d( TAG, "同步定位" );
|
||||
MapStyleController.getInstance().onLocationChanged( location, this );
|
||||
}, 5_000L );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -728,6 +746,8 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
cameraPosition.getBearing() );
|
||||
Trace.endSection();
|
||||
}
|
||||
initMapView();
|
||||
initMyLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -748,17 +768,17 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
|
||||
@Override
|
||||
public void onMapStatusChanged( int type, int value ) {
|
||||
Logger.i( TAG, "mapop--onMapStatusChanged-: " + type + "," + value );
|
||||
// Logger.i( TAG, "mapop--onMapStatusChanged-: " + type + "," + value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChange( int type, int value ) {
|
||||
Logger.i( TAG, "mapop--onCameraChange-: " + type + "," + value );
|
||||
// Logger.i( TAG, "mapop--onCameraChange-: " + type + "," + value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChangeFinish( @Nullable CameraPosition cameraPosition ) {
|
||||
Logger.i( TAG, "mapop--onCameraChangeFinish-: " + cameraPosition + "cost:" + ( System.currentTimeMillis() - startTime ) );
|
||||
// Logger.i( TAG, "mapop--onCameraChangeFinish-: " + cameraPosition + "cost:" + ( System.currentTimeMillis() - startTime ) );
|
||||
if ( cameraPosition != null ) {
|
||||
Trace.beginSection( "timer.onCameraChangeFinish" );
|
||||
MogoMapListenerHandler.getInstance().onMapChanged( ObjectUtils.fromAMap( cameraPosition.getTarget() ),
|
||||
@@ -784,6 +804,9 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
|
||||
}
|
||||
|
||||
//目前切换完vr之后,会立即回调其他样式,这里做一个判断
|
||||
private boolean mVrModeAutoChangedFlag = false;
|
||||
|
||||
@Override
|
||||
public void onChangeMapStyle( int i ) {
|
||||
|
||||
@@ -803,13 +826,22 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
mCurrentUI = EnumMapUI.CarUp_3D;
|
||||
}
|
||||
|
||||
if ( last == mCurrentUI ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// vr 模式切换到普通模式下,保持之前的白天模式 wtf.
|
||||
if ( last == EnumMapUI.Type_VR && mCurrentUI != last ) {
|
||||
if ( mIsLightStyle ) {
|
||||
changeMapMode( EnumMapUI.Type_Light );
|
||||
return;
|
||||
}
|
||||
if ( mVrModeAutoChangedFlag ) {
|
||||
mVrModeAutoChangedFlag = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
|
||||
if ( mCurrentUI != null ) {
|
||||
UiThreadHandler.post( () -> {
|
||||
try {
|
||||
@@ -831,19 +863,18 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
public void onStyleAutoChanged( boolean isVrMode ) {
|
||||
if ( isVrMode ) {
|
||||
if ( mCurrentUI != EnumMapUI.Type_VR ) {
|
||||
changeZoom( 20 );
|
||||
changeMapMode( EnumMapUI.Type_VR );
|
||||
Logger.d( TAG, "自动切换为vr模式" );
|
||||
mVrModeAutoChangedFlag = true;
|
||||
changeMapMode( EnumMapUI.Type_VR );
|
||||
}
|
||||
} else {
|
||||
if ( mCurrentUI == EnumMapUI.Type_VR ) {
|
||||
changeZoom( 16 );
|
||||
Logger.d( TAG, "自动切换为2D模式" );
|
||||
if ( mIsLightStyle ) {
|
||||
changeMapMode( EnumMapUI.Type_Light );
|
||||
} else {
|
||||
changeMapMode( EnumMapUI.Type_Night );
|
||||
}
|
||||
Logger.d( TAG, "自动切换为2D模式" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user