Skip to content

Commit 7dac440

Browse files
Merge pull request #2611 from Kokika/bugfix/sort-descending-lexicographical
Bugfix/Correct sort descending lexicographical
2 parents d18db81 + f2cb10a commit 7dac440

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,13 @@ protected void onCreate(Bundle savedInstanceState) {
262262
updateSortMethodIcon(methodOfCategory.second);
263263
activityBinding.sortingMethod.setOnClickListener((v) -> {
264264
if (methodOfCategory.first != null) {
265+
int newId = 0;
266+
if (methodOfCategory.second != null)
267+
{
268+
newId = methodOfCategory.second.getId();
269+
}
265270
//Rotate for next sorting method
266-
var newMethod = CategorySortingMethod.findById(methodOfCategory.second.getId() + 1);
271+
var newMethod = CategorySortingMethod.findById(newId + 1);
267272
final var modifyLiveData = mainViewModel.modifyCategoryOrder(methodOfCategory.first, newMethod);
268273
modifyLiveData.observe(this, (next) -> modifyLiveData.removeObservers(this));
269274
}

app/src/main/java/it/niedermann/owncloud/notes/main/MainViewModel.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import static it.niedermann.owncloud.notes.main.slots.SlotterUtil.fillListByInitials;
1717
import static it.niedermann.owncloud.notes.main.slots.SlotterUtil.fillListByTime;
1818
import static it.niedermann.owncloud.notes.shared.model.CategorySortingMethod.SORT_MODIFIED_DESC;
19-
import static it.niedermann.owncloud.notes.shared.model.CategorySortingMethod.SORT_LEXICOGRAPHICAL_ASC;
19+
import static it.niedermann.owncloud.notes.shared.model.CategorySortingMethod.SORT_LEXICOGRAPHICAL_DESC;
2020
import static it.niedermann.owncloud.notes.shared.model.ENavigationCategoryType.DEFAULT_CATEGORY;
2121
import static it.niedermann.owncloud.notes.shared.model.ENavigationCategoryType.FAVORITES;
2222
import static it.niedermann.owncloud.notes.shared.model.ENavigationCategoryType.RECENT;
@@ -273,6 +273,9 @@ public LiveData<List<Item>> getNotesListLiveData() {
273273
}
274274

275275
private List<Item> fromNotes(List<Note> noteList, @NonNull NavigationCategory selectedCategory, @Nullable CategorySortingMethod sortingMethod) {
276+
if(sortingMethod == SORT_LEXICOGRAPHICAL_DESC){
277+
Collections.reverse(noteList);
278+
}
276279
if (selectedCategory.getType() == DEFAULT_CATEGORY) {
277280
final String category = selectedCategory.getCategory();
278281
if (category != null) {
@@ -284,9 +287,6 @@ private List<Item> fromNotes(List<Note> noteList, @NonNull NavigationCategory se
284287
if (sortingMethod == SORT_MODIFIED_DESC) {
285288
return fillListByTime(getApplication(), noteList);
286289
}
287-
if(sortingMethod != SORT_LEXICOGRAPHICAL_ASC){
288-
Collections.reverse(noteList);
289-
}
290290
return fillListByInitials(getApplication(), noteList);
291291
}
292292

app/src/main/res/drawable/alphabetical_desc.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
~
55
~ SPDX-FileCopyrightText: 2018-2024 Google LLC
66
~ SPDX-FileCopyrightText: 2018-2024 Andy Scherzinger
7+
~ SPDX-FileCopyrightText: 2024-2025 Kornél Szekeres
78
~ SPDX-License-Identifier: Apache-2.0
89
-->
910
<vector xmlns:android="http://schemas.android.com/apk/res/android"

0 commit comments

Comments
 (0)