mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
HabitCardListAdapter: Return copy of list of selected items
Previously, HabitCardListAdapter returned a pointer to the list, instead of a copy. By the time other parts of the application were reading the list, its contents had already changed. This prevented the user from deleting or archiving habits.
This commit is contained in:
@@ -53,7 +53,7 @@ class HabitCardListAdapter @Inject constructor(
|
||||
ListHabitsSelectionMenuBehavior.Adapter {
|
||||
val observable: ModelObservable = ModelObservable()
|
||||
private var listView: HabitCardListView? = null
|
||||
override val selected: LinkedList<Habit> = LinkedList()
|
||||
val selected: LinkedList<Habit> = LinkedList()
|
||||
override fun atMidnight() {
|
||||
cache.refreshAllHabits()
|
||||
}
|
||||
@@ -71,6 +71,10 @@ class HabitCardListAdapter @Inject constructor(
|
||||
observable.notifyListeners()
|
||||
}
|
||||
|
||||
override fun getSelected(): List<Habit> {
|
||||
return ArrayList(selected)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the item that occupies a certain position on the list
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user