More fixes and amazing improvements

filterfix
Laurent 5 years ago
parent fb0c5f7933
commit 457ef13c2f
  1. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetEditTextFragment.kt
  2. 73
      app/src/main/java/net/pokeranalytics/android/ui/modules/filter/FilterDetailsFragment.kt
  3. 12
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterElementRow.kt

@ -29,7 +29,7 @@ class BottomSheetEditTextFragment : BottomSheetFragment() {
*/ */
private fun initUI() { private fun initUI() {
val data = getDescriptors() ?: throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor not found") val data = getDescriptors() ?: throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor not found for $this")
if (data.size != 1) { if (data.size != 1) {
throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor inconsistency") throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor inconsistency")
} }

@ -114,43 +114,52 @@ open class FilterDetailsFragment : RealmFragment(), RowRepresentableDelegate {
return return
} }
when (row) { (row as? BaseFilterItemRow)?.let {
is DateFilterItemRow -> { when (val condition = it.rawCondition) {
when (val condition = row.rawCondition) { is QueryCondition.DateQuery -> DateTimePickerManager.create(
is QueryCondition.DateQuery -> DateTimePickerManager.create( requireContext(),
requireContext(), row,
row, this,
this, (row as DateFilterItemRow).value,
row.value, onlyDate = !condition.showTime,
onlyDate = !condition.showTime, onlyTime = condition.showTime
onlyTime = condition.showTime )
) is QueryCondition.Duration -> {
} val hours = (condition.minutes / 60).toString()
} val minutes = (condition.minutes % 60).toString()
is IntFilterItemRow -> { val data = row.editingDescriptors(mapOf("hours" to hours, "minutes" to minutes))
when (val condition = row.rawCondition) { showBottomSheet(row, this, data, true)
is QueryCondition.Duration -> {
val hours = (condition.minutes / 60).toString()
val minutes = (condition.minutes % 60).toString()
val data = row.editingDescriptors(mapOf("hours" to hours, "minutes" to minutes))
showBottomSheet(row, this, data, true)
}
} }
} is QueryCondition.ListOfValues<*> -> {
is ValueListFilterItemRow<*> -> { val valueAsString: String? = (row as FilterValueHolder).singleValue?.toString()
when (row.rawCondition) { // row.list.firstOrNull()?.let {
is QueryCondition.ListOfValues<*> -> { // valueAsString = row.list.firstOrNull()?.toString()
var valueAsString: String? = null // }
row.list.firstOrNull()?.let { val data = row.editingDescriptors(mapOf("valueAsString" to valueAsString))
valueAsString = row.list.firstOrNull()?.toString() showBottomSheet(row, this, data, true)
}
val data = row.editingDescriptors(mapOf("valueAsString" to valueAsString))
showBottomSheet(row, this, data, true)
}
} }
else -> { }
} }
} }
// when (row) {
// is DateFilterItemRow -> {
// when (val condition = row.rawCondition) {
//
// }
// }
// is IntFilterItemRow -> {
// when (val condition = row.rawCondition) {
//
// }
// }
// is ValueListFilterItemRow<*> -> {
// when (row.rawCondition) {
//
// }
// }
// }
// (row as? BaseFilterItemRow)?.let { filterItemRow -> // (row as? BaseFilterItemRow)?.let { filterItemRow ->
// val rawCondition = filterItemRow.rawCondition // val rawCondition = filterItemRow.rawCondition

@ -68,6 +68,7 @@ interface FilterItemRow : RowRepresentable {
interface FilterValueHolder { interface FilterValueHolder {
fun valueFormatted(context: Context): CharSequence? fun valueFormatted(context: Context): CharSequence?
val singleValue: Any?
} }
open class BaseFilterItemRow(queryCondition: QueryCondition, override var filterSectionRow: FilterSectionRow) : FilterItemRow { open class BaseFilterItemRow(queryCondition: QueryCondition, override var filterSectionRow: FilterSectionRow) : FilterItemRow {
@ -93,6 +94,8 @@ open class BaseFilterItemRow(queryCondition: QueryCondition, override var filter
override val bottomSheetType: BottomSheetType override val bottomSheetType: BottomSheetType
get() { return this.rawCondition.bottomSheetType } get() { return this.rawCondition.bottomSheetType }
} }
@ -118,6 +121,11 @@ abstract class ValueFilterItemRow<T: Comparable<T>>(queryCondition: QueryConditi
return NULL_TEXT return NULL_TEXT
} }
override val singleValue: Any?
get() {
return this.value
}
override fun updateValue(fc: FilterCondition) { override fun updateValue(fc: FilterCondition) {
// TODO // TODO
@ -157,6 +165,10 @@ abstract class ValueListFilterItemRow<T: Comparable<T>>(queryCondition: QueryCon
return NULL_TEXT return NULL_TEXT
} }
override val singleValue: Any?
get() {
return this.list.firstOrNull()
}
// override fun getDisplayName(context: Context): String { // override fun getDisplayName(context: Context): String {
// return this.listCondition.getDisplayName(context, this.list) // return this.listCondition.getDisplayName(context, this.list)

Loading…
Cancel
Save