mirror of
				https://github.com/SimpleMobileTools/Simple-Notes.git
				synced 2025-06-05 17:00:23 +02:00 
			
		
		
		
	Wait for DB updates before refreshing checklist items
This commit is contained in:
		| @@ -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 = {}) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user