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() |         positions.sortDescending() | ||||||
|         removeSelectedItems(positions) |         removeSelectedItems(positions) | ||||||
|  |  | ||||||
|         listener?.saveChecklist() |         listener?.saveChecklist { | ||||||
|             if (items.isEmpty()) { |             if (items.isEmpty()) { | ||||||
|             listener?.refreshItems() |                 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) { |         if (note == null) { | ||||||
|             return |             return | ||||||
|         } |         } | ||||||
| @@ -215,6 +215,7 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener { | |||||||
|             ensureBackgroundThread { |             ensureBackgroundThread { | ||||||
|                 saveNoteValue(note!!, note!!.value) |                 saveNoteValue(note!!, note!!.value) | ||||||
|                 context?.updateWidgets() |                 context?.updateWidgets() | ||||||
|  |                 activity?.runOnUiThread(callback) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -235,8 +236,8 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener { | |||||||
|  |  | ||||||
|     fun getChecklistItems() = Gson().toJson(items) |     fun getChecklistItems() = Gson().toJson(items) | ||||||
|  |  | ||||||
|     override fun saveChecklist() { |     override fun saveChecklist(callback: () -> Unit) { | ||||||
|         saveNote() |         saveNote(callback = callback) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun refreshItems() { |     override fun refreshItems() { | ||||||
|   | |||||||
| @@ -3,5 +3,5 @@ package com.simplemobiletools.notes.pro.interfaces | |||||||
| interface ChecklistItemsListener { | interface ChecklistItemsListener { | ||||||
|     fun refreshItems() |     fun refreshItems() | ||||||
|  |  | ||||||
|     fun saveChecklist() |     fun saveChecklist(callback: () -> Unit = {}) | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user