Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2611758

Browse files
committed
Wait for DB updates before refreshing checklist items
1 parent 886a397 commit 2611758

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

‎app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,10 @@ class ChecklistAdapter(
152152
positions.sortDescending()
153153
removeSelectedItems(positions)
154154

155-
listener?.saveChecklist()
156-
if (items.isEmpty()) {
157-
listener?.refreshItems()
155+
listener?.saveChecklist {
156+
if (items.isEmpty()) {
157+
listener.refreshItems()
158+
}
158159
}
159160
}
160161

‎app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
190190
}
191191
}
192192

193-
private fun saveNote(refreshIndex: Int = -1) {
193+
private fun saveNote(refreshIndex: Int = -1, callback: () ->Unit = {}) {
194194
if (note == null) {
195195
return
196196
}
@@ -215,6 +215,7 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
215215
ensureBackgroundThread {
216216
saveNoteValue(note!!, note!!.value)
217217
context?.updateWidgets()
218+
activity?.runOnUiThread(callback)
218219
}
219220
}
220221
}
@@ -235,8 +236,8 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
235236

236237
fun getChecklistItems() = Gson().toJson(items)
237238

238-
override fun saveChecklist() {
239-
saveNote()
239+
override fun saveChecklist(callback: () ->Unit) {
240+
saveNote(callback = callback)
240241
}
241242

242243
override fun refreshItems() {

‎app/src/main/kotlin/com/simplemobiletools/notes/pro/interfaces/ChecklistItemsListener.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ package com.simplemobiletools.notes.pro.interfaces
33
interface ChecklistItemsListener {
44
fun refreshItems()
55

6-
fun saveChecklist()
6+
fun saveChecklist(callback: () ->Unit = {})
77
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /