@@ -63,7 +63,7 @@ public class ViewGroupMvpDelegateImpl<V extends MvpView, P extends MvpPresenter<
63
63
64
64
private boolean checkedActivityFinishing = false ;
65
65
private boolean presenterDetached = false ;
66
- private boolean presenterDestroeyed = false ;
66
+ private boolean presenterDestroyed = false ;
67
67
68
68
public ViewGroupMvpDelegateImpl (@ NonNull View view ,
69
69
@ NonNull ViewGroupDelegateCallback <V , P > delegateCallback ,
@@ -231,18 +231,18 @@ public void onRestoreInstanceState(Parcelable state) {
231
231
keepPresenterDuringScreenOrientationChange , activity );
232
232
233
233
if (destroyPermanently ) {
234
- destroyPresenterIfnotDoneYet ();
234
+ destroyPresenterIfNotDoneYet ();
235
235
} else if (!activity .isChangingConfigurations ()) {
236
236
// View removed manually from screen
237
- destroyPresenterIfnotDoneYet ();
237
+ destroyPresenterIfNotDoneYet ();
238
238
}
239
239
} // else --> see onActivityDestroyed()
240
240
}
241
241
242
242
@ Override public void onActivityDestroyed (Activity activity ) {
243
243
244
244
if (activity == this .activity ) {
245
- // The hosting activity of this view has been destroyed, so time to destoryed the presenter too?
245
+ // The hosting activity of this view has been destroyed, so time to destroy the presenter too?
246
246
247
247
activity .getApplication ().unregisterActivityLifecycleCallbacks (this );
248
248
checkedActivityFinishing = true ;
@@ -253,7 +253,7 @@ public void onRestoreInstanceState(Parcelable state) {
253
253
if (destroyedPermanently ) {
254
254
// Whole activity will be destroyed
255
255
detachPresenterIfNotDoneYet ();
256
- destroyPresenterIfnotDoneYet ();
256
+ destroyPresenterIfNotDoneYet ();
257
257
}
258
258
}
259
259
@@ -277,11 +277,13 @@ public void onRestoreInstanceState(Parcelable state) {
277
277
@ Override public void onActivitySaveInstanceState (Activity activity , Bundle outState ) {
278
278
}
279
279
280
- private void destroyPresenterIfnotDoneYet () {
281
- if (!presenterDestroeyed ) {
280
+ private void destroyPresenterIfNotDoneYet () {
281
+ if (!presenterDestroyed ) {
282
282
P presenter = delegateCallback .getPresenter ();
283
- presenter .destroy ();
284
- presenterDestroeyed = true ;
283
+ if (presenter != null ) {
284
+ presenter .destroy ();
285
+ }
286
+ presenterDestroyed = true ;
285
287
activity .getApplication ().unregisterActivityLifecycleCallbacks (this );
286
288
if (DEBUG ) {
287
289
Log .d (DEBUG_TAG , "Presenter destroyed: " + presenter );
@@ -298,7 +300,9 @@ private void destroyPresenterIfnotDoneYet() {
298
300
private void detachPresenterIfNotDoneYet () {
299
301
if (!presenterDetached ) {
300
302
P presenter = delegateCallback .getPresenter ();
301
- presenter .detachView ();
303
+ if (presenter != null ) {
304
+ presenter .detachView ();
305
+ }
302
306
presenterDetached = true ;
303
307
if (DEBUG ) {
304
308
Log .d (DEBUG_TAG ,
0 commit comments