Skip to content

Commit b57be1b

Browse files
committed
Added support for own sorting in OpenNoteDialog
1 parent dec0498 commit b57be1b

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

app/src/main/kotlin/org/fossify/notes/adapters/OpenNoteAdapter.kt

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,16 @@ class OpenNoteAdapter(
125125
val taskType = object : TypeToken<List<Task>>() {}.type
126126
var items = Gson().fromJson<List<Task>>(getNoteStoredValue(context), taskType) ?: listOf()
127127
items = items.let {
128-
val sorting = context.config.sorting
128+
val sorting = context.config.getSorting(id)
129129
Task.sorting = sorting
130+
var result = it
130131
if (Task.sorting and SORT_BY_CUSTOM == 0) {
131-
it.sorted().let {
132-
if (context.config.getMoveDoneChecklistItems(null)) {
133-
it.sortedBy { it.isDone }
134-
} else {
135-
it
136-
}
137-
}
138-
} else {
139-
it
132+
result = result.sorted()
133+
}
134+
if (context.config.getMoveDoneChecklistItems(id)) {
135+
result = result.sortedBy { it.isDone }
140136
}
137+
result
141138
}
142139

143140
val linePrefix = ""

app/src/main/kotlin/org/fossify/notes/adapters/WidgetAdapter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsServi
133133
if (sorting and SORT_BY_CUSTOM == 0) {
134134
Task.sorting = sorting
135135
tasks.sort()
136-
if (context.config.getMoveDoneChecklistItems(noteId)) {
137-
tasks.sortBy { it.isDone }
138-
}
136+
}
137+
if (context.config.getMoveDoneChecklistItems(noteId)) {
138+
tasks.sortBy { it.isDone }
139139
}
140140
}
141141
}

0 commit comments

Comments
 (0)