Skip to content

Commit 31c74b1

Browse files
committed
adding a check for removing broken checklist items
1 parent b5f6f42 commit 31c74b1

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsServi
9494
if (note?.type == NoteType.TYPE_CHECKLIST.value) {
9595
val checklistItemType = object : TypeToken<List<ChecklistItem>>() {}.type
9696
checklistItems = Gson().fromJson<ArrayList<ChecklistItem>>(note!!.value, checklistItemType) ?: ArrayList(1)
97+
98+
// checklist title can be null only because of the glitch in upgrade to 6.6.0, remove this check in the future
99+
checklistItems = checklistItems.filter { it.title != null }.toMutableList() as ArrayList<ChecklistItem>
97100
if (context.config.moveDoneChecklistItems) {
98101
checklistItems.sortBy { it.isDone }
99102
}

app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
5959
try {
6060
val checklistItemType = object : TypeToken<List<ChecklistItem>>() {}.type
6161
items = Gson().fromJson<ArrayList<ChecklistItem>>(storedNote.value, checklistItemType) ?: ArrayList(1)
62+
63+
// checklist title can be null only because of the glitch in upgrade to 6.6.0, remove this check in the future
64+
items = items.filter { it.title != null }.toMutableList() as ArrayList<ChecklistItem>
6265
} catch (e: Exception) {
6366
migrateCheckListOnFailure(storedNote)
6467
}

0 commit comments

Comments
 (0)