mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-25 02:18:23 +01:00
Fix sorting and changing post layout for multireddits.
This commit is contained in:
parent
e69c26db19
commit
0d56a81206
@ -166,6 +166,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
sortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
|
||||
Bundle bottomSheetBundle = new Bundle();
|
||||
bottomSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
|
||||
bottomSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_RANDOM_TYPE, true);
|
||||
sortTypeBottomSheetFragment.setArguments(bottomSheetBundle);
|
||||
|
||||
sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
|
||||
@ -173,13 +174,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
|
||||
|
||||
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
|
||||
|
||||
//Get status bar height
|
||||
int statusBarHeight = 0;
|
||||
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
statusBarHeight = getResources().getDimensionPixelSize(resourceId);
|
||||
}
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndInitializeFragment() {
|
||||
@ -285,9 +279,11 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
|
||||
@Override
|
||||
public void sortTypeSelected(SortType sortType) {
|
||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST, sortType.getType().name()).apply();
|
||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiPath,
|
||||
sortType.getType().name()).apply();
|
||||
if(sortType.getTime() != null) {
|
||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST, sortType.getTime().name()).apply();
|
||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE+ multiPath,
|
||||
sortType.getTime().name()).apply();
|
||||
}
|
||||
|
||||
((PostFragment) mFragment).changeSortType(sortType);
|
||||
@ -304,7 +300,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
@Override
|
||||
public void postLayoutSelected(int postLayout) {
|
||||
if (mFragment != null) {
|
||||
//mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + multiPath, postLayout).apply();
|
||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiPath, postLayout).apply();
|
||||
((FragmentCommunicator) mFragment).changePostLayout(postLayout);
|
||||
}
|
||||
}
|
||||
|
@ -420,16 +420,19 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
filter, nsfw);
|
||||
}
|
||||
} else if(postType == PostDataSource.TYPE_MULTI_REDDIT) {
|
||||
String multiRedditName = getArguments().getString(EXTRA_NAME);
|
||||
String multiRedditPath = getArguments().getString(EXTRA_NAME);
|
||||
String sort;
|
||||
String sortTime = null;
|
||||
SortType sortType;
|
||||
|
||||
sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_ALL_POST, SortType.Type.HOT.name());
|
||||
sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
||||
SortType.Type.HOT.name());
|
||||
if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
|
||||
sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_ALL_POST, SortType.Time.ALL.name());
|
||||
sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
||||
SortType.Time.ALL.name());
|
||||
}
|
||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_ALL_POST, SharedPreferencesUtils.POST_LAYOUT_CARD);
|
||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
||||
SharedPreferencesUtils.POST_LAYOUT_CARD);
|
||||
|
||||
if(sortTime != null) {
|
||||
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
|
||||
@ -448,7 +451,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
@Override
|
||||
public void typeChipClicked(int filter) {
|
||||
Intent intent = new Intent(activity, FilteredThingActivity.class);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_NAME, multiRedditName);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_NAME, multiRedditPath);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
|
||||
intent.putExtra(FilteredThingActivity.EXTRA_FILTER, filter);
|
||||
startActivity(intent);
|
||||
@ -457,11 +460,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
|
||||
if (accessToken == null) {
|
||||
factory = new PostViewModel.Factory(mRetrofit, accessToken,
|
||||
getResources().getConfiguration().locale, multiRedditName, postType, sortType,
|
||||
getResources().getConfiguration().locale, multiRedditPath, postType, sortType,
|
||||
filter, nsfw);
|
||||
} else {
|
||||
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||
getResources().getConfiguration().locale, multiRedditName, postType, sortType,
|
||||
getResources().getConfiguration().locale, multiRedditPath, postType, sortType,
|
||||
filter, nsfw);
|
||||
}
|
||||
} else if (postType == PostDataSource.TYPE_USER) {
|
||||
@ -587,6 +590,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
mFetchPostInfoLinearLayout.setVisibility(View.GONE);
|
||||
mGlide.clear(mFetchPostInfoImageView);
|
||||
}
|
||||
mAdapter.removeFooter();
|
||||
hasPost = false;
|
||||
if (isInLazyMode) {
|
||||
stopLazyMode();
|
||||
}
|
||||
mPostViewModel.changeSortType(sortType);
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
public class SortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment {
|
||||
|
||||
public static final String EXTRA_NO_BEST_TYPE = "ENBT";
|
||||
public static final String EXTRA_NO_RANDOM_TYPE = "ENRT";
|
||||
@BindView(R.id.best_type_text_view_sort_type_bottom_sheet_fragment)
|
||||
TextView bestTypeTextView;
|
||||
@BindView(R.id.hot_type_text_view_sort_type_bottom_sheet_fragment)
|
||||
@ -78,10 +79,14 @@ public class SortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragmen
|
||||
dismiss();
|
||||
});
|
||||
|
||||
randomTypeTextView.setOnClickListener(view -> {
|
||||
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RANDOM));
|
||||
dismiss();
|
||||
});
|
||||
if (getArguments() == null || (getArguments().containsKey(EXTRA_NO_RANDOM_TYPE) && getArguments().getBoolean(EXTRA_NO_RANDOM_TYPE))) {
|
||||
randomTypeTextView.setVisibility(View.GONE);
|
||||
} else {
|
||||
randomTypeTextView.setOnClickListener(view -> {
|
||||
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RANDOM));
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
risingTypeTextView.setOnClickListener(view -> {
|
||||
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RISING));
|
||||
|
@ -40,6 +40,8 @@ public class SharedPreferencesUtils {
|
||||
public static final String SORT_TIME_SEARCH_POST = "sort_time_search_post";
|
||||
public static final String SORT_TYPE_SUBREDDIT_POST = "sort_type_subreddit_post";
|
||||
public static final String SORT_TIME_SUBREDDIT_POST = "sort_time_subreddit_post";
|
||||
public static final String SORT_TYPE_MULTI_REDDIT_POST_BASE = "sort_type_multi_reddit_post_";
|
||||
public static final String SORT_TIME_MULTI_REDDIT_POST_BASE = "sort_time_multi_reddit_post_";
|
||||
public static final String SORT_TYPE_USER_POST = "sort_type_user_post";
|
||||
public static final String SORT_TIME_USER_POST = "sort_time_user_post";
|
||||
public static final String SORT_TYPE_USER_COMMENT = "sort_type_user_comment";
|
||||
@ -51,6 +53,7 @@ public class SharedPreferencesUtils {
|
||||
public static final String POST_LAYOUT_POPULAR_POST = "post_layout_popular_post";
|
||||
public static final String POST_LAYOUT_ALL_POST = "post_layout_all_post";
|
||||
public static final String POST_LAYOUT_SUBREDDIT_POST_BASE = "post_layout_subreddit_post_";
|
||||
public static final String POST_LAYOUT_MULTI_REDDIT_POST_BASE = "post_layout_multi_reddit_post_";
|
||||
public static final String POST_LAYOUT_USER_POST_BASE = "post_layout_user_post_";
|
||||
public static final String POST_LAYOUT_SEARCH_POST = "post_layout_search_post";
|
||||
public static final int POST_LAYOUT_CARD = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user