From 31c74b14c70f6d880fd404d70b6b3983db60d029 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 20 Feb 2021 23:28:13 +0100 Subject: [PATCH] adding a check for removing broken checklist items --- .../com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt | 3 +++ .../simplemobiletools/notes/pro/fragments/ChecklistFragment.kt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt index 45bde63f..550422ee 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt @@ -94,6 +94,9 @@ class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsServi if (note?.type == NoteType.TYPE_CHECKLIST.value) { val checklistItemType = object : TypeToken>() {}.type checklistItems = Gson().fromJson>(note!!.value, checklistItemType) ?: ArrayList(1) + + // checklist title can be null only because of the glitch in upgrade to 6.6.0, remove this check in the future + checklistItems = checklistItems.filter { it.title != null }.toMutableList() as ArrayList if (context.config.moveDoneChecklistItems) { checklistItems.sortBy { it.isDone } } 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 2d636e77..c7e34f80 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 @@ -59,6 +59,9 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener { try { val checklistItemType = object : TypeToken>() {}.type items = Gson().fromJson>(storedNote.value, checklistItemType) ?: ArrayList(1) + + // checklist title can be null only because of the glitch in upgrade to 6.6.0, remove this check in the future + items = items.filter { it.title != null }.toMutableList() as ArrayList } catch (e: Exception) { migrateCheckListOnFailure(storedNote) }