mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-27 22:10:09 +01:00
adding a check for removing broken checklist items
This commit is contained in:
parent
b5f6f421b0
commit
31c74b14c7
app/src/main/kotlin/com/simplemobiletools/notes/pro
@ -94,6 +94,9 @@ class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsServi
|
|||||||
if (note?.type == NoteType.TYPE_CHECKLIST.value) {
|
if (note?.type == NoteType.TYPE_CHECKLIST.value) {
|
||||||
val checklistItemType = object : TypeToken<List<ChecklistItem>>() {}.type
|
val checklistItemType = object : TypeToken<List<ChecklistItem>>() {}.type
|
||||||
checklistItems = Gson().fromJson<ArrayList<ChecklistItem>>(note!!.value, checklistItemType) ?: ArrayList(1)
|
checklistItems = Gson().fromJson<ArrayList<ChecklistItem>>(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<ChecklistItem>
|
||||||
if (context.config.moveDoneChecklistItems) {
|
if (context.config.moveDoneChecklistItems) {
|
||||||
checklistItems.sortBy { it.isDone }
|
checklistItems.sortBy { it.isDone }
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,9 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
|||||||
try {
|
try {
|
||||||
val checklistItemType = object : TypeToken<List<ChecklistItem>>() {}.type
|
val checklistItemType = object : TypeToken<List<ChecklistItem>>() {}.type
|
||||||
items = Gson().fromJson<ArrayList<ChecklistItem>>(storedNote.value, checklistItemType) ?: ArrayList(1)
|
items = Gson().fromJson<ArrayList<ChecklistItem>>(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<ChecklistItem>
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
migrateCheckListOnFailure(storedNote)
|
migrateCheckListOnFailure(storedNote)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user