Fix issue with default sort times

Previously, if the default sort type is set to "top of x time", most failed to load any posts.
This commit is contained in:
Balazs Toldi 2023-08-11 08:42:16 +02:00
parent 82414bba55
commit 3afd2601f0
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
2 changed files with 15 additions and 16 deletions

View File

@ -137,7 +137,6 @@ import eu.toldi.infinityforlemmy.post.PostPagingSource;
import eu.toldi.infinityforlemmy.post.PostViewModel;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import eu.toldi.infinityforlemmy.postfilter.PostFilterUsage;
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import eu.toldi.infinityforlemmy.utils.Utils;
import eu.toldi.infinityforlemmy.videoautoplay.ExoCreator;
@ -530,7 +529,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName,
mSharedPreferences.getString(SharedPreferencesUtils.SUBREDDIT_DEFAULT_SORT_TYPE, SortType.Type.HOT.name()));
if (sort.equals(sort.equals(SortType.Type.TOP.name()))) {
if (sort.equalsIgnoreCase(SortType.Type.TOP.value)) {
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName,
mSharedPreferences.getString(SharedPreferencesUtils.SUBREDDIT_DEFAULT_SORT_TIME, SortType.Time.ALL.name()));
}
@ -538,7 +537,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, defaultPostLayout);
if (sortTime != null) {
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
sortType = new SortType(SortType.Type.fromValue(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
}
@ -670,10 +669,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username,
mSharedPreferences.getString(SharedPreferencesUtils.USER_DEFAULT_SORT_TYPE, SortType.Type.NEW.name()));
if (sort.equals(SortType.Type.TOP.name())) {
if (sort.equalsIgnoreCase(SortType.Type.TOP.value)) {
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username,
mSharedPreferences.getString(SharedPreferencesUtils.USER_DEFAULT_SORT_TIME, SortType.Time.ALL.name()));
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
sortType = new SortType(SortType.Type.fromValue(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
}

View File

@ -543,17 +543,17 @@
</string-array>
<string-array name="settings_default_sort_time_values">
<item>HOUR</item>
<item>6HOURS</item>
<item>12HOURS</item>
<item>DAY</item>
<item>WEEK</item>
<item>MONTH</item>
<item>3MONTHS</item>
<item>6MONTHS</item>
<item>9MONTHS</item>
<item>YEAR</item>
<item>ALL</item>
<item>TopHour</item>
<item>TopSixHour</item>
<item>TopTwelveHour</item>
<item>TopDay</item>
<item>TopWeek</item>
<item>TopMonth</item>
<item>TopThreeMonths</item>
<item>TopSixMonths</item>
<item>TopNineMonths</item>
<item>TopYear</item>
<item>TopAll</item>
</string-array>
<string-array name="settings_default_search_result_tab">