Added new checklist items at the top (#439)

This commit is contained in:
Agnieszka C
2021-09-28 20:18:52 +02:00
parent 1ed43e85e5
commit d9a5fce48b
36 changed files with 76 additions and 1 deletions

View File

@ -136,14 +136,21 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
private fun showNewItemDialog() {
NewChecklistItemDialog(activity as SimpleActivity) { titles ->
var currentMaxId = items.maxBy { item -> item.id }?.id ?: 0
val newItems = ArrayList<ChecklistItem>()
titles.forEach { title ->
title.split("\n").map { it.trim() }.filter { it.isNotBlank() }.forEach { row ->
items.add(ChecklistItem(currentMaxId + 1, row, false))
newItems.add(ChecklistItem(currentMaxId + 1, row, false))
currentMaxId++
}
}
if (config?.addNewChecklistItemsTop == true) {
items.addAll(0, newItems)
} else {
items.addAll(newItems)
}
saveNote()
setupAdapter()
}