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

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

Loading…
Cancel
Save