修复M3无法启动问题

This commit is contained in:
wangcongtao
2021-01-06 16:55:08 +08:00
parent 1f5b8413c2
commit e3a8e56337
6 changed files with 75 additions and 48 deletions

View File

@@ -239,7 +239,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
public void onDestroy() {
if ( mMapView != null ) {
mMapView.onDestroy();
AMapUIController.getInstance().release();
AMapUIController.release();
AMapWrapper.release();
Logger.d( TAG, "map onDestroy" );
}

View File

@@ -47,11 +47,16 @@ public class AMapUIController implements IMogoMapUIController {
}
public void initClient(IMogoMapUIController client) {
Logger.d( "whatthefuck-AMapUIController", "init %s", this );
this.mClient = client;
}
public synchronized void release() {
public synchronized void destroy(){
mClient = null;
}
public static synchronized void release() {
sInstance.destroy();
sInstance = null;
}
@@ -80,6 +85,7 @@ public class AMapUIController implements IMogoMapUIController {
@Override
public void changeMapMode(EnumMapUI mode) {
Logger.d( "whatthefuck-AMapUIController", "%s", this );
if (mClient != null) {
mClient.changeMapMode(mode);
}

View File

@@ -17,7 +17,9 @@ class MogoMapApi {
public static IMogoMapApiBuilder getApiBuilder() {
if ( sApiBuilder == null ) {
synchronized ( AutoNaviClient.class ) {
sApiBuilder = ARouter.getInstance().navigation( IMogoMapApiBuilder.class );
if ( sApiBuilder == null ) {
sApiBuilder = ARouter.getInstance().navigation( IMogoMapApiBuilder.class );
}
}
}
return sApiBuilder;

View File

@@ -250,4 +250,8 @@ public interface IMogoMapUIController {
default void rtkEnable( boolean enable ) {
}
default void destroy(){
}
}

View File

@@ -23,7 +23,7 @@ import java.util.List;
* 描述
*/
public class MogoMapUIController implements IMogoMapUIController {
private static final String TAG = "MogoMapUIController";
private IMogoMapUIController mDelegate;
@@ -31,13 +31,13 @@ public class MogoMapUIController implements IMogoMapUIController {
private static volatile MogoMapUIController sInstance;
private MogoMapUIController() {
mDelegate = MogoMapDelegateFactory.getMapUIControllerDelegate();
initDelegate();
}
public static MogoMapUIController getInstance() {
if (sInstance == null) {
synchronized (MogoMapUIController.class) {
if (sInstance == null) {
if ( sInstance == null ) {
synchronized ( MogoMapUIController.class ) {
if ( sInstance == null ) {
sInstance = new MogoMapUIController();
}
}
@@ -49,53 +49,54 @@ public class MogoMapUIController implements IMogoMapUIController {
this.mDelegate = mDelegate;
}
public synchronized void release() {
public static synchronized void release() {
sInstance = null;
}
@Override
public void setTrafficEnabled(boolean visible) {
if (mDelegate != null) {
mDelegate.setTrafficEnabled(visible);
public void setTrafficEnabled( boolean visible ) {
if ( mDelegate != null ) {
mDelegate.setTrafficEnabled( visible );
}
}
@Override
public MapControlResult changeZoom( boolean zoom) {
if (mDelegate != null) {
return mDelegate.changeZoom(zoom);
public MapControlResult changeZoom( boolean zoom ) {
if ( mDelegate != null ) {
return mDelegate.changeZoom( zoom );
}
return MapControlResult.ERROR;
}
@Override
public MapControlResult changeZoom(float zoom) {
if (mDelegate != null) {
return mDelegate.changeZoom(zoom);
public MapControlResult changeZoom( float zoom ) {
if ( mDelegate != null ) {
return mDelegate.changeZoom( zoom );
}
return MapControlResult.ERROR;
}
@Override
public void changeMapMode(EnumMapUI mode) {
if (mDelegate != null) {
public void changeMapMode( EnumMapUI mode ) {
if ( mDelegate != null ) {
Logger.d( "whatthefuck-MogoMapUIController", "%s", this );
Logger.d( TAG, "set type: %s", mode.name() );
mDelegate.changeMapMode(mode);
mDelegate.changeMapMode( mode );
}
}
@Override
public void moveToCenter(MogoLatLng latLng, boolean animate) {
if (mDelegate != null) {
mDelegate.moveToCenter(latLng, animate);
public void moveToCenter( MogoLatLng latLng, boolean animate ) {
if ( mDelegate != null ) {
mDelegate.moveToCenter( latLng, animate );
}
}
@Override
public void showMyLocation(boolean visible) {
if (mDelegate != null) {
mDelegate.showMyLocation(visible);
public void showMyLocation( boolean visible ) {
if ( mDelegate != null ) {
mDelegate.showMyLocation( visible );
}
}
@@ -115,7 +116,7 @@ public class MogoMapUIController implements IMogoMapUIController {
@Override
public void recoverLockMode() {
if (mDelegate != null) {
if ( mDelegate != null ) {
mDelegate.recoverLockMode();
}
}
@@ -128,22 +129,22 @@ public class MogoMapUIController implements IMogoMapUIController {
}
@Override
public void setLockZoom(int var1) {
if (mDelegate != null) {
mDelegate.setLockZoom(var1);
public void setLockZoom( int var1 ) {
if ( mDelegate != null ) {
mDelegate.setLockZoom( var1 );
}
}
@Override
public void displayOverview( Rect bounds ) {
if (mDelegate != null) {
mDelegate.displayOverview(bounds);
if ( mDelegate != null ) {
mDelegate.displayOverview( bounds );
}
}
@Override
public float getScalePerPixel() {
if (mDelegate != null) {
if ( mDelegate != null ) {
return mDelegate.getScalePerPixel();
}
return 0;
@@ -151,7 +152,7 @@ public class MogoMapUIController implements IMogoMapUIController {
@Override
public float getZoomLevel() {
if (mDelegate != null) {
if ( mDelegate != null ) {
return mDelegate.getZoomLevel();
}
return 0;
@@ -159,7 +160,7 @@ public class MogoMapUIController implements IMogoMapUIController {
@Override
public MogoLatLng getCameraNorthEastPosition() {
if (mDelegate != null) {
if ( mDelegate != null ) {
return mDelegate.getCameraNorthEastPosition();
}
return null;
@@ -167,38 +168,39 @@ public class MogoMapUIController implements IMogoMapUIController {
@Override
public MogoLatLng getCameraSouthWestPosition() {
if (mDelegate != null) {
if ( mDelegate != null ) {
return mDelegate.getCameraSouthWestPosition();
}
return null;
}
@Override public MogoLatLng getWindowCenterLocation() {
if (mDelegate != null) {
@Override
public MogoLatLng getWindowCenterLocation() {
if ( mDelegate != null ) {
return mDelegate.getWindowCenterLocation();
}
return null;
}
@Override
public void setPointToCenter(double mapCenterX, double mapCenterY) {
if (mDelegate != null) {
mDelegate.setPointToCenter(mapCenterX, mapCenterY);
public void setPointToCenter( double mapCenterX, double mapCenterY ) {
if ( mDelegate != null ) {
mDelegate.setPointToCenter( mapCenterX, mapCenterY );
}
}
@Override
public Point getLocationPointInScreen( MogoLatLng latLng ) {
if (mDelegate != null) {
return mDelegate.getLocationPointInScreen(latLng);
if ( mDelegate != null ) {
return mDelegate.getLocationPointInScreen( latLng );
}
return null;
}
@Override
public MogoLatLng getLocationMogoLatLngInScreen(Point point) {
if (mDelegate != null) {
return mDelegate.getLocationMogoLatLngInScreen(point);
public MogoLatLng getLocationMogoLatLngInScreen( Point point ) {
if ( mDelegate != null ) {
return mDelegate.getLocationMogoLatLngInScreen( point );
}
return null;
}
@@ -218,7 +220,7 @@ public class MogoMapUIController implements IMogoMapUIController {
}
@Override
public void showBounds(String tag, MogoLatLng carPosition, List< MogoLatLng > lonLats, Rect bound, boolean lockCarPosition ) {
public void showBounds( String tag, MogoLatLng carPosition, List< MogoLatLng > lonLats, Rect bound, boolean lockCarPosition ) {
if ( mDelegate != null ) {
mDelegate.showBounds( tag, carPosition, lonLats, bound, lockCarPosition );
}
@@ -290,4 +292,16 @@ public class MogoMapUIController implements IMogoMapUIController {
mDelegate.rtkEnable( enable );
}
}
@Override
public void destroy() {
mDelegate = null;
release();
}
private void initDelegate() {
if ( mDelegate == null ) {
mDelegate = MogoMapDelegateFactory.getMapUIControllerDelegate();
}
}
}

View File

@@ -380,6 +380,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
mMogoFragmentManager.unregisterMainFragmentStackTransactionListener();
mMogoFragmentManager = null;
mServiceApis.getMapServiceApi().getMapViewInstanceHandler().destroy();
mServiceApis.getMapServiceApi().getMapUIController().destroy();
AdasConfigApiController.getInstance().release();
mServiceApis.getAdasControllerApi().release();
Logger.d( TAG, "destroy." );