1. 独立app内存泄漏优化
This commit is contained in:
@@ -101,7 +101,7 @@ CRASHREPORT_NOOP_VERSION=2.0.0
|
||||
|
||||
######## 外部依赖引用
|
||||
# 车聊聊
|
||||
CARCHATTING_VERSION=1.8.6
|
||||
CARCHATTING_VERSION=1.8.7
|
||||
# 车聊聊接口
|
||||
CARCHATTINGPROVIDER_VERSION=1.4.1
|
||||
# loglib
|
||||
|
||||
@@ -86,6 +86,7 @@ public abstract class MogoBaseMapView extends FrameLayout implements ILifeCycle
|
||||
if ( mMapView != null ) {
|
||||
mMapView.onDestroy();
|
||||
}
|
||||
MogoMap.getInstance().clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,4 +46,9 @@ public class MogoMap {
|
||||
public IMogoMap getMogoMap() {
|
||||
return mMap;
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
mContext = null;
|
||||
mMap = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -604,6 +604,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
super.onDestroyView();
|
||||
isClickShare = false;
|
||||
TopViewAnimHelper.getInstance().removeAllView();
|
||||
TopViewAnimHelper.getInstance().clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -680,4 +680,20 @@ public class TopViewAnimHelper {
|
||||
hideNaviView();
|
||||
MapCenterPointStrategy.setMapCenterPointByScene(mogoMapUIController, Scene.AIMLESS);
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
topMotionLayout = null;
|
||||
remainTimeGroup = null;
|
||||
remainDistanceGroup = null;
|
||||
arriveTimeGroup = null;
|
||||
naviBg = null;
|
||||
ivTurnIcon = null;
|
||||
tvNextDistance = null;
|
||||
tvNextRoad = null;
|
||||
tvNextDistanceUnit = null;
|
||||
tvTurnInfo = null;
|
||||
topContainer = null;
|
||||
cameraMode = null;
|
||||
transition = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,6 +346,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mMogoMapService.getHostListenerRegister().unregisterMarkerClickListener();
|
||||
mMogoStatusManager.setMainPageLaunchedStatus( TAG, false );
|
||||
mMogoMapService = null;
|
||||
mMogoMapUIController = null;
|
||||
@@ -359,5 +360,8 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mServiceApis.getOnlineCarPanelApi().clear();
|
||||
ContextHolderUtil.releaseContext();
|
||||
MogoModulesManager.getInstance().onDestroy();
|
||||
SchemeIntent.getInstance().clear();
|
||||
FloatingViewHandler.clear();
|
||||
mServiceApis.getShareManager().releaseContext();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,16 +55,23 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
}
|
||||
}
|
||||
|
||||
private SchemeIntent() {
|
||||
// private constructor
|
||||
private static volatile SchemeIntent sInstance;
|
||||
|
||||
private SchemeIntent(){}
|
||||
|
||||
public static SchemeIntent getInstance(){
|
||||
if( sInstance == null ){
|
||||
synchronized( SchemeIntent.class ) {
|
||||
if( sInstance == null ){
|
||||
sInstance = new SchemeIntent();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
private static final SchemeIntent INSTANCE = new SchemeIntent();
|
||||
}
|
||||
|
||||
public static SchemeIntent getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
public synchronized void release(){
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
public void init( Context context, IMogoServiceApis apis ) {
|
||||
@@ -73,9 +80,11 @@ public class SchemeIntent implements IMogoStatusChangedListener {
|
||||
mApis.getStatusManagerApi().registerStatusChangedListener( TAG, StatusDescriptor.MAIN_PAGE_RESUME, this );
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
public void clear(){
|
||||
mApis.getStatusManagerApi().unregisterStatusChangedListener( TAG, StatusDescriptor.MAIN_PAGE_RESUME, this );
|
||||
mContext = null;
|
||||
mApis = null;
|
||||
|
||||
}
|
||||
|
||||
public void handle( Intent intent ) {
|
||||
|
||||
@@ -41,6 +41,10 @@ public class FloatingViewHandler {
|
||||
sFloatingLayout = frameLayout;
|
||||
}
|
||||
|
||||
public static void clear(){
|
||||
sFloatingLayout = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加任意view到布局,不考虑优先级
|
||||
*
|
||||
|
||||
@@ -67,7 +67,7 @@ class LauncherCardRefresher {
|
||||
public static final long ONE_MINUTE = 60 * 1000L;
|
||||
public static final long ONE_DAY = 24 * 60 * ONE_MINUTE;
|
||||
private String mLaunchTTSText;
|
||||
private long mDefaultTTSPlayInterval = 2 * ONE_MINUTE;
|
||||
private long mDefaultTTSPlayInterval = 60 * ONE_MINUTE;
|
||||
private LauncherCardAdvertisementData.LauncherCardAdvertisement mDefaultLauncherCardConfig;
|
||||
private List< LauncherCardAdvertisementData.LauncherCardAdvertisement > mAdvertisements;
|
||||
|
||||
@@ -156,7 +156,7 @@ class LauncherCardRefresher {
|
||||
private ZhidaoRefreshModel mZhidaoRefreshModel;
|
||||
|
||||
private LauncherCardRefreshStrategy mExplorerWayOrOnlineCarDataStrategy = new LauncherCardRefreshStrategy(
|
||||
1 * ONE_MINUTE, null, MSG_EXPLORER_WAY_OR_ONLINE_CAR_DATA
|
||||
40 * ONE_MINUTE, null, MSG_EXPLORER_WAY_OR_ONLINE_CAR_DATA
|
||||
);
|
||||
private LauncherCardRefreshStrategy mInduceStrategy = new LauncherCardRefreshStrategy(
|
||||
3 * ONE_MINUTE, mExplorerWayOrOnlineCarDataStrategy, MSG_INDUCE
|
||||
|
||||
@@ -131,6 +131,11 @@ public class ShareControl implements IMogoShareManager, IMogoIntentListener,
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseContext() {
|
||||
mContext = mContext.getApplicationContext();
|
||||
}
|
||||
|
||||
private void realShowDialog() {
|
||||
if (mShareDialog == null) {
|
||||
Logger.d(TAG, "realShowDialog context : " + mContext);
|
||||
|
||||
@@ -82,7 +82,7 @@ object SeekHelpManager {
|
||||
if(!isSeeking) {
|
||||
isSeeking = true
|
||||
if (this.context == null) {
|
||||
this.context = context
|
||||
this.context = context.applicationContext
|
||||
}
|
||||
aiAssist = AIAssist.getInstance(context)
|
||||
|
||||
|
||||
@@ -25,4 +25,6 @@ public interface IMogoShareManager extends IProvider {
|
||||
* @param context 待重置的上下文
|
||||
*/
|
||||
void resetContext(Context context);
|
||||
|
||||
void releaseContext();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ public class FragmentStack {
|
||||
private FragmentManager mFragmentManager;
|
||||
//private FragmentTransaction mFragmentTransaction;
|
||||
private int mContainerId;
|
||||
private Activity mActivity;
|
||||
private FragmentDescriptor mCurrentFragment;
|
||||
|
||||
private FragmentStackTransactionListener mFragmentStackTransactionListener;
|
||||
@@ -56,7 +55,6 @@ public class FragmentStack {
|
||||
}
|
||||
|
||||
public void init( AppCompatActivity activity, int containerId ) {
|
||||
mActivity = activity;
|
||||
mFragmentManager = activity.getSupportFragmentManager();
|
||||
mContainerId = containerId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user