Select the new items after duplication (#2446)

#1201 Select the new items after duplication
pull/2352/head
vulewuxe86 1 year ago committed by GitHub
parent f7e2c7824a
commit 3d0cf46f8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -776,10 +776,8 @@ class TaskListFragment : Fragment(), OnRefreshListener, Toolbar.OnMenuItemClickL
}
R.id.menu_select_all -> {
lifecycleScope.launch {
taskAdapter.setSelected(taskDao.fetchTasks(preferences, filter)
setSelected(taskDao.fetchTasks(preferences, filter)
.map(TaskContainer::id))
updateModeTitle()
recyclerAdapter?.notifyDataSetChanged()
}
true
}
@ -881,12 +879,19 @@ class TaskListFragment : Fragment(), OnRefreshListener, Toolbar.OnMenuItemClickL
makeSnackbar(R.string.delete_multiple_tasks_confirmation, result.size.toString())?.show()
}
private fun setSelected(tasks: List<Long>) {
taskAdapter.setSelected(tasks)
updateModeTitle()
recyclerAdapter?.notifyDataSetChanged()
}
private fun copySelectedItems(tasks: List<Long>) = lifecycleScope.launch {
finishActionMode()
val duplicates = withContext(NonCancellable) {
taskDuplicator.duplicate(tasks)
}
onTaskCreated(duplicates)
setSelected(duplicates.map(Task::id))
makeSnackbar(R.string.copy_multiple_tasks_confirmation, duplicates.size.toString())?.show()
}

Loading…
Cancel
Save