mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-09 16:08:43 +01:00
Create sort type and post layout shared preferences.
This commit is contained in:
parent
ea27af4080
commit
ca599fede5
@ -64,6 +64,9 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("post_layout")
|
||||||
|
SharedPreferences mPostLayoutSharedPreferences;
|
||||||
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
private boolean isInLazyMode = false;
|
private boolean isInLazyMode = false;
|
||||||
private boolean mNullAccessToken = false;
|
private boolean mNullAccessToken = false;
|
||||||
@ -281,7 +284,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
|
|||||||
@Override
|
@Override
|
||||||
public void postLayoutSelected(int postLayout) {
|
public void postLayoutSelected(int postLayout) {
|
||||||
if (mFragment != null) {
|
if (mFragment != null) {
|
||||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + mAccountName, postLayout).apply();
|
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + mAccountName, postLayout).apply();
|
||||||
((FragmentCommunicator) mFragment).changePostLayout(postLayout);
|
((FragmentCommunicator) mFragment).changePostLayout(postLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,9 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("post_layout")
|
||||||
|
SharedPreferences mPostLayoutSharedPreferences;
|
||||||
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
private boolean isInLazyMode = false;
|
private boolean isInLazyMode = false;
|
||||||
private boolean mNullAccessToken = false;
|
private boolean mNullAccessToken = false;
|
||||||
@ -399,16 +402,16 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
|
|||||||
if (mFragment != null) {
|
if (mFragment != null) {
|
||||||
switch (postType) {
|
switch (postType) {
|
||||||
case PostDataSource.TYPE_FRONT_PAGE:
|
case PostDataSource.TYPE_FRONT_PAGE:
|
||||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, postLayout).apply();
|
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, postLayout).apply();
|
||||||
break;
|
break;
|
||||||
case PostDataSource.TYPE_SUBREDDIT:
|
case PostDataSource.TYPE_SUBREDDIT:
|
||||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + name, postLayout).apply();
|
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + name, postLayout).apply();
|
||||||
break;
|
break;
|
||||||
case PostDataSource.TYPE_USER:
|
case PostDataSource.TYPE_USER:
|
||||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + name, postLayout).apply();
|
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + name, postLayout).apply();
|
||||||
break;
|
break;
|
||||||
case PostDataSource.TYPE_SEARCH:
|
case PostDataSource.TYPE_SEARCH:
|
||||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, postLayout).apply();
|
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, postLayout).apply();
|
||||||
}
|
}
|
||||||
((FragmentCommunicator) mFragment).changePostLayout(postLayout);
|
((FragmentCommunicator) mFragment).changePostLayout(postLayout);
|
||||||
}
|
}
|
||||||
|
@ -161,6 +161,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("sort_type")
|
||||||
|
SharedPreferences mSortTypeSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
@Named("post_layout")
|
||||||
|
SharedPreferences mPostLayoutSharedPreferences;
|
||||||
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||||
private AppBarLayout.LayoutParams params;
|
private AppBarLayout.LayoutParams params;
|
||||||
@ -1188,25 +1194,25 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
} else {
|
} else {
|
||||||
switch (viewPager.getCurrentItem()) {
|
switch (viewPager.getCurrentItem()) {
|
||||||
case 0:
|
case 0:
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, sortType.getType().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, sortType.getType().name()).apply();
|
||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_BEST_POST, sortType.getTime().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_BEST_POST, sortType.getTime().name()).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
frontPagePostFragment.changeSortType(sortType);
|
frontPagePostFragment.changeSortType(sortType);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_POPULAR_POST, sortType.getType().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_POPULAR_POST, sortType.getType().name()).apply();
|
||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_POPULAR_POST, sortType.getTime().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_POPULAR_POST, sortType.getTime().name()).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
popularPostFragment.changeSortType(sortType);
|
popularPostFragment.changeSortType(sortType);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_ALL_POST, sortType.getType().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_ALL_POST, sortType.getType().name()).apply();
|
||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_ALL_POST, sortType.getTime().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_ALL_POST, sortType.getTime().name()).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
allPostFragment.changeSortType(sortType);
|
allPostFragment.changeSortType(sortType);
|
||||||
@ -1261,12 +1267,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
if (mAccessToken == null) {
|
if (mAccessToken == null) {
|
||||||
if (viewPager.getCurrentItem() == 0) {
|
if (viewPager.getCurrentItem() == 0) {
|
||||||
if (popularPostFragment != null) {
|
if (popularPostFragment != null) {
|
||||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_POPULAR_POST, postLayout).apply();
|
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_POPULAR_POST, postLayout).apply();
|
||||||
popularPostFragment.changePostLayout(postLayout);
|
popularPostFragment.changePostLayout(postLayout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (allPostFragment != null) {
|
if (allPostFragment != null) {
|
||||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_ALL_POST, postLayout).apply();
|
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_ALL_POST, postLayout).apply();
|
||||||
allPostFragment.changePostLayout(postLayout);
|
allPostFragment.changePostLayout(postLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1274,19 +1280,19 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
switch (viewPager.getCurrentItem()) {
|
switch (viewPager.getCurrentItem()) {
|
||||||
case 0:
|
case 0:
|
||||||
if (frontPagePostFragment != null) {
|
if (frontPagePostFragment != null) {
|
||||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, postLayout).apply();
|
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, postLayout).apply();
|
||||||
frontPagePostFragment.changePostLayout(postLayout);
|
frontPagePostFragment.changePostLayout(postLayout);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (popularPostFragment != null) {
|
if (popularPostFragment != null) {
|
||||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_POPULAR_POST, postLayout).apply();
|
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_POPULAR_POST, postLayout).apply();
|
||||||
popularPostFragment.changePostLayout(postLayout);
|
popularPostFragment.changePostLayout(postLayout);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (allPostFragment != null) {
|
if (allPostFragment != null) {
|
||||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_ALL_POST, postLayout).apply();
|
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_ALL_POST, postLayout).apply();
|
||||||
allPostFragment.changePostLayout(postLayout);
|
allPostFragment.changePostLayout(postLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,12 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("sort_type")
|
||||||
|
SharedPreferences mSortTypeSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
@Named("post_layout")
|
||||||
|
SharedPreferences mPostLayoutSharedPreferences;
|
||||||
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
private boolean mNullAccessToken = false;
|
private boolean mNullAccessToken = false;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
@ -375,9 +381,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
}
|
}
|
||||||
|
|
||||||
void changeSortType(SortType sortType) {
|
void changeSortType(SortType sortType) {
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, sortType.getType().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, sortType.getType().name()).apply();
|
||||||
if(sortType.getTime() != null) {
|
if(sortType.getTime() != null) {
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, sortType.getTime().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, sortType.getTime().name()).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
postFragment.changeSortType(sortType);
|
postFragment.changeSortType(sortType);
|
||||||
@ -386,11 +392,11 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
void changeSortType(SortType sortType, int fragmentPosition) {
|
void changeSortType(SortType sortType, int fragmentPosition) {
|
||||||
switch (fragmentPosition) {
|
switch (fragmentPosition) {
|
||||||
case 1:
|
case 1:
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_SUBREDDIT, sortType.getType().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_SUBREDDIT, sortType.getType().name()).apply();
|
||||||
subredditListingFragment.changeSortType(sortType);
|
subredditListingFragment.changeSortType(sortType);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
mSharedPreferences.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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -417,7 +423,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
|
|
||||||
void changePostLayout(int postLayout) {
|
void changePostLayout(int postLayout) {
|
||||||
if (postFragment != null) {
|
if (postFragment != null) {
|
||||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, postLayout).apply();
|
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, postLayout).apply();
|
||||||
((FragmentCommunicator) postFragment).changePostLayout(postLayout);
|
((FragmentCommunicator) postFragment).changePostLayout(postLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,12 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("sort_type")
|
||||||
|
SharedPreferences mSortTypeSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
@Named("post_layout")
|
||||||
|
SharedPreferences mPostLayoutSharedPreferences;
|
||||||
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
private boolean mNullAccessToken = false;
|
private boolean mNullAccessToken = false;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
@ -284,10 +290,10 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sortTypeSelected(SortType sortType) {
|
public void sortTypeSelected(SortType sortType) {
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiPath,
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiPath,
|
||||||
sortType.getType().name()).apply();
|
sortType.getType().name()).apply();
|
||||||
if(sortType.getTime() != null) {
|
if(sortType.getTime() != null) {
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE+ multiPath,
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE+ multiPath,
|
||||||
sortType.getTime().name()).apply();
|
sortType.getTime().name()).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,7 +311,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
@Override
|
@Override
|
||||||
public void postLayoutSelected(int postLayout) {
|
public void postLayoutSelected(int postLayout) {
|
||||||
if (mFragment != null) {
|
if (mFragment != null) {
|
||||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiPath, postLayout).apply();
|
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiPath, postLayout).apply();
|
||||||
((FragmentCommunicator) mFragment).changePostLayout(postLayout);
|
((FragmentCommunicator) mFragment).changePostLayout(postLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,6 +159,9 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("sort_type")
|
||||||
|
SharedPreferences mSortTypeSharedPreferences;
|
||||||
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
private RequestManager mGlide;
|
private RequestManager mGlide;
|
||||||
private Locale mLocale;
|
private Locale mLocale;
|
||||||
@ -558,7 +561,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
mSwipeRefreshLayout.setRefreshing(true);
|
mSwipeRefreshLayout.setRefreshing(true);
|
||||||
mGlide.clear(mFetchPostInfoImageView);
|
mGlide.clear(mFetchPostInfoImageView);
|
||||||
|
|
||||||
String sortType = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, SortType.Type.BEST.value).toLowerCase();
|
String sortType = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, SortType.Type.BEST.value).toLowerCase();
|
||||||
|
|
||||||
|
|
||||||
Call<String> postAndComments;
|
Call<String> postAndComments;
|
||||||
@ -836,7 +839,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fetchComments(boolean changeRefreshState) {
|
private void fetchComments(boolean changeRefreshState) {
|
||||||
String sortType = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT,
|
String sortType = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT,
|
||||||
SortType.Type.BEST.value).toLowerCase();
|
SortType.Type.BEST.value).toLowerCase();
|
||||||
fetchComments(changeRefreshState, true, sortType);
|
fetchComments(changeRefreshState, true, sortType);
|
||||||
}
|
}
|
||||||
@ -1582,7 +1585,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
children.clear();
|
children.clear();
|
||||||
}
|
}
|
||||||
fetchComments(false, false, sortType.getType().value);
|
fetchComments(false, false, sortType.getType().value);
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, sortType.getType().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, sortType.getType().name()).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lockSwipeRightToGoBack() {
|
public void lockSwipeRightToGoBack() {
|
||||||
|
@ -147,6 +147,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("sort_type")
|
||||||
|
SharedPreferences mSortTypeSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
@Named("post_layout")
|
||||||
|
SharedPreferences mPostLayoutSharedPreferences;
|
||||||
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
public SubredditViewModel mSubredditViewModel;
|
public SubredditViewModel mSubredditViewModel;
|
||||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||||
@ -774,7 +780,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postLayoutSelected(int postLayout) {
|
public void postLayoutSelected(int postLayout) {
|
||||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, postLayout).apply();
|
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, postLayout).apply();
|
||||||
sectionsPagerAdapter.changePostLayout(postLayout);
|
sectionsPagerAdapter.changePostLayout(postLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -914,9 +920,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
|
|
||||||
public void changeSortType(SortType sortType) {
|
public void changeSortType(SortType sortType) {
|
||||||
if (postFragment != null) {
|
if (postFragment != null) {
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, sortType.getType().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, sortType.getType().name()).apply();
|
||||||
if(sortType.getTime() != null) {
|
if(sortType.getTime() != null) {
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName, sortType.getTime().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName, sortType.getTime().name()).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
postFragment.changeSortType(sortType);
|
postFragment.changeSortType(sortType);
|
||||||
@ -931,7 +937,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
|
|
||||||
void changePostLayout(int postLayout) {
|
void changePostLayout(int postLayout) {
|
||||||
if (postFragment != null) {
|
if (postFragment != null) {
|
||||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, postLayout).apply();
|
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, postLayout).apply();
|
||||||
((FragmentCommunicator) postFragment).changePostLayout(postLayout);
|
((FragmentCommunicator) postFragment).changePostLayout(postLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,12 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("sort_type")
|
||||||
|
SharedPreferences mSortTypeSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
@Named("post_layout")
|
||||||
|
SharedPreferences mPostLayoutSharedPreferences;
|
||||||
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
public UserViewModel userViewModel;
|
public UserViewModel userViewModel;
|
||||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||||
@ -811,18 +817,18 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
public void changeSortType(SortType sortType) {
|
public void changeSortType(SortType sortType) {
|
||||||
if (viewPager.getCurrentItem() == 0) {
|
if (viewPager.getCurrentItem() == 0) {
|
||||||
if (postFragment != null) {
|
if (postFragment != null) {
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username, sortType.getType().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username, sortType.getType().name()).apply();
|
||||||
if(sortType.getTime() != null) {
|
if(sortType.getTime() != null) {
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username, sortType.getTime().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username, sortType.getTime().name()).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
postFragment.changeSortType(sortType);
|
postFragment.changeSortType(sortType);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (commentsListingFragment != null) {
|
if (commentsListingFragment != null) {
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_USER_COMMENT, sortType.getType().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_USER_COMMENT, sortType.getType().name()).apply();
|
||||||
if(sortType.getTime() != null) {
|
if(sortType.getTime() != null) {
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_USER_COMMENT, sortType.getTime().name()).apply();
|
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_USER_COMMENT, sortType.getTime().name()).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
commentsListingFragment.changeSortType(sortType);
|
commentsListingFragment.changeSortType(sortType);
|
||||||
@ -838,7 +844,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
|
|
||||||
void changePostLayout(int postLayout) {
|
void changePostLayout(int postLayout) {
|
||||||
if (postFragment != null) {
|
if (postFragment != null) {
|
||||||
mSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, postLayout).apply();
|
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, postLayout).apply();
|
||||||
((FragmentCommunicator) postFragment).changePostLayout(postLayout);
|
((FragmentCommunicator) postFragment).changePostLayout(postLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import dagger.Provides;
|
|||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import okhttp3.ConnectionPool;
|
import okhttp3.ConnectionPool;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -127,6 +128,18 @@ class AppModule {
|
|||||||
return mApplication.getSharedPreferences(CustomThemeSharedPreferencesUtils.AMOLED_THEME_SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE);
|
return mApplication.getSharedPreferences(CustomThemeSharedPreferencesUtils.AMOLED_THEME_SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Named("sort_type")
|
||||||
|
SharedPreferences provideSortTypeSharedPreferences() {
|
||||||
|
return mApplication.getSharedPreferences(SharedPreferencesUtils.SORT_TYPE_SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Named("post_layout")
|
||||||
|
SharedPreferences providePostLayoutSharedPreferences() {
|
||||||
|
return mApplication.getSharedPreferences(SharedPreferencesUtils.POST_LAYOUT_SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
CustomThemeWrapper provideCustomThemeWrapper(@Named("light_theme") SharedPreferences lightThemeSharedPreferences,
|
CustomThemeWrapper provideCustomThemeWrapper(@Named("light_theme") SharedPreferences lightThemeSharedPreferences,
|
||||||
|
@ -84,6 +84,12 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("sort_type")
|
||||||
|
SharedPreferences mSortTypeSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
@Named("post_layout")
|
||||||
|
SharedPreferences mPostLayoutSharedPreferences;
|
||||||
|
@Inject
|
||||||
CustomThemeWrapper customThemeWrapper;
|
CustomThemeWrapper customThemeWrapper;
|
||||||
private boolean mNullAccessToken = false;
|
private boolean mNullAccessToken = false;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
@ -165,10 +171,10 @@ 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 = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_COMMENT, SortType.Type.NEW.value);
|
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_COMMENT, SortType.Type.NEW.value);
|
||||||
SortType sortType;
|
SortType sortType;
|
||||||
if(sort.equals(SortType.Type.CONTROVERSIAL.value) || sort.equals(SortType.Type.TOP.value)) {
|
if(sort.equals(SortType.Type.CONTROVERSIAL.value) || sort.equals(SortType.Type.TOP.value)) {
|
||||||
String sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_COMMENT, SortType.Time.ALL.value);
|
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()));
|
||||||
|
@ -114,6 +114,12 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("sort_type")
|
||||||
|
SharedPreferences mSortTypeSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
@Named("post_layout")
|
||||||
|
SharedPreferences mPostLayoutSharedPreferences;
|
||||||
|
@Inject
|
||||||
CustomThemeWrapper customThemeWrapper;
|
CustomThemeWrapper customThemeWrapper;
|
||||||
private RequestManager mGlide;
|
private RequestManager mGlide;
|
||||||
private AppCompatActivity activity;
|
private AppCompatActivity activity;
|
||||||
@ -329,10 +335,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
String subredditName = getArguments().getString(EXTRA_NAME);
|
String subredditName = getArguments().getString(EXTRA_NAME);
|
||||||
String query = getArguments().getString(EXTRA_QUERY);
|
String query = getArguments().getString(EXTRA_QUERY);
|
||||||
|
|
||||||
String sort = mSharedPreferences.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 = mSharedPreferences.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 sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
|
||||||
postLayout = mSharedPreferences.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,
|
||||||
customThemeWrapper, accessToken, postType, postLayout, true,
|
customThemeWrapper, accessToken, postType, postLayout, true,
|
||||||
@ -373,24 +379,24 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
boolean displaySubredditName = subredditName != null && (subredditName.equals("popular") || subredditName.equals("all"));
|
boolean displaySubredditName = subredditName != null && (subredditName.equals("popular") || subredditName.equals("all"));
|
||||||
if(displaySubredditName) {
|
if(displaySubredditName) {
|
||||||
if(subredditName.equals("popular")) {
|
if(subredditName.equals("popular")) {
|
||||||
sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POPULAR_POST, SortType.Type.HOT.name());
|
sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POPULAR_POST, SortType.Type.HOT.name());
|
||||||
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())) {
|
||||||
sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_POPULAR_POST, SortType.Time.ALL.name());
|
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_POPULAR_POST, SortType.Time.ALL.name());
|
||||||
}
|
}
|
||||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_POPULAR_POST, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_POPULAR_POST, defaultPostLayout);
|
||||||
} else {
|
} else {
|
||||||
sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_ALL_POST, SortType.Type.HOT.name());
|
sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_ALL_POST, SortType.Type.HOT.name());
|
||||||
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())) {
|
||||||
sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_ALL_POST, SortType.Time.ALL.name());
|
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_ALL_POST, SortType.Time.ALL.name());
|
||||||
}
|
}
|
||||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_ALL_POST, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_ALL_POST, defaultPostLayout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, SortType.Type.HOT.name());
|
sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, SortType.Type.HOT.name());
|
||||||
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())) {
|
||||||
sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName, SortType.Time.ALL.name());
|
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName, SortType.Time.ALL.name());
|
||||||
}
|
}
|
||||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, defaultPostLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sortTime != null) {
|
if(sortTime != null) {
|
||||||
@ -434,13 +440,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
String sortTime = null;
|
String sortTime = null;
|
||||||
SortType sortType;
|
SortType sortType;
|
||||||
|
|
||||||
sort = mSharedPreferences.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());
|
||||||
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())) {
|
||||||
sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
||||||
SortType.Time.ALL.name());
|
SortType.Time.ALL.name());
|
||||||
}
|
}
|
||||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
||||||
defaultPostLayout);
|
defaultPostLayout);
|
||||||
|
|
||||||
if(sortTime != null) {
|
if(sortTime != null) {
|
||||||
@ -487,15 +493,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
mFetchPostInfoLinearLayout.setLayoutParams(params);
|
mFetchPostInfoLinearLayout.setLayoutParams(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
String sort = mSharedPreferences.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;
|
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 = mSharedPreferences.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));
|
||||||
} else {
|
} else {
|
||||||
sortType = new SortType(SortType.Type.valueOf(sort));
|
sortType = new SortType(SortType.Type.valueOf(sort));
|
||||||
}
|
}
|
||||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
||||||
customThemeWrapper, accessToken, postType, postLayout, true,
|
customThemeWrapper, accessToken, postType, postLayout, true,
|
||||||
@ -528,15 +534,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
filter, nsfw)).get(PostViewModel.class);
|
filter, nsfw)).get(PostViewModel.class);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String sort = mSharedPreferences.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;
|
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 = mSharedPreferences.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));
|
||||||
} else {
|
} else {
|
||||||
sortType = new SortType(SortType.Type.valueOf(sort));
|
sortType = new SortType(SortType.Type.valueOf(sort));
|
||||||
}
|
}
|
||||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
||||||
customThemeWrapper, accessToken, postType, postLayout, true,
|
customThemeWrapper, accessToken, postType, postLayout, true,
|
||||||
@ -804,27 +810,27 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
switch (postType) {
|
switch (postType) {
|
||||||
case PostDataSource.TYPE_SUBREDDIT:
|
case PostDataSource.TYPE_SUBREDDIT:
|
||||||
if (!mSharedPreferences.contains(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + bundle.getString(EXTRA_NAME))) {
|
if (!mPostLayoutSharedPreferences.contains(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + bundle.getString(EXTRA_NAME))) {
|
||||||
changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout);
|
changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PostDataSource.TYPE_USER:
|
case PostDataSource.TYPE_USER:
|
||||||
if (!mSharedPreferences.contains(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + bundle.getString(EXTRA_USER_NAME))) {
|
if (!mPostLayoutSharedPreferences.contains(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + bundle.getString(EXTRA_USER_NAME))) {
|
||||||
changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout);
|
changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PostDataSource.TYPE_MULTI_REDDIT:
|
case PostDataSource.TYPE_MULTI_REDDIT:
|
||||||
if (!mSharedPreferences.contains(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + bundle.getString(EXTRA_NAME))) {
|
if (!mPostLayoutSharedPreferences.contains(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + bundle.getString(EXTRA_NAME))) {
|
||||||
changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout);
|
changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PostDataSource.TYPE_SEARCH:
|
case PostDataSource.TYPE_SEARCH:
|
||||||
if (!mSharedPreferences.contains(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST)) {
|
if (!mPostLayoutSharedPreferences.contains(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST)) {
|
||||||
changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout);
|
changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PostDataSource.TYPE_FRONT_PAGE:
|
case PostDataSource.TYPE_FRONT_PAGE:
|
||||||
if (!mSharedPreferences.contains(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST)) {
|
if (!mPostLayoutSharedPreferences.contains(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST)) {
|
||||||
changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout);
|
changePostLayout(changeDefaultPostLayoutEvent.defaultPostLayout);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -82,6 +82,9 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("sort_type")
|
||||||
|
SharedPreferences mSortTypeSharedPreferences;
|
||||||
|
@Inject
|
||||||
CustomThemeWrapper customThemeWrapper;
|
CustomThemeWrapper customThemeWrapper;
|
||||||
private LinearLayoutManager mLinearLayoutManager;
|
private LinearLayoutManager mLinearLayoutManager;
|
||||||
private SubredditListingRecyclerViewAdapter mAdapter;
|
private SubredditListingRecyclerViewAdapter mAdapter;
|
||||||
@ -124,7 +127,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
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 = mSharedPreferences.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 sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()));
|
||||||
|
|
||||||
mAdapter = new SubredditListingRecyclerViewAdapter(mActivity, mOauthRetrofit, mRetrofit,
|
mAdapter = new SubredditListingRecyclerViewAdapter(mActivity, mOauthRetrofit, mRetrofit,
|
||||||
|
@ -78,6 +78,9 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("sort_type")
|
||||||
|
SharedPreferences mSortTypeSharedPreferences;
|
||||||
|
@Inject
|
||||||
CustomThemeWrapper customThemeWrapper;
|
CustomThemeWrapper customThemeWrapper;
|
||||||
private LinearLayoutManager mLinearLayoutManager;
|
private LinearLayoutManager mLinearLayoutManager;
|
||||||
private String mQuery;
|
private String mQuery;
|
||||||
@ -119,7 +122,7 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
|
|||||||
mQuery = getArguments().getString(EXTRA_QUERY);
|
mQuery = getArguments().getString(EXTRA_QUERY);
|
||||||
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 = mSharedPreferences.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 sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()));
|
||||||
|
|
||||||
mAdapter = new UserListingRecyclerViewAdapter(getActivity(), mOauthRetrofit, mRetrofit,
|
mAdapter = new UserListingRecyclerViewAdapter(getActivity(), mOauthRetrofit, mRetrofit,
|
||||||
|
@ -33,6 +33,8 @@ public class SharedPreferencesUtils {
|
|||||||
public static final String IMMERSIVE_INTERFACE_KEY = "immersive_interface";
|
public static final String IMMERSIVE_INTERFACE_KEY = "immersive_interface";
|
||||||
public static final String BOTTOM_APP_BAR_KEY = "bottom_app_bar";
|
public static final String BOTTOM_APP_BAR_KEY = "bottom_app_bar";
|
||||||
public static final String VOTE_BUTTONS_ON_THE_RIGHT_KEY = "vote_buttons_on_the_right";
|
public static final String VOTE_BUTTONS_ON_THE_RIGHT_KEY = "vote_buttons_on_the_right";
|
||||||
|
|
||||||
|
public static final String SORT_TYPE_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.sort_type";
|
||||||
public static final String SORT_TYPE_BEST_POST = "sort_type_best_post";
|
public static final String SORT_TYPE_BEST_POST = "sort_type_best_post";
|
||||||
public static final String SORT_TIME_BEST_POST = "sort_time_best_post";
|
public static final String SORT_TIME_BEST_POST = "sort_time_best_post";
|
||||||
public static final String SORT_TYPE_ALL_POST = "sort_type_all_post";
|
public static final String SORT_TYPE_ALL_POST = "sort_type_all_post";
|
||||||
@ -52,6 +54,8 @@ public class SharedPreferencesUtils {
|
|||||||
public static final String SORT_TYPE_SEARCH_SUBREDDIT = "sort_type_search_subreddit";
|
public static final String SORT_TYPE_SEARCH_SUBREDDIT = "sort_type_search_subreddit";
|
||||||
public static final String SORT_TYPE_SEARCH_USER = "sort_type_search_user";
|
public static final String SORT_TYPE_SEARCH_USER = "sort_type_search_user";
|
||||||
public static final String SORT_TYPE_POST_COMMENT = "sort_type_post_comment";
|
public static final String SORT_TYPE_POST_COMMENT = "sort_type_post_comment";
|
||||||
|
|
||||||
|
public static final String POST_LAYOUT_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.post_layout";
|
||||||
public static final String POST_LAYOUT_FRONT_PAGE_POST = "post_layout_best_post";
|
public static final String POST_LAYOUT_FRONT_PAGE_POST = "post_layout_best_post";
|
||||||
public static final String POST_LAYOUT_POPULAR_POST = "post_layout_popular_post";
|
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_ALL_POST = "post_layout_all_post";
|
||||||
@ -61,6 +65,7 @@ public class SharedPreferencesUtils {
|
|||||||
public static final String POST_LAYOUT_SEARCH_POST = "post_layout_search_post";
|
public static final String POST_LAYOUT_SEARCH_POST = "post_layout_search_post";
|
||||||
public static final int POST_LAYOUT_CARD = 0;
|
public static final int POST_LAYOUT_CARD = 0;
|
||||||
public static final int POST_LAYOUT_COMPACT = 1;
|
public static final int POST_LAYOUT_COMPACT = 1;
|
||||||
|
|
||||||
public static final String PULL_NOTIFICATION_TIME = "pull_notification_time";
|
public static final String PULL_NOTIFICATION_TIME = "pull_notification_time";
|
||||||
public static final String SHOW_ELAPSED_TIME_KEY = "show_elapsed_time";
|
public static final String SHOW_ELAPSED_TIME_KEY = "show_elapsed_time";
|
||||||
public static final String DEFAULT_POST_LAYOUT_KEY = "default_post_layout";
|
public static final String DEFAULT_POST_LAYOUT_KEY = "default_post_layout";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user