improve background filtering

This commit is contained in:
Phillip Thelen 2023-01-10 17:49:37 +01:00
parent 17164d3fef
commit 50619b7312
2 changed files with 16 additions and 0 deletions

View file

@ -9,4 +9,18 @@ data class CustomizationFilter(
get() {
return onlyPurchased || months.isNotEmpty()
}
override fun equals(other: Any?): Boolean {
if (other is CustomizationFilter) {
return onlyPurchased == other.onlyPurchased && ascending == other.ascending && months.size == other.months.size && months.containsAll(other.months)
}
return super.equals(other)
}
override fun hashCode(): Int {
var result = onlyPurchased.hashCode()
result = 31 * result + ascending.hashCode()
result = 31 * result + months.hashCode()
return result
}
}

View file

@ -334,6 +334,8 @@ class AvatarCustomizationFragment :
button.text
button.setOnCheckedChangeListener { _, isChecked ->
val newFilter = filter.copy()
newFilter.months = mutableListOf()
newFilter.months.addAll(filter.months)
if (!isChecked && newFilter.months.contains(identifier)) {
button.typeface = Typeface.create("sans-serif", Typeface.NORMAL)
newFilter.months.remove(identifier)