Fixes crash when clearing custom field values

kmm
Laurent 5 years ago
parent 50c22ea40e
commit da6a6c53ba
  1. 12
      app/src/main/java/net/pokeranalytics/android/ui/modules/filter/FilterDetailsFragment.kt
  2. 4
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterItemRow.kt

@ -176,17 +176,29 @@ open class FilterDetailsFragment : RealmFragment(), RowRepresentableDelegate {
} }
} }
is DoubleValueListFilterItemRow -> { is DoubleValueListFilterItemRow -> {
if (value == null) {
row.clear()
} else {
val string = value as String val string = value as String
row.add(string.toDouble()) row.add(string.toDouble())
} }
}
is IntValueListFilterItemRow -> { is IntValueListFilterItemRow -> {
if (value == null) {
row.clear()
} else {
val string = value as String val string = value as String
row.add(string.toInt()) row.add(string.toInt())
} }
}
is StringValueListFilterItemRow -> { is StringValueListFilterItemRow -> {
if (value == null) {
row.clear()
} else {
row.add(value as String) row.add(value as String)
} }
} }
}
// Remove the row before updating the selected rows list // Remove the row before updating the selected rows list
this.model.selectedRows.remove(row as FilterItemRow) this.model.selectedRows.remove(row as FilterItemRow)

@ -159,6 +159,10 @@ abstract class ValueListFilterItemRow<T: Comparable<T>>(queryCondition: QueryCon
this.list.add(value) this.list.add(value)
} }
fun clear() {
this.list.clear()
}
override val queryCondition: QueryCondition? override val queryCondition: QueryCondition?
get() { get() {
return if (list.isNotEmpty()) { return if (list.isNotEmpty()) {

Loading…
Cancel
Save