解决内存泄漏2
This commit is contained in:
@@ -271,6 +271,7 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
|
||||
mediator?.detach()
|
||||
// 避免内存泄漏
|
||||
fragment = null
|
||||
mClPanelContainer = null
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ public class V2XScenarioHistoryFragment
|
||||
private RecyclerView mRecyclerView;
|
||||
private V2XScenarioHistoryAdapter mV2XScenarioHistoryAdapter;
|
||||
private ArrayList<V2XHistoryScenarioData> mV2XHistoryScenarioData = new ArrayList<>();
|
||||
private IMoGoV2XStatusChangedListener mListener;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -88,24 +89,25 @@ public class V2XScenarioHistoryFragment
|
||||
});
|
||||
|
||||
|
||||
mListener = new IMoGoV2XStatusChangedListener() {
|
||||
@Override
|
||||
public void onStatusChanged( V2XStatusDescriptor descriptor, boolean isTrue ) {
|
||||
Logger.d( TAG, descriptor + " initViews --------> " + isTrue );
|
||||
if ( descriptor == V2XStatusDescriptor.EventPanelWindow_UI ) {
|
||||
mPresenter.loadHistory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
Logger.d( TAG, "init --------> " );
|
||||
}
|
||||
};
|
||||
V2XServiceManager.getMoGoV2XStatusManager()
|
||||
.registerStatusChangedListener(
|
||||
TAG,
|
||||
V2XStatusDescriptor.EventPanelWindow_UI,
|
||||
new IMoGoV2XStatusChangedListener() {
|
||||
@Override
|
||||
public void onStatusChanged(V2XStatusDescriptor descriptor, boolean isTrue) {
|
||||
Logger.d(TAG, descriptor + " initViews --------> " + isTrue);
|
||||
if (descriptor == V2XStatusDescriptor.EventPanelWindow_UI) {
|
||||
mPresenter.loadHistory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
Logger.d(TAG, "init --------> ");
|
||||
}
|
||||
});
|
||||
mListener );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,4 +182,13 @@ public class V2XScenarioHistoryFragment
|
||||
protected ScenarioHistoryPresenter createPresenter() {
|
||||
return new ScenarioHistoryPresenter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
V2XServiceManager.getMoGoV2XStatusManager().unregisterStatusChangedListener( TAG,
|
||||
V2XStatusDescriptor.EventPanelWindow_UI,
|
||||
mListener
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user