allow adding 3 checklist items at once

This commit is contained in:
tibbi
2018-12-26 23:50:41 +01:00
parent 02c73cdec0
commit 622778e882
4 changed files with 38 additions and 12 deletions

View File

@ -80,12 +80,17 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
private fun showNewItemDialog() {
NewChecklistItemDialog(activity as SimpleActivity) {
val currentMaxId = items.maxBy { it.id }?.id ?: 0
val checklistItem = ChecklistItem(currentMaxId + 1, it, false)
items.add(checklistItem)
var currentMaxId = items.maxBy { it.id }?.id ?: 0
it.forEach {
val checklistItem = ChecklistItem(currentMaxId + 1, it, false)
items.add(checklistItem)
currentMaxId++
}
saveNote()
if (items.size == 1) {
setupAdapter()
} else {
(view.checklist_list.adapter as? ChecklistAdapter)?.notifyDataSetChanged()
}
}
}