mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix stat details persisting filters when cancelled
This commit is contained in:
parent
47e16f8445
commit
c28f2ab405
1 changed files with 9 additions and 1 deletions
|
@ -403,6 +403,7 @@ class StatsDetailsController :
|
||||||
@PluralsRes
|
@PluralsRes
|
||||||
resourceIdPlural: Int,
|
resourceIdPlural: Int,
|
||||||
) {
|
) {
|
||||||
|
val initialStateValues = selectedValues.toSet()
|
||||||
val isCategory = statsList.isArrayOf<Category>()
|
val isCategory = statsList.isArrayOf<Category>()
|
||||||
val items = statsList.map { if (isCategory) (it as Category).name else it.toString() }
|
val items = statsList.map { if (isCategory) (it as Category).name else it.toString() }
|
||||||
.toTypedArray()
|
.toTypedArray()
|
||||||
|
@ -420,13 +421,20 @@ class StatsDetailsController :
|
||||||
selectedValues.remove(newSelection)
|
selectedValues.remove(newSelection)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel) { _, _ ->
|
||||||
|
selectedValues.clear()
|
||||||
|
selectedValues.addAll(initialStateValues)
|
||||||
|
}
|
||||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||||
setState(selectedValues, resourceId, resourceIdPlural, isCategory)
|
setState(selectedValues, resourceId, resourceIdPlural, isCategory)
|
||||||
updateChipsVisibility()
|
updateChipsVisibility()
|
||||||
binding.progress.isVisible = true
|
binding.progress.isVisible = true
|
||||||
resetAndSetup(updateChipsVisibility = false)
|
resetAndSetup(updateChipsVisibility = false)
|
||||||
}
|
}
|
||||||
|
.setOnCancelListener {
|
||||||
|
selectedValues.clear()
|
||||||
|
selectedValues.addAll(initialStateValues)
|
||||||
|
}
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue