From 7e7234d0bcf950a66c4ad4654aa11e74b0c73c51 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 17 Mar 2022 13:39:58 +0100 Subject: [PATCH] changing some code to avoid ConcurrentModificationExceptions --- .../notes/pro/fragments/ChecklistFragment.kt | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt index 76edfeeb..7eee0ec2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt @@ -191,20 +191,19 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener { return } - ensureBackgroundThread { - context?.let { ctx -> - note?.let { currentNote -> - if (refreshIndex != -1) { - view.checklist_list.post { - view.checklist_list.adapter?.notifyItemChanged(refreshIndex) - } - } - - currentNote.value = getChecklistItems() - saveNoteValue(note!!, currentNote.value) - ctx.updateWidgets() + if (note != null) { + if (refreshIndex != -1) { + view.checklist_list.post { + view.checklist_list.adapter?.notifyItemChanged(refreshIndex) } } + + note!!.value = getChecklistItems() + + ensureBackgroundThread { + saveNoteValue(note!!, note!!.value) + context?.updateWidgets() + } } }