Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use isFinishing instead of isChangingConfigurations #304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ private P createViewIdAndCreatePresenter() {
* @param keepPresenterInstance true, if the delegate has enabled keep
*/
static boolean retainPresenterInstance(boolean keepPresenterInstance, Activity activity) {
return keepPresenterInstance && (activity.isChangingConfigurations()
|| !activity.isFinishing());
return keepPresenterInstance && !activity.isFinishing();
}

@Override public void onStop() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ final public class PresenterManager {
}

@Override public void onActivityDestroyed(Activity activity) {
if (!activity.isChangingConfigurations()) {
if (activity.isFinishing()) {
// Activity will be destroyed permanently, so reset the cache
String activityId = activityIdMap.get(activity);
if (activityId != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public class PresenterManagerTest {
Activity activity = Mockito.mock(Activity.class);
Application application = Mockito.mock(Application.class);
Mockito.when(activity.getApplication()).thenReturn(application);
Mockito.when(activity.isChangingConfigurations()).thenReturn(false);
Mockito.when(activity.isFinishing()).thenReturn(true);

// This one also registers for
ActivityScopedCache scopedCache = PresenterManager.getOrCreateActivityScopedCache(activity);
Expand All @@ -177,8 +177,8 @@ public class PresenterManagerTest {

Mockito.when(portraitActivity1.getApplication()).thenReturn(application);
Mockito.when(landscapeActivity1.getApplication()).thenReturn(application);
Mockito.when(portraitActivity1.isChangingConfigurations()).thenReturn(true);
Mockito.when(landscapeActivity1.isChangingConfigurations()).thenReturn(false);
Mockito.when(portraitActivity1.isFinishing()).thenReturn(false);
Mockito.when(landscapeActivity1.isFinishing()).thenReturn(true);

// This one also registers for lifecycle events
ActivityScopedCache scopedCache1 =
Expand Down Expand Up @@ -250,10 +250,10 @@ public class PresenterManagerTest {
Mockito.when(landscapeActivity1.getApplication()).thenReturn(application);
Mockito.when(portraitActivity2.getApplication()).thenReturn(application);
Mockito.when(landscapeActivity2.getApplication()).thenReturn(application);
Mockito.when(portraitActivity1.isChangingConfigurations()).thenReturn(true);
Mockito.when(landscapeActivity1.isChangingConfigurations()).thenReturn(false);
Mockito.when(portraitActivity2.isChangingConfigurations()).thenReturn(true);
Mockito.when(landscapeActivity2.isChangingConfigurations()).thenReturn(false);
Mockito.when(portraitActivity1.isFinishing()).thenReturn(false);
Mockito.when(landscapeActivity1.isFinishing()).thenReturn(true);
Mockito.when(portraitActivity2.isFinishing()).thenReturn(false);
Mockito.when(landscapeActivity2.isFinishing()).thenReturn(true);

// This one also registers for lifecycle events
ActivityScopedCache activity1ScopedCache1 =
Expand Down