mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-31 21:37:11 +01:00
Show sort type in toolbar.
This commit is contained in:
parent
8311507acd
commit
2cd86c7ffa
@ -92,6 +92,7 @@ import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.Subscrib
|
|||||||
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
|
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
|
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
|
||||||
@ -601,6 +602,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
sectionsPagerAdapter.pauseLazyMode();
|
sectionsPagerAdapter.pauseLazyMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sectionsPagerAdapter.displaySortTypeInToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -931,6 +933,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displaySortType() {
|
||||||
|
if (sectionsPagerAdapter != null) {
|
||||||
|
sectionsPagerAdapter.displaySortTypeInToolbar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||||
private PostFragment tab1;
|
private PostFragment tab1;
|
||||||
private PostFragment tab2;
|
private PostFragment tab2;
|
||||||
@ -1092,6 +1101,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
tab3 = (PostFragment) fragment;
|
tab3 = (PostFragment) fragment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
displaySortTypeInToolbar();
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1271,6 +1281,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
tab3.changeSortType(sortType);
|
tab3.changeSortType(sortType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
displaySortTypeInToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
@ -1361,5 +1372,27 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
tab3.goBackToTop();
|
tab3.goBackToTop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void displaySortTypeInToolbar() {
|
||||||
|
switch (viewPager.getCurrentItem()) {
|
||||||
|
case 0:
|
||||||
|
if (tab1 != null) {
|
||||||
|
SortType sortType = tab1.getSortType();
|
||||||
|
Utils.displaySortTypeInToolbar(sortType, toolbar);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (tab2 != null) {
|
||||||
|
SortType sortType = tab2.getSortType();
|
||||||
|
Utils.displaySortTypeInToolbar(sortType, toolbar);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (tab3 != null) {
|
||||||
|
SortType sortType = tab3.getSortType();
|
||||||
|
Utils.displaySortTypeInToolbar(sortType, toolbar);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
|||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
|
|
||||||
public class SearchResultActivity extends BaseActivity implements SortTypeSelectionCallback,
|
public class SearchResultActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||||
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, ActivityToolbarInterface {
|
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, ActivityToolbarInterface {
|
||||||
@ -200,6 +201,20 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||||
viewPager.setAdapter(sectionsPagerAdapter);
|
viewPager.setAdapter(sectionsPagerAdapter);
|
||||||
viewPager.setOffscreenPageLimit(2);
|
viewPager.setOffscreenPageLimit(2);
|
||||||
|
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
sectionsPagerAdapter.displaySortTypeInToolbar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int state) {
|
||||||
|
}
|
||||||
|
});
|
||||||
tabLayout.setupWithViewPager(viewPager);
|
tabLayout.setupWithViewPager(viewPager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,6 +319,13 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displaySortType() {
|
||||||
|
if (sectionsPagerAdapter != null) {
|
||||||
|
sectionsPagerAdapter.displaySortTypeInToolbar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||||
|
|
||||||
private PostFragment postFragment;
|
private PostFragment postFragment;
|
||||||
@ -384,6 +406,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
userListingFragment = (UserListingFragment) fragment;
|
userListingFragment = (UserListingFragment) fragment;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
displaySortTypeInToolbar();
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,6 +421,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
}
|
}
|
||||||
|
|
||||||
postFragment.changeSortType(sortType);
|
postFragment.changeSortType(sortType);
|
||||||
|
displaySortTypeInToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeSortType(SortType sortType, int fragmentPosition) {
|
void changeSortType(SortType sortType, int fragmentPosition) {
|
||||||
@ -410,6 +434,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_USER, sortType.getType().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_USER, sortType.getType().name()).apply();
|
||||||
userListingFragment.changeSortType(sortType);
|
userListingFragment.changeSortType(sortType);
|
||||||
}
|
}
|
||||||
|
displaySortTypeInToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
@ -448,5 +473,28 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
userListingFragment.goBackToTop();
|
userListingFragment.goBackToTop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void displaySortTypeInToolbar() {
|
||||||
|
switch (viewPager.getCurrentItem()) {
|
||||||
|
case 0:
|
||||||
|
if (postFragment != null) {
|
||||||
|
SortType sortType = postFragment.getSortType();
|
||||||
|
Utils.displaySortTypeInToolbar(sortType, toolbar);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (subredditListingFragment != null) {
|
||||||
|
SortType sortType = subredditListingFragment.getSortType();
|
||||||
|
Utils.displaySortTypeInToolbar(sortType, toolbar);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (userListingFragment != null) {
|
||||||
|
SortType sortType = userListingFragment.getSortType();
|
||||||
|
Utils.displaySortTypeInToolbar(sortType, toolbar);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
|||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class ViewMultiRedditDetailActivity extends BaseActivity implements SortTypeSelectionCallback,
|
public class ViewMultiRedditDetailActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||||
@ -306,6 +307,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
}
|
}
|
||||||
|
|
||||||
((PostFragment) mFragment).changeSortType(sortType);
|
((PostFragment) mFragment).changeSortType(sortType);
|
||||||
|
displaySortType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -346,4 +348,12 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
((PostFragment) mFragment).goBackToTop();
|
((PostFragment) mFragment).goBackToTop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displaySortType() {
|
||||||
|
if (mFragment != null) {
|
||||||
|
SortType sortType = ((PostFragment) mFragment).getSortType();
|
||||||
|
Utils.displaySortTypeInToolbar(sortType, toolbar);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ import butterknife.ButterKnife;
|
|||||||
import im.ene.toro.exoplayer.ExoCreator;
|
import im.ene.toro.exoplayer.ExoCreator;
|
||||||
import im.ene.toro.media.PlaybackInfo;
|
import im.ene.toro.media.PlaybackInfo;
|
||||||
import im.ene.toro.media.VolumeInfo;
|
import im.ene.toro.media.VolumeInfo;
|
||||||
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||||
import ml.docilealligator.infinityforreddit.Adapter.CommentAndPostRecyclerViewAdapter;
|
import ml.docilealligator.infinityforreddit.Adapter.CommentAndPostRecyclerViewAdapter;
|
||||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||||
@ -81,7 +82,6 @@ import ml.docilealligator.infinityforreddit.Post.ParsePost;
|
|||||||
import ml.docilealligator.infinityforreddit.Post.Post;
|
import ml.docilealligator.infinityforreddit.Post.Post;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.ReadMessage;
|
import ml.docilealligator.infinityforreddit.ReadMessage;
|
||||||
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
@ -181,6 +181,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
private int orientation;
|
private int orientation;
|
||||||
private int postListPosition = -1;
|
private int postListPosition = -1;
|
||||||
private String mSingleCommentId;
|
private String mSingleCommentId;
|
||||||
|
private String sortType;
|
||||||
private boolean showToast = false;
|
private boolean showToast = false;
|
||||||
private boolean isSortingComments = false;
|
private boolean isSortingComments = false;
|
||||||
private boolean mVolumeKeysNavigateComments;
|
private boolean mVolumeKeysNavigateComments;
|
||||||
@ -344,6 +345,9 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
};
|
};
|
||||||
|
|
||||||
mSingleCommentId = getIntent().getStringExtra(EXTRA_SINGLE_COMMENT_ID);
|
mSingleCommentId = getIntent().getStringExtra(EXTRA_SINGLE_COMMENT_ID);
|
||||||
|
sortType = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, SortType.Type.BEST.value);
|
||||||
|
mToolbar.setTitle(new SortType(SortType.Type.valueOf(sortType)).getType().fullName);
|
||||||
|
sortType = sortType.toLowerCase();
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
if (mSingleCommentId != null) {
|
if (mSingleCommentId != null) {
|
||||||
isSingleCommentThreadMode = true;
|
isSingleCommentThreadMode = true;
|
||||||
@ -569,9 +573,6 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
mSwipeRefreshLayout.setRefreshing(true);
|
mSwipeRefreshLayout.setRefreshing(true);
|
||||||
mGlide.clear(mFetchPostInfoImageView);
|
mGlide.clear(mFetchPostInfoImageView);
|
||||||
|
|
||||||
String sortType = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, SortType.Type.BEST.value).toLowerCase();
|
|
||||||
|
|
||||||
|
|
||||||
Call<String> postAndComments;
|
Call<String> postAndComments;
|
||||||
if (mAccessToken == null) {
|
if (mAccessToken == null) {
|
||||||
if (isSingleCommentThreadMode && mSingleCommentId != null) {
|
if (isSingleCommentThreadMode && mSingleCommentId != null) {
|
||||||
@ -847,8 +848,6 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fetchComments(boolean changeRefreshState) {
|
private void fetchComments(boolean changeRefreshState) {
|
||||||
String sortType = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT,
|
|
||||||
SortType.Type.BEST.value).toLowerCase();
|
|
||||||
fetchComments(changeRefreshState, true, sortType);
|
fetchComments(changeRefreshState, true, sortType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1618,6 +1617,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
}
|
}
|
||||||
fetchComments(false, false, sortType.getType().value);
|
fetchComments(false, false, sortType.getType().value);
|
||||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, sortType.getType().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, sortType.getType().name()).apply();
|
||||||
|
|
||||||
|
mToolbar.setTitle(sortType.getType().fullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lockSwipeRightToGoBack() {
|
public void lockSwipeRightToGoBack() {
|
||||||
|
@ -78,6 +78,7 @@ import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
|
|||||||
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditViewModel;
|
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditViewModel;
|
||||||
import ml.docilealligator.infinityforreddit.SubredditSubscription;
|
import ml.docilealligator.infinityforreddit.SubredditSubscription;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
import pl.droidsonroids.gif.GifImageView;
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
@ -642,6 +643,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
sectionsPagerAdapter.pauseLazyMode();
|
sectionsPagerAdapter.pauseLazyMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sectionsPagerAdapter.displaySortTypeInToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -853,6 +856,13 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displaySortType() {
|
||||||
|
if (sectionsPagerAdapter != null) {
|
||||||
|
sectionsPagerAdapter.displaySortTypeInToolbar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||||
private PostFragment postFragment;
|
private PostFragment postFragment;
|
||||||
private SidebarFragment sidebarFragment;
|
private SidebarFragment sidebarFragment;
|
||||||
@ -904,6 +914,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
switch (position) {
|
switch (position) {
|
||||||
case 0:
|
case 0:
|
||||||
postFragment = (PostFragment) fragment;
|
postFragment = (PostFragment) fragment;
|
||||||
|
displaySortTypeInToolbar();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
sidebarFragment = (SidebarFragment) fragment;
|
sidebarFragment = (SidebarFragment) fragment;
|
||||||
@ -960,6 +971,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
}
|
}
|
||||||
|
|
||||||
postFragment.changeSortType(sortType);
|
postFragment.changeSortType(sortType);
|
||||||
|
displaySortTypeInToolbar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -987,5 +999,14 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void displaySortTypeInToolbar() {
|
||||||
|
if (viewPager.getCurrentItem() == 0) {
|
||||||
|
if (postFragment != null) {
|
||||||
|
SortType sortType = postFragment.getSortType();
|
||||||
|
Utils.displaySortTypeInToolbar(sortType, toolbar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,7 @@ import ml.docilealligator.infinityforreddit.User.UserData;
|
|||||||
import ml.docilealligator.infinityforreddit.User.UserViewModel;
|
import ml.docilealligator.infinityforreddit.User.UserViewModel;
|
||||||
import ml.docilealligator.infinityforreddit.UserFollowing;
|
import ml.docilealligator.infinityforreddit.UserFollowing;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
import pl.droidsonroids.gif.GifImageView;
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
@ -510,6 +511,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
sectionsPagerAdapter.pauseLazyMode();
|
sectionsPagerAdapter.pauseLazyMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sectionsPagerAdapter.displaySortTypeInToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -720,6 +722,13 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displaySortType() {
|
||||||
|
if (sectionsPagerAdapter != null) {
|
||||||
|
sectionsPagerAdapter.displaySortTypeInToolbar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class InsertUserDataAsyncTask extends AsyncTask<Void, Void, Void> {
|
private static class InsertUserDataAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
private UserDao userDao;
|
private UserDao userDao;
|
||||||
@ -807,6 +816,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
case 1:
|
case 1:
|
||||||
commentsListingFragment = (CommentsListingFragment) fragment;
|
commentsListingFragment = (CommentsListingFragment) fragment;
|
||||||
}
|
}
|
||||||
|
displaySortTypeInToolbar();
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -871,6 +881,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
commentsListingFragment.changeSortType(sortType);
|
commentsListingFragment.changeSortType(sortType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
displaySortTypeInToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeNSFW(boolean nsfw) {
|
public void changeNSFW(boolean nsfw) {
|
||||||
@ -897,5 +908,22 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void displaySortTypeInToolbar() {
|
||||||
|
switch (viewPager.getCurrentItem()) {
|
||||||
|
case 0:
|
||||||
|
if (postFragment != null) {
|
||||||
|
SortType sortType = postFragment.getSortType();
|
||||||
|
Utils.displaySortTypeInToolbar(sortType, toolbar);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (commentsListingFragment != null) {
|
||||||
|
SortType sortType = commentsListingFragment.getSortType();
|
||||||
|
Utils.displaySortTypeInToolbar(sortType, toolbar);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,4 +2,5 @@ package ml.docilealligator.infinityforreddit;
|
|||||||
|
|
||||||
public interface ActivityToolbarInterface {
|
public interface ActivityToolbarInterface {
|
||||||
void onLongPress();
|
void onLongPress();
|
||||||
|
default void displaySortType() {};
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -42,7 +43,6 @@ import ml.docilealligator.infinityforreddit.R;
|
|||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
|
|
||||||
@ -97,6 +97,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
private LinearLayoutManager mLinearLayoutManager;
|
private LinearLayoutManager mLinearLayoutManager;
|
||||||
private CommentsListingRecyclerViewAdapter mAdapter;
|
private CommentsListingRecyclerViewAdapter mAdapter;
|
||||||
|
private SortType sortType;
|
||||||
private boolean mShowElapsedTime;
|
private boolean mShowElapsedTime;
|
||||||
private boolean mShowCommentDivider;
|
private boolean mShowCommentDivider;
|
||||||
private boolean mShowAbsoluteNumberOfVotes;
|
private boolean mShowAbsoluteNumberOfVotes;
|
||||||
@ -173,10 +174,9 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
() -> mCommentViewModel.retryLoadingMore());
|
() -> mCommentViewModel.retryLoadingMore());
|
||||||
|
|
||||||
String username = getArguments().getString(EXTRA_USERNAME);
|
String username = getArguments().getString(EXTRA_USERNAME);
|
||||||
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_COMMENT, SortType.Type.NEW.value);
|
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_COMMENT, SortType.Type.NEW.name());
|
||||||
SortType sortType;
|
if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
|
||||||
if(sort.equals(SortType.Type.CONTROVERSIAL.value) || sort.equals(SortType.Type.TOP.value)) {
|
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_COMMENT, SortType.Time.ALL.name());
|
||||||
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_COMMENT, SortType.Time.ALL.value);
|
|
||||||
sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()), SortType.Time.valueOf(sortTime.toUpperCase()));
|
sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()), SortType.Time.valueOf(sortTime.toUpperCase()));
|
||||||
} else {
|
} else {
|
||||||
sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()));
|
sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()));
|
||||||
@ -230,6 +230,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
|
|
||||||
public void changeSortType(SortType sortType) {
|
public void changeSortType(SortType sortType) {
|
||||||
mCommentViewModel.changeSortType(sortType);
|
mCommentViewModel.changeSortType(sortType);
|
||||||
|
this.sortType = sortType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -273,4 +274,8 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SortType getSortType() {
|
||||||
|
return sortType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,11 +49,11 @@ import butterknife.ButterKnife;
|
|||||||
import im.ene.toro.exoplayer.ExoCreator;
|
import im.ene.toro.exoplayer.ExoCreator;
|
||||||
import im.ene.toro.media.PlaybackInfo;
|
import im.ene.toro.media.PlaybackInfo;
|
||||||
import im.ene.toro.media.VolumeInfo;
|
import im.ene.toro.media.VolumeInfo;
|
||||||
import im.ene.toro.widget.Container;
|
|
||||||
import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
|
import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.FilteredThingActivity;
|
import ml.docilealligator.infinityforreddit.Activity.FilteredThingActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.MainActivity;
|
import ml.docilealligator.infinityforreddit.Activity.MainActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
|
||||||
|
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||||
import ml.docilealligator.infinityforreddit.Adapter.PostRecyclerViewAdapter;
|
import ml.docilealligator.infinityforreddit.Adapter.PostRecyclerViewAdapter;
|
||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.CustomView.CustomToroContainer;
|
import ml.docilealligator.infinityforreddit.CustomView.CustomToroContainer;
|
||||||
@ -151,6 +151,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
private CountDownTimer resumeLazyModeCountDownTimer;
|
private CountDownTimer resumeLazyModeCountDownTimer;
|
||||||
private float lazyModeInterval;
|
private float lazyModeInterval;
|
||||||
private int postLayout;
|
private int postLayout;
|
||||||
|
private SortType sortType;
|
||||||
|
|
||||||
public PostFragment() {
|
public PostFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
@ -348,7 +349,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, SortType.Type.RELEVANCE.name());
|
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, SortType.Type.RELEVANCE.name());
|
||||||
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, SortType.Time.ALL.name());
|
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, SortType.Time.ALL.name());
|
||||||
SortType sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
|
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
|
||||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
||||||
@ -383,7 +384,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
String subredditName = getArguments().getString(EXTRA_NAME);
|
String subredditName = getArguments().getString(EXTRA_NAME);
|
||||||
String sort;
|
String sort;
|
||||||
String sortTime = null;
|
String sortTime = null;
|
||||||
SortType sortType;
|
|
||||||
|
|
||||||
boolean displaySubredditName = subredditName != null && (subredditName.equals("popular") || subredditName.equals("all"));
|
boolean displaySubredditName = subredditName != null && (subredditName.equals("popular") || subredditName.equals("all"));
|
||||||
if(displaySubredditName) {
|
if(displaySubredditName) {
|
||||||
@ -445,7 +445,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
String multiRedditPath = getArguments().getString(EXTRA_NAME);
|
String multiRedditPath = getArguments().getString(EXTRA_NAME);
|
||||||
String sort;
|
String sort;
|
||||||
String sortTime = null;
|
String sortTime = null;
|
||||||
SortType sortType;
|
|
||||||
|
|
||||||
sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
||||||
SortType.Type.HOT.name());
|
SortType.Type.HOT.name());
|
||||||
@ -499,7 +498,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username, SortType.Type.NEW.name());
|
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username, SortType.Type.NEW.name());
|
||||||
SortType sortType;
|
|
||||||
if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
|
if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
|
||||||
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username, SortType.Time.ALL.name());
|
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username, SortType.Time.ALL.name());
|
||||||
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
|
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
|
||||||
@ -538,7 +536,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, SortType.Type.BEST.name());
|
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, SortType.Type.BEST.name());
|
||||||
SortType sortType;
|
|
||||||
if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
|
if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
|
||||||
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_BEST_POST, SortType.Time.ALL.name());
|
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_BEST_POST, SortType.Time.ALL.name());
|
||||||
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
|
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
|
||||||
@ -569,6 +566,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
getResources().getConfiguration().locale, postType, sortType, filter, nsfw)).get(PostViewModel.class);
|
getResources().getConfiguration().locale, postType, sortType, filter, nsfw)).get(PostViewModel.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (activity instanceof ActivityToolbarInterface) {
|
||||||
|
((ActivityToolbarInterface) activity).displaySortType();
|
||||||
|
}
|
||||||
|
|
||||||
mPostRecyclerView.setAdapter(mAdapter);
|
mPostRecyclerView.setAdapter(mAdapter);
|
||||||
mPostRecyclerView.setCacheManager(mAdapter);
|
mPostRecyclerView.setCacheManager(mAdapter);
|
||||||
mPostRecyclerView.setPlayerInitializer(order -> {
|
mPostRecyclerView.setPlayerInitializer(order -> {
|
||||||
@ -621,6 +622,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
if (isInLazyMode) {
|
if (isInLazyMode) {
|
||||||
stopLazyMode();
|
stopLazyMode();
|
||||||
}
|
}
|
||||||
|
this.sortType = sortType;
|
||||||
mPostViewModel.changeSortType(sortType);
|
mPostViewModel.changeSortType(sortType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -937,6 +939,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SortType getSortType() {
|
||||||
|
return sortType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
@ -89,6 +89,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
private LinearLayoutManager mLinearLayoutManager;
|
private LinearLayoutManager mLinearLayoutManager;
|
||||||
private SubredditListingRecyclerViewAdapter mAdapter;
|
private SubredditListingRecyclerViewAdapter mAdapter;
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
|
private SortType sortType;
|
||||||
|
|
||||||
public SubredditListingFragment() {
|
public SubredditListingFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
@ -128,7 +129,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
|
String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
|
||||||
|
|
||||||
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_SUBREDDIT, SortType.Type.RELEVANCE.value);
|
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_SUBREDDIT, SortType.Type.RELEVANCE.value);
|
||||||
SortType sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()));
|
sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()));
|
||||||
|
|
||||||
mAdapter = new SubredditListingRecyclerViewAdapter(mActivity, mOauthRetrofit, mRetrofit,
|
mAdapter = new SubredditListingRecyclerViewAdapter(mActivity, mOauthRetrofit, mRetrofit,
|
||||||
customThemeWrapper, accessToken, accountName, mRedditDataRoomDatabase,
|
customThemeWrapper, accessToken, accountName, mRedditDataRoomDatabase,
|
||||||
@ -206,6 +207,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
|
|
||||||
public void changeSortType(SortType sortType) {
|
public void changeSortType(SortType sortType) {
|
||||||
mSubredditListingViewModel.changeSortType(sortType);
|
mSubredditListingViewModel.changeSortType(sortType);
|
||||||
|
this.sortType = sortType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -227,4 +229,8 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SortType getSortType() {
|
||||||
|
return sortType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,7 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
|
|||||||
private String mQuery;
|
private String mQuery;
|
||||||
private UserListingRecyclerViewAdapter mAdapter;
|
private UserListingRecyclerViewAdapter mAdapter;
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
|
private SortType sortType;
|
||||||
|
|
||||||
public UserListingFragment() {
|
public UserListingFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
@ -123,7 +124,7 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
|
|||||||
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
||||||
String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
|
String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
|
||||||
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_USER, SortType.Type.RELEVANCE.value);
|
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_USER, SortType.Type.RELEVANCE.value);
|
||||||
SortType sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()));
|
sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()));
|
||||||
|
|
||||||
mAdapter = new UserListingRecyclerViewAdapter(getActivity(), mOauthRetrofit, mRetrofit,
|
mAdapter = new UserListingRecyclerViewAdapter(getActivity(), mOauthRetrofit, mRetrofit,
|
||||||
customThemeWrapper, accessToken, accountName, mRedditDataRoomDatabase.subscribedUserDao(),
|
customThemeWrapper, accessToken, accountName, mRedditDataRoomDatabase.subscribedUserDao(),
|
||||||
@ -186,6 +187,7 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
|
|||||||
|
|
||||||
public void changeSortType(SortType sortType) {
|
public void changeSortType(SortType sortType) {
|
||||||
mUserListingViewModel.changeSortType(sortType);
|
mUserListingViewModel.changeSortType(sortType);
|
||||||
|
this.sortType = sortType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -207,4 +209,8 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
|
|||||||
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SortType getSortType() {
|
||||||
|
return sortType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,40 +23,44 @@ public class SortType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
BEST("best"),
|
BEST("best", "Best"),
|
||||||
HOT("hot"),
|
HOT("hot", "Hot"),
|
||||||
NEW("new"),
|
NEW("new", "New"),
|
||||||
RANDOM("random"),
|
RANDOM("random", "Random"),
|
||||||
RISING("rising"),
|
RISING("rising", "Rising"),
|
||||||
TOP("top"),
|
TOP("top", "Top"),
|
||||||
CONTROVERSIAL("controversial"),
|
CONTROVERSIAL("controversial", "Controversial"),
|
||||||
RELEVANCE("relevance"),
|
RELEVANCE("relevance", "Relevance"),
|
||||||
COMMENTS("comments"),
|
COMMENTS("comments", "Comments"),
|
||||||
ACTIVITY("activity"),
|
ACTIVITY("activity", "Activity"),
|
||||||
CONFIDENCE("confidence"),
|
CONFIDENCE("confidence", "Confidence"),
|
||||||
OLD("old"),
|
OLD("old", "Old"),
|
||||||
QA("qa"),
|
QA("qa", "QA"),
|
||||||
LIVE("live");
|
LIVE("live", "Live");
|
||||||
|
|
||||||
public final String value;
|
public final String value;
|
||||||
|
public final String fullName;
|
||||||
|
|
||||||
Type(String value) {
|
Type(String value, String fullName) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
this.fullName = fullName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Time {
|
public enum Time {
|
||||||
HOUR("hour"),
|
HOUR("hour", "Hour"),
|
||||||
DAY("day"),
|
DAY("day", "Day"),
|
||||||
WEEK("week"),
|
WEEK("week", "Week"),
|
||||||
MONTH("month"),
|
MONTH("month", "Month"),
|
||||||
YEAR("year"),
|
YEAR("year", "Year"),
|
||||||
ALL("all");
|
ALL("all", "All Time");
|
||||||
|
|
||||||
public final String value;
|
public final String value;
|
||||||
|
public final String fullName;
|
||||||
|
|
||||||
Time(String value) {
|
Time(String value, String fullName) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
this.fullName = fullName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,12 @@ import android.text.Html;
|
|||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
private static final long SECOND_MILLIS = 1000;
|
private static final long SECOND_MILLIS = 1000;
|
||||||
@ -104,4 +107,14 @@ public class Utils {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void displaySortTypeInToolbar(SortType sortType, Toolbar toolbar) {
|
||||||
|
if (sortType != null) {
|
||||||
|
if (sortType.getTime() != null) {
|
||||||
|
toolbar.setSubtitle(sortType.getType().fullName + " " + sortType.getTime().fullName);
|
||||||
|
} else {
|
||||||
|
toolbar.setSubtitle(sortType.getType().fullName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user