mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-19 10:00:16 +01:00
Wait for DB updates before refreshing checklist items
This commit is contained in:
parent
886a397d23
commit
2611758758
app/src/main/kotlin/com/simplemobiletools/notes/pro
@ -152,9 +152,10 @@ class ChecklistAdapter(
|
||||
positions.sortDescending()
|
||||
removeSelectedItems(positions)
|
||||
|
||||
listener?.saveChecklist()
|
||||
if (items.isEmpty()) {
|
||||
listener?.refreshItems()
|
||||
listener?.saveChecklist {
|
||||
if (items.isEmpty()) {
|
||||
listener.refreshItems()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
||||
}
|
||||
}
|
||||
|
||||
private fun saveNote(refreshIndex: Int = -1) {
|
||||
private fun saveNote(refreshIndex: Int = -1, callback: () -> Unit = {}) {
|
||||
if (note == null) {
|
||||
return
|
||||
}
|
||||
@ -215,6 +215,7 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
||||
ensureBackgroundThread {
|
||||
saveNoteValue(note!!, note!!.value)
|
||||
context?.updateWidgets()
|
||||
activity?.runOnUiThread(callback)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -235,8 +236,8 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
||||
|
||||
fun getChecklistItems() = Gson().toJson(items)
|
||||
|
||||
override fun saveChecklist() {
|
||||
saveNote()
|
||||
override fun saveChecklist(callback: () -> Unit) {
|
||||
saveNote(callback = callback)
|
||||
}
|
||||
|
||||
override fun refreshItems() {
|
||||
|
@ -3,5 +3,5 @@ package com.simplemobiletools.notes.pro.interfaces
|
||||
interface ChecklistItemsListener {
|
||||
fun refreshItems()
|
||||
|
||||
fun saveChecklist()
|
||||
fun saveChecklist(callback: () -> Unit = {})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user