diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-11-19 07:35:25 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-11-19 07:35:25 +0000 |
commit | 994df9062cdcbed8799a3b6862428cf64bf6fdb3 (patch) | |
tree | 5b30cfb561a24cec7e4b9ad7bfefa4b292904c43 /app/src/main/java/ml | |
parent | 2db6fb8aca4bb0484cfcfbccbb9834101ee0a2e5 (diff) | |
download | infinity-for-reddit-994df9062cdcbed8799a3b6862428cf64bf6fdb3.tar infinity-for-reddit-994df9062cdcbed8799a3b6862428cf64bf6fdb3.tar.gz infinity-for-reddit-994df9062cdcbed8799a3b6862428cf64bf6fdb3.tar.bz2 infinity-for-reddit-994df9062cdcbed8799a3b6862428cf64bf6fdb3.tar.lz infinity-for-reddit-994df9062cdcbed8799a3b6862428cf64bf6fdb3.tar.xz infinity-for-reddit-994df9062cdcbed8799a3b6862428cf64bf6fdb3.tar.zst infinity-for-reddit-994df9062cdcbed8799a3b6862428cf64bf6fdb3.zip |
Check if activity is destroyed after fetching subreddit filters in PostFragment.
Diffstat (limited to 'app/src/main/java/ml')
-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 8ab11086..fbc7d0cb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -459,7 +459,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { }); mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, - accountName, getResources().getConfiguration().locale, mSharedPreferences, + accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, query, postType, sortType, filter, nsfw)).get(PostViewModel.class); } else if (postType == PostDataSource.TYPE_SUBREDDIT) { subredditName = getArguments().getString(EXTRA_NAME); @@ -513,14 +513,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator { if (subredditName.equals("all") || subredditName.equals("popular")) { if (subredditFilterList != null) { mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, - accountName, getResources().getConfiguration().locale, mSharedPreferences, + accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, filter, nsfw, subredditFilterList)).get(PostViewModel.class); } else { FetchSubredditFilters.fetchSubredditFilters(mRedditDataRoomDatabase, subredditFilters -> { - if (activity != null) { + if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) { subredditFilterList = subredditFilters; mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, - accountName, getResources().getConfiguration().locale, mSharedPreferences, + accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, filter, nsfw, subredditFilters)).get(PostViewModel.class); bindPostViewModel(); @@ -529,7 +529,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } } else { mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, - accountName, getResources().getConfiguration().locale, mSharedPreferences, + accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, filter, nsfw)).get(PostViewModel.class); } } else if(postType == PostDataSource.TYPE_MULTI_REDDIT) { @@ -584,7 +584,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { }); mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, - accountName, getResources().getConfiguration().locale, mSharedPreferences, + accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, multiRedditPath, postType, sortType, filter, nsfw)).get(PostViewModel.class); } else if (postType == PostDataSource.TYPE_USER) { username = getArguments().getString(EXTRA_USER_NAME); @@ -637,7 +637,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { }); mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken, - accountName, getResources().getConfiguration().locale, mSharedPreferences, + accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, username, postType, sortType, where, filter, nsfw)).get(PostViewModel.class); } else { String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, SortType.Type.BEST.name()); @@ -681,7 +681,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { }); mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mOauthRetrofit, accessToken, - accountName, getResources().getConfiguration().locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, + accountName, locale, mSharedPreferences, postFeedScrolledPositionSharedPreferences, postType, sortType, filter, nsfw)).get(PostViewModel.class); } |