Fix some issues related to showing sort type on toolbars.

This commit is contained in:
Alex Ning 2020-06-05 23:28:04 +08:00
parent e9ffe5a13c
commit ff5691aecb
2 changed files with 21 additions and 7 deletions

View File

@ -1375,15 +1375,29 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
void displaySortTypeInToolbar() {
switch (viewPager.getCurrentItem()) {
case 0:
if (tab1 != null) {
SortType sortType = tab1.getSortType();
Utils.displaySortTypeInToolbar(sortType, toolbar);
if (mAccessToken != null) {
if (tab1 != null) {
SortType sortType = tab1.getSortType();
Utils.displaySortTypeInToolbar(sortType, toolbar);
}
} else {
if (tab2 != null) {
SortType sortType = tab2.getSortType();
Utils.displaySortTypeInToolbar(sortType, toolbar);
}
}
break;
case 1:
if (tab2 != null) {
SortType sortType = tab2.getSortType();
Utils.displaySortTypeInToolbar(sortType, toolbar);
if (mAccessToken != null) {
if (tab2 != null) {
SortType sortType = tab2.getSortType();
Utils.displaySortTypeInToolbar(sortType, toolbar);
}
} else {
if (tab3 != null) {
SortType sortType = tab3.getSortType();
Utils.displaySortTypeInToolbar(sortType, toolbar);
}
}
break;
case 2:

View File

@ -345,7 +345,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
};
mSingleCommentId = getIntent().getStringExtra(EXTRA_SINGLE_COMMENT_ID);
sortType = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, SortType.Type.BEST.value);
sortType = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, SortType.Type.BEST.value.toUpperCase());
mToolbar.setTitle(new SortType(SortType.Type.valueOf(sortType)).getType().fullName);
sortType = sortType.toLowerCase();
if (savedInstanceState == null) {