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

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