mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-23 16:34:44 +01:00
Fixed loading posts error in FilteredThingActivity when loading user's posts.
This commit is contained in:
parent
2b0fac1e7c
commit
096f122994
@ -71,6 +71,7 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
|
|||||||
private boolean mNullAccessToken = false;
|
private boolean mNullAccessToken = false;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String name;
|
private String name;
|
||||||
|
private String userWhere;
|
||||||
private int postType;
|
private int postType;
|
||||||
private Fragment mFragment;
|
private Fragment mFragment;
|
||||||
private Menu mMenu;
|
private Menu mMenu;
|
||||||
@ -145,6 +146,13 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
|
|||||||
postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostDataSource.TYPE_FRONT_PAGE);
|
postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostDataSource.TYPE_FRONT_PAGE);
|
||||||
int filter = getIntent().getIntExtra(EXTRA_FILTER, Post.TEXT_TYPE);
|
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) {
|
if (savedInstanceState != null) {
|
||||||
isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
|
isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
|
||||||
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
|
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
|
||||||
@ -248,14 +256,16 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
|
|||||||
if (initializeFragment) {
|
if (initializeFragment) {
|
||||||
mFragment = new PostFragment();
|
mFragment = new PostFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(PostFragment.EXTRA_NAME, name);
|
|
||||||
bundle.putInt(PostFragment.EXTRA_POST_TYPE, postType);
|
bundle.putInt(PostFragment.EXTRA_POST_TYPE, postType);
|
||||||
bundle.putInt(PostFragment.EXTRA_FILTER, filter);
|
bundle.putInt(PostFragment.EXTRA_FILTER, filter);
|
||||||
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
if (postType == PostDataSource.TYPE_USER) {
|
if (postType == PostDataSource.TYPE_USER) {
|
||||||
bundle.putString(PostFragment.EXTRA_USER_WHERE, getIntent().getStringExtra(EXTRA_USER_WHERE));
|
bundle.putString(PostFragment.EXTRA_USER_NAME, name);
|
||||||
}
|
bundle.putString(PostFragment.EXTRA_USER_WHERE, userWhere);
|
||||||
if (postType == PostDataSource.TYPE_SEARCH) {
|
} 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));
|
bundle.putString(PostFragment.EXTRA_QUERY, getIntent().getStringExtra(EXTRA_QUERY));
|
||||||
}
|
}
|
||||||
mFragment.setArguments(bundle);
|
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);
|
params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
|
||||||
collapsingToolbarLayout.setLayoutParams(params);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,10 +105,6 @@ class PostDataSourceFactory extends DataSource.Factory {
|
|||||||
return postDataSource;
|
return postDataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeSortType(SortType sortType) {
|
|
||||||
this.sortType = sortType;
|
|
||||||
}
|
|
||||||
|
|
||||||
void changeNSFWAndSortType(boolean nsfw, SortType sortType) {
|
void changeNSFWAndSortType(boolean nsfw, SortType sortType) {
|
||||||
this.nsfw = nsfw;
|
this.nsfw = nsfw;
|
||||||
this.sortType = sortType;
|
this.sortType = sortType;
|
||||||
|
@ -216,6 +216,7 @@ public class PostViewModel extends ViewModel {
|
|||||||
this.nsfw = nsfw;
|
this.nsfw = nsfw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//User posts
|
||||||
public Factory(Retrofit retrofit, String accessToken, Locale locale, String subredditName, int postType,
|
public Factory(Retrofit retrofit, String accessToken, Locale locale, String subredditName, int postType,
|
||||||
SortType sortType, String where, int filter, boolean nsfw) {
|
SortType sortType, String where, int filter, boolean nsfw) {
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user