diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/bottomsheetfragments/SearchPostSortTypeBottomSheetFragment.java b/app/src/main/java/eu/toldi/infinityforlemmy/bottomsheetfragments/SearchPostSortTypeBottomSheetFragment.java index f64c5833..ee140a12 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/bottomsheetfragments/SearchPostSortTypeBottomSheetFragment.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/bottomsheetfragments/SearchPostSortTypeBottomSheetFragment.java @@ -31,16 +31,12 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun public static final String EXTRA_CURRENT_SORT_TYPE = "ECST"; - @BindView(R.id.relevance_type_text_view_search_sort_type_bottom_sheet_fragment) - TextView relevanceTypeTextView; - @BindView(R.id.hot_type_text_view_search_sort_type_bottom_sheet_fragment) - TextView hotTypeTextView; @BindView(R.id.top_type_text_view_search_sort_type_bottom_sheet_fragment) TextView topTypeTextView; @BindView(R.id.new_type_text_view_search_sort_type_bottom_sheet_fragment) TextView newTypeTextView; - @BindView(R.id.comments_type_text_view_search_sort_type_bottom_sheet_fragment) - TextView commentsTypeTextView; + @BindView(R.id.old_type_text_view_search_sort_type_bottom_sheet_fragment) + TextView oldTypeTextView; private BaseActivity activity; public SearchPostSortTypeBottomSheetFragment() { // Required empty public constructor @@ -61,14 +57,12 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun ButterKnife.bind(this, rootView); String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE); - if (currentSortType.equals(SortType.Type.HOT.fullName)) { - hotTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(hotTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); - } else if (currentSortType.equals(SortType.Type.TOP.fullName)) { + if (currentSortType.equals(SortType.Type.TOP.fullName)) { topTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(topTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.NEW.fullName)) { newTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(newTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.OLD.fullName)) { - commentsTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(commentsTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + oldTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(oldTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O @@ -76,15 +70,6 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); } - /*relevanceTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.RELEVANCE.name()); - dismiss(); - });*/ - - hotTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.HOT.name()); - dismiss(); - }); topTypeTextView.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name()); @@ -92,12 +77,12 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun }); newTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW)); + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW,null)); dismiss(); }); - commentsTypeTextView.setOnClickListener(view -> { - ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.MOST_COMMENTS.name()); + oldTypeTextView.setOnClickListener(view -> { + ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.OLD,null)); dismiss(); }); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/fragments/PostFragment.java b/app/src/main/java/eu/toldi/infinityforlemmy/fragments/PostFragment.java index 9ad61c9a..8d2e6d6d 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/fragments/PostFragment.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/fragments/PostFragment.java @@ -460,9 +460,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator { nameOfUsage = PostFilterUsage.NO_USAGE; String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, SortType.Type.TOP_ALL.value); - String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, SortType.Time.ALL.name()); + String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, sort.equalsIgnoreCase(SortType.Type.TOP.value) ? SortType.Time.ALL.name() : null); SortType.Type st = SortType.Type.fromValue(sort); - sortType = new SortType(st == null ? SortType.Type.TOP_ALL : st, SortType.Time.valueOf(sortTime)); + sortType = new SortType(st == null ? SortType.Type.TOP_ALL : st,sortTime != null ? SortType.Time.valueOf(sortTime) : null); postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout); mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit, @@ -1385,6 +1385,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, sortType.getType().name()).apply(); if (sortType.getTime() != null) { mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, sortType.getTime().name()).apply(); + }else { + mSortTypeSharedPreferences.edit().remove(SharedPreferencesUtils.SORT_TIME_SEARCH_POST).apply(); } break; case PostPagingSource.TYPE_MULTI_REDDIT: diff --git a/app/src/main/res/layout/fragment_search_post_sort_type_bottom_sheet.xml b/app/src/main/res/layout/fragment_search_post_sort_type_bottom_sheet.xml index 8b1c86b6..e7c06c29 100644 --- a/app/src/main/res/layout/fragment_search_post_sort_type_bottom_sheet.xml +++ b/app/src/main/res/layout/fragment_search_post_sort_type_bottom_sheet.xml @@ -11,43 +11,6 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - -