Implement partial reordering or habit groups

This commit is contained in:
Dharanish
2024-07-07 10:26:28 +02:00
parent 8df1fb765c
commit 26260fbbc4
2 changed files with 17 additions and 5 deletions

View File

@@ -50,12 +50,20 @@ class HabitCardListController @Inject constructor(
if (from == to) return
cancelSelection()
val habitFrom = adapter.getItem(from)
val habitTo = adapter.getItem(to)
if (habitFrom == null || habitTo == null) return
val habitFrom = adapter.getHabit(from)
val habitTo = adapter.getHabit(to)
if (habitFrom != null && habitTo != null) {
adapter.performReorder(from, to)
behavior.onReorderHabit(habitFrom, habitTo)
return
}
adapter.performReorder(from, to)
behavior.onReorderHabit(habitFrom, habitTo)
val hgrFrom = adapter.getHabitGroup(from)
val hgrTo = adapter.getHabitGroup(to)
if (hgrFrom != null && hgrTo != null) {
adapter.performReorder(from, to)
behavior.onReorderHabitGroup(hgrFrom, hgrTo)
}
}
override fun onItemClick(position: Int) {

View File

@@ -118,6 +118,10 @@ open class ListHabitsBehavior @Inject constructor(
}
}
fun onReorderHabitGroup(from: HabitGroup, to: HabitGroup) {
taskRunner.execute { habitGroupList.reorder(from, to) }
}
fun onRepairDB() {
taskRunner.execute {
habitList.repair()