1. 解决app列表内存泄漏问题

2. 独立APP在onPause时不关闭adas算法
3. 解决npe问题
This commit is contained in:
wangcongtao
2020-09-09 10:05:25 +08:00
parent cf2460b54e
commit d4d0399b27
10 changed files with 49 additions and 15 deletions

View File

@@ -160,7 +160,7 @@ targetSdkVersion : 22,
gpssimulatornoop : "com.mogo.module:module-gps-simulator-noop:${MOGO_MODULE_GPS_SIMULATOR_NOOP_VERSION}",
adasapi : "com.zhidao.autopilot.support:adas:1.0.1",
adasconfigapi : "com.zhidao.adasconfig:adasconfig:1.0.9",
adasconfigapi : "com.zhidao.adasconfig:adasconfig:1.1.4",
// 个人中心的SDK
personalsdk : "com.zhidaoauto.person.info:data:1.0.1",

View File

@@ -185,6 +185,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
aMap.setOnCameraChangeListener( this );
aMap.setOnMyLocationChangeListener( this );
}
AMapMessageManager.getInstance().clear();
AMapMessageManager.getInstance().registerAMapMessageListener( this );
}

View File

@@ -70,6 +70,8 @@ public class AMapViewWrapper implements IMogoMapView,
AMap.OnCameraChangeListener,
AMap.OnMyLocationChangeListener {
private static boolean sIsCreated = false;
private static final String TAG = "AMapViewWrapper";
private final MapView mMapView;
@@ -200,6 +202,13 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void onCreate( Bundle bundle ) {
if ( sIsCreated ) {
initMapView();
initListeners();
initMyLocation();
return;
}
sIsCreated = true;
if ( mMapView != null ) {
mMapView.onCreate( bundle );
Logger.d( TAG, "map onCreate" );
@@ -227,6 +236,7 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void onDestroy() {
sIsCreated = false;
if ( mMapView != null ) {
mMapView.onDestroy();
Logger.d( TAG, "map onDestroy" );
@@ -362,6 +372,8 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.getMap().moveCamera( CameraUpdateFactory.changeTilt( 60 ) );
break;
case NorthUP_2D:
mMapView.getMap().moveCamera( CameraUpdateFactory.changeTilt( 0 ) );
break;
case CarUp_2D:
mMapView.getMap().moveCamera( CameraUpdateFactory.changeTilt( 0 ) );
break;

View File

@@ -47,6 +47,12 @@ public class AMapMessageManager {
}
}
public synchronized void clear(){
if ( mListeners != null ) {
mListeners.clear();
}
}
public synchronized void unregisterAMapMessageListener( AMapMessageListener listener ) {
mListeners.remove( listener );
}

View File

@@ -65,7 +65,7 @@ public class MainIndependentActivity extends MainActivity {
@Override
protected void onPause() {
super.onPause();
mServiceApis.getAdasControllerApi().setUseAlgorithm( false );
mServiceApis.getAdasControllerApi().setUseAlgorithm( true );
}
@Override

View File

@@ -14,21 +14,24 @@ public class AppsListChangedLiveData extends MutableLiveData {
private Observer mObserver;
private AppsListChangedLiveData(){
// private constructor
}
private static volatile AppsListChangedLiveData sInstance;
private static final class InstanceHolder{
private static final AppsListChangedLiveData INSTANCE = new AppsListChangedLiveData();
}
private AppsListChangedLiveData(){}
public static AppsListChangedLiveData getInstance(){
return InstanceHolder.INSTANCE;
if( sInstance == null ){
synchronized( AppsListChangedLiveData.class ) {
if( sInstance == null ){
sInstance = new AppsListChangedLiveData();
}
}
}
return sInstance;
}
private Object readResolve(){
// 阻止反序列化,必须实现 Serializable 接口
return InstanceHolder.INSTANCE;
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
@Override
@@ -37,7 +40,9 @@ public class AppsListChangedLiveData extends MutableLiveData {
mObserver = observer;
}
public void release(){
public synchronized void release(){
removeObserver( mObserver );
mObserver = null;
sInstance = null;
}
}

View File

@@ -216,6 +216,12 @@ public class AppsPresenter extends Presenter< AppsView > {
AppsListChangedLiveData.getInstance().release();
mView = null;
mLauncher.destroy();
` mAnalytics = null;
mCardManager = null;
if ( mLauncher != null ) {
mLauncher.destroy();
}
mLauncher = null;
}
public void exit() {

View File

@@ -103,6 +103,7 @@ public class InternalFunctionLauncher extends BaseAppLauncher {
public void destroy() {
if ( getNext() != null ) {
getNext().destroy();
setNext( null );
}
}
}

View File

@@ -36,7 +36,7 @@ public class AppsModel {
private Map< Integer, List< AppInfo > > mPagedApps = new HashMap<>();
private AppsModel( Context context ) {
mContext = context;
mContext = context.getApplicationContext();
}
public static AppsModel getInstance( Context context ) {

View File

@@ -703,7 +703,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
} );
}
public void onSyncMarkerResponse(MarkerResponse response){
public void onSyncMarkerResponse( MarkerResponse response ) {
if ( ignoreDrawRequest() ) {
return;
}
@@ -862,6 +862,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
// 平滑移动
private void startSmooth( IMogoMarker iMogoMarker, MarkerOnlineCar markerOnlineCar,
MarkerLocation markerLocation ) {
if ( iMogoMarker == null ) {
return;
}
List< MarkerCarPois > poiList = markerOnlineCar.getPois();
if ( filterErrorPoint( poiList ) ) {
return;