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. 43
      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() {
val data = getDescriptors() ?: throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor not found")
val data = getDescriptors() ?: throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor not found for $this")
if (data.size != 1) {
throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor inconsistency")
}

@ -114,42 +114,51 @@ open class FilterDetailsFragment : RealmFragment(), RowRepresentableDelegate {
return
}
when (row) {
is DateFilterItemRow -> {
when (val condition = row.rawCondition) {
(row as? BaseFilterItemRow)?.let {
when (val condition = it.rawCondition) {
is QueryCondition.DateQuery -> DateTimePickerManager.create(
requireContext(),
row,
this,
row.value,
(row as DateFilterItemRow).value,
onlyDate = !condition.showTime,
onlyTime = condition.showTime
)
}
}
is IntFilterItemRow -> {
when (val condition = row.rawCondition) {
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 ValueListFilterItemRow<*> -> {
when (row.rawCondition) {
is QueryCondition.ListOfValues<*> -> {
var valueAsString: String? = null
row.list.firstOrNull()?.let {
valueAsString = row.list.firstOrNull()?.toString()
}
val valueAsString: String? = (row as FilterValueHolder).singleValue?.toString()
// row.list.firstOrNull()?.let {
// valueAsString = row.list.firstOrNull()?.toString()
// }
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 ->

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

Loading…
Cancel
Save