mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-14 21:18:51 -06:00
Implement partial reordering or habit groups
This commit is contained in:
@@ -50,12 +50,20 @@ class HabitCardListController @Inject constructor(
|
|||||||
if (from == to) return
|
if (from == to) return
|
||||||
cancelSelection()
|
cancelSelection()
|
||||||
|
|
||||||
val habitFrom = adapter.getItem(from)
|
val habitFrom = adapter.getHabit(from)
|
||||||
val habitTo = adapter.getItem(to)
|
val habitTo = adapter.getHabit(to)
|
||||||
if (habitFrom == null || habitTo == null) return
|
if (habitFrom != null && habitTo != null) {
|
||||||
|
adapter.performReorder(from, to)
|
||||||
|
behavior.onReorderHabit(habitFrom, habitTo)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
adapter.performReorder(from, to)
|
val hgrFrom = adapter.getHabitGroup(from)
|
||||||
behavior.onReorderHabit(habitFrom, habitTo)
|
val hgrTo = adapter.getHabitGroup(to)
|
||||||
|
if (hgrFrom != null && hgrTo != null) {
|
||||||
|
adapter.performReorder(from, to)
|
||||||
|
behavior.onReorderHabitGroup(hgrFrom, hgrTo)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemClick(position: Int) {
|
override fun onItemClick(position: Int) {
|
||||||
|
|||||||
@@ -118,6 +118,10 @@ open class ListHabitsBehavior @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun onReorderHabitGroup(from: HabitGroup, to: HabitGroup) {
|
||||||
|
taskRunner.execute { habitGroupList.reorder(from, to) }
|
||||||
|
}
|
||||||
|
|
||||||
fun onRepairDB() {
|
fun onRepairDB() {
|
||||||
taskRunner.execute {
|
taskRunner.execute {
|
||||||
habitList.repair()
|
habitList.repair()
|
||||||
|
|||||||
Reference in New Issue
Block a user