diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-12-02 06:50:16 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-12-02 06:50:16 +0000 |
commit | 5c31c21d06cfbf9c2fca0a32ca0d7c185566b625 (patch) | |
tree | 4f755e409d813d6420e2848dc2044d88c06bfc83 /app/src/main/java/ml | |
parent | 71661e94f06f0edc939d2bb170ae019fe9cfca0d (diff) | |
download | infinity-for-reddit-5c31c21d06cfbf9c2fca0a32ca0d7c185566b625.tar infinity-for-reddit-5c31c21d06cfbf9c2fca0a32ca0d7c185566b625.tar.gz infinity-for-reddit-5c31c21d06cfbf9c2fca0a32ca0d7c185566b625.tar.bz2 infinity-for-reddit-5c31c21d06cfbf9c2fca0a32ca0d7c185566b625.tar.lz infinity-for-reddit-5c31c21d06cfbf9c2fca0a32ca0d7c185566b625.tar.xz infinity-for-reddit-5c31c21d06cfbf9c2fca0a32ca0d7c185566b625.tar.zst infinity-for-reddit-5c31c21d06cfbf9c2fca0a32ca0d7c185566b625.zip |
Try fixing IllegalStateException for fragments in various Activities.
Diffstat (limited to 'app/src/main/java/ml')
5 files changed, 12 insertions, 11 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java index 74cf5393..27292222 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java @@ -143,10 +143,12 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE); mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE); isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE); - mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE); - getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_account_posts_activity, mFragment).commit(); + if (!mNullAccessToken && mAccessToken == null) { getCurrentAccountAndInitializeFragment(); + } else { + mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE); + getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_account_posts_activity, mFragment).commit(); } } else { getCurrentAccountAndInitializeFragment(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java index 42a366e9..d2bfc20f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java @@ -159,12 +159,11 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE); mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE); - mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE); - getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_filtered_posts_activity, mFragment).commit(); - if (!mNullAccessToken && mAccessToken == null) { getCurrentAccountAndBindView(filter); } else { + mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE); + getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_filtered_posts_activity, mFragment).commit(); bindView(filter, false); } } else { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java index 21ebd255..9014ce1a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java @@ -114,6 +114,7 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE); mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE); mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE); + if (!mNullAccessToken && mAccessToken == null) { getCurrentAccountAndInitializeFragment(query); } else { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java index 8742ad7c..eb63d756 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java @@ -133,12 +133,11 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE); mAccountProfileImageUrl = savedInstanceState.getString(ACCOUNT_PROFILE_IMAGE_URL); - mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE); - getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_subreddit_selection_activity, mFragment).commit(); - if (!mNullAccessToken && mAccountName == null) { getCurrentAccountAndBindView(); } else { + mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE); + getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_subreddit_selection_activity, mFragment).commit(); bindView(false); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java index 72ff2341..2caec58b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java @@ -158,11 +158,11 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE); isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE); - mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE_KEY); - getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_multi_reddit_detail_activity, mFragment).commit(); - if (!mNullAccessToken && mAccessToken == null) { getCurrentAccountAndInitializeFragment(); + } else { + mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE_KEY); + getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_multi_reddit_detail_activity, mFragment).commit(); } } else { getCurrentAccountAndInitializeFragment(); |