diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-10-20 11:36:30 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-10-20 11:36:30 +0000 |
commit | 096f12299447dbd21680d5195767b33788ffd5cb (patch) | |
tree | f86f5b8ad4b0c3af0b24c0911d4c2c58ca317142 /app/src | |
parent | 2b0fac1e7cba6413606857bf98e63dd6f1a66a4c (diff) | |
download | infinity-for-reddit-096f12299447dbd21680d5195767b33788ffd5cb.tar infinity-for-reddit-096f12299447dbd21680d5195767b33788ffd5cb.tar.gz infinity-for-reddit-096f12299447dbd21680d5195767b33788ffd5cb.tar.bz2 infinity-for-reddit-096f12299447dbd21680d5195767b33788ffd5cb.tar.lz infinity-for-reddit-096f12299447dbd21680d5195767b33788ffd5cb.tar.xz infinity-for-reddit-096f12299447dbd21680d5195767b33788ffd5cb.tar.zst infinity-for-reddit-096f12299447dbd21680d5195767b33788ffd5cb.zip |
Fixed loading posts error in FilteredThingActivity when loading user's posts.
Diffstat (limited to 'app/src')
3 files changed, 19 insertions, 8 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java index b5412522..1f6fc1e3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java @@ -71,6 +71,7 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec private boolean mNullAccessToken = false; private String mAccessToken; private String name; + private String userWhere; private int postType; private Fragment mFragment; private Menu mMenu; @@ -145,6 +146,13 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostDataSource.TYPE_FRONT_PAGE); int filter = getIntent().getIntExtra(EXTRA_FILTER, Post.TEXT_TYPE); + if (postType == PostDataSource.TYPE_USER) { + userWhere = getIntent().getStringExtra(EXTRA_USER_WHERE); + if (userWhere != null && !PostDataSource.USER_WHERE_SUBMITTED.equals(userWhere) && mMenu != null) { + mMenu.findItem(R.id.action_sort_filtered_thing_activity).setVisible(false); + } + } + if (savedInstanceState != null) { isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE); mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE); @@ -248,14 +256,16 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec if (initializeFragment) { mFragment = new PostFragment(); Bundle bundle = new Bundle(); - bundle.putString(PostFragment.EXTRA_NAME, name); bundle.putInt(PostFragment.EXTRA_POST_TYPE, postType); bundle.putInt(PostFragment.EXTRA_FILTER, filter); bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken); if (postType == PostDataSource.TYPE_USER) { - bundle.putString(PostFragment.EXTRA_USER_WHERE, getIntent().getStringExtra(EXTRA_USER_WHERE)); - } - if (postType == PostDataSource.TYPE_SEARCH) { + bundle.putString(PostFragment.EXTRA_USER_NAME, name); + bundle.putString(PostFragment.EXTRA_USER_WHERE, userWhere); + } else if (postType == PostDataSource.TYPE_SUBREDDIT) { + bundle.putString(PostFragment.EXTRA_NAME, name); + } else if (postType == PostDataSource.TYPE_SEARCH) { + bundle.putString(PostFragment.EXTRA_NAME, name); bundle.putString(PostFragment.EXTRA_QUERY, getIntent().getStringExtra(EXTRA_QUERY)); } mFragment.setArguments(bundle); @@ -277,6 +287,10 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS); collapsingToolbarLayout.setLayoutParams(params); } + + if (userWhere != null && !PostDataSource.USER_WHERE_SUBMITTED.equals(userWhere)) { + mMenu.findItem(R.id.action_sort_filtered_thing_activity).setVisible(false); + } return true; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java index 77b5199d..52015450 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java @@ -105,10 +105,6 @@ class PostDataSourceFactory extends DataSource.Factory { return postDataSource; } - void changeSortType(SortType sortType) { - this.sortType = sortType; - } - void changeNSFWAndSortType(boolean nsfw, SortType sortType) { this.nsfw = nsfw; this.sortType = sortType; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java index 16ad30f0..487ef5b1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java @@ -216,6 +216,7 @@ public class PostViewModel extends ViewModel { this.nsfw = nsfw; } + //User posts public Factory(Retrofit retrofit, String accessToken, Locale locale, String subredditName, int postType, SortType sortType, String where, int filter, boolean nsfw) { this.retrofit = retrofit; |