Skip to content

Commit

Permalink
Fix #20, clear the view reference in AbstractPresenter#onViewDetached
Browse files Browse the repository at this point in the history
  • Loading branch information
Saeed Masoumi committed Jan 11, 2017
1 parent 7c202c0 commit 5555437
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions easymvp-api/src/main/java/easymvp/AbstractPresenter.java
Expand Up @@ -21,6 +21,7 @@ public void onViewAttached(V view) {

@Override
public void onViewDetached() {
this.view.clear();
}

@Override
Expand Down
Expand Up @@ -10,6 +10,7 @@
import easymvp.annotation.ActivityView;
import easymvp.annotation.Presenter;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
Expand Down Expand Up @@ -41,6 +42,7 @@ protected void onStart() {
protected void onStop() {
super.onStop();
assertTrue(testPresenter.isOnViewDetachedCalled());
assertFalse(testPresenter.isViewAttached());
}

@Override
Expand Down
Expand Up @@ -7,6 +7,7 @@
import easymvp.annotation.ActivityView;
import easymvp.annotation.Presenter;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
Expand Down Expand Up @@ -38,6 +39,7 @@ protected void onStart() {
protected void onStop() {
super.onStop();
assertTrue(testPresenter.isOnViewDetachedCalled());
assertFalse(testPresenter.isViewAttached());
}

@Override
Expand Down
Expand Up @@ -7,6 +7,7 @@
import easymvp.annotation.ActivityView;
import easymvp.annotation.Presenter;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
Expand Down Expand Up @@ -37,6 +38,7 @@ protected void onStart() {
protected void onStop() {
super.onStop();
assertTrue(testPresenter.isOnViewDetachedCalled());
assertFalse(testPresenter.isViewAttached());
}

@Override
Expand Down
Expand Up @@ -10,6 +10,7 @@
import easymvp.annotation.FragmentView;
import easymvp.annotation.Presenter;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
Expand Down Expand Up @@ -41,6 +42,7 @@ public void onResume() {
public void onPause() {
super.onPause();
assertTrue(testPresenter.isOnViewDetachedCalled());
assertFalse(testPresenter.isViewAttached());
}

@Override
Expand Down

0 comments on commit 5555437

Please sign in to comment.