diff options
author | Docile-Alligator <chineseperson5@gmail.com> | 2022-03-17 06:23:06 +0000 |
---|---|---|
committer | Docile-Alligator <chineseperson5@gmail.com> | 2022-03-17 06:23:06 +0000 |
commit | b4915859da8463d4ea3cca960f1bf1124c4bd591 (patch) | |
tree | b722e54526a6a0f273139575702d4d3968740e8a /app/src/main | |
parent | 7405e19c2ed059bf92be4fa2df45740268655107 (diff) | |
download | infinity-for-reddit-b4915859da8463d4ea3cca960f1bf1124c4bd591.tar infinity-for-reddit-b4915859da8463d4ea3cca960f1bf1124c4bd591.tar.gz infinity-for-reddit-b4915859da8463d4ea3cca960f1bf1124c4bd591.tar.bz2 infinity-for-reddit-b4915859da8463d4ea3cca960f1bf1124c4bd591.tar.lz infinity-for-reddit-b4915859da8463d4ea3cca960f1bf1124c4bd591.tar.xz infinity-for-reddit-b4915859da8463d4ea3cca960f1bf1124c4bd591.tar.zst infinity-for-reddit-b4915859da8463d4ea3cca960f1bf1124c4bd591.zip |
Check if PostFragment is detached before initializing PostViewModel.
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java index cba59d00..e982a512 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -911,7 +911,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { if (postFilter == null) { FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor, new Handler(), null, usage, nameOfUsage, (postFilter, readPostList) -> { - if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) { + if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) { this.postFilter = postFilter; postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.NSFW_BASE, false); initializeAndBindPostViewModel(accessToken); @@ -923,7 +923,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } else { FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor, new Handler(), accountName, usage, nameOfUsage, (postFilter, readPostList) -> { - if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) { + if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) { if (this.postFilter == null) { this.postFilter = postFilter; postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.NSFW_BASE, false); @@ -937,7 +937,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { if (postFilter == null) { FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor, new Handler(), null, usage, nameOfUsage, (postFilter, readPostList) -> { - if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) { + if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) { this.postFilter = postFilter; postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(accountName + SharedPreferencesUtils.NSFW_BASE, false); initializeAndBindPostViewModel(accessToken); @@ -953,7 +953,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { if (concatenatedSubredditNames == null) { FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndConcatenatedSubredditNames(mRedditDataRoomDatabase, mExecutor, new Handler(), usage, nameOfUsage, (postFilter, concatenatedSubredditNames) -> { - if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) { + if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) { this.postFilter = postFilter; postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_BASE, false); this.concatenatedSubredditNames = concatenatedSubredditNames; @@ -971,7 +971,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { if (concatenatedSubredditNames == null) { FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndConcatenatedSubredditNames(mRedditDataRoomDatabase, mExecutor, new Handler(), multiRedditPath, usage, nameOfUsage, (postFilter, concatenatedSubredditNames) -> { - if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) { + if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) { this.postFilter = postFilter; postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_BASE, false); this.concatenatedSubredditNames = concatenatedSubredditNames; @@ -988,7 +988,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } else { FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor, new Handler(), null, usage, nameOfUsage, (postFilter, readPostList) -> { - if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) { + if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) { this.postFilter = postFilter; postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_BASE, false); initializeAndBindPostViewModelForAnonymous(null); @@ -1000,7 +1000,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { if (concatenatedSubredditNames == null) { FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndConcatenatedSubredditNames(mRedditDataRoomDatabase, mExecutor, new Handler(), usage, nameOfUsage, (postFilter, concatenatedSubredditNames) -> { - if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) { + if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) { this.postFilter = postFilter; postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_BASE, false); this.concatenatedSubredditNames = concatenatedSubredditNames; @@ -1018,7 +1018,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { if (concatenatedSubredditNames == null) { FetchPostFilterReadPostsAndConcatenatedSubredditNames.fetchPostFilterAndConcatenatedSubredditNames(mRedditDataRoomDatabase, mExecutor, new Handler(), multiRedditPath, usage, nameOfUsage, (postFilter, concatenatedSubredditNames) -> { - if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) { + if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && !isDetached()) { this.postFilter = postFilter; postFilter.allowNSFW = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false) && mNsfwAndSpoilerSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_BASE, false); this.concatenatedSubredditNames = concatenatedSubredditNames; |