|
|
|
|
@ -1,12 +1,15 @@ |
|
|
|
|
package net.pokeranalytics.android.ui.view.rowrepresentable |
|
|
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
|
import android.text.InputType |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.exceptions.PokerAnalyticsException |
|
|
|
|
import net.pokeranalytics.android.model.filter.QueryCondition |
|
|
|
|
import net.pokeranalytics.android.model.interfaces.Manageable |
|
|
|
|
import net.pokeranalytics.android.model.realm.FilterCondition |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetType |
|
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor |
|
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
@ -40,6 +43,10 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
open class QuantityFilterElementRow : FilterElementRow() |
|
|
|
|
open class MoreFilterElementRow : QuantityFilterElementRow() |
|
|
|
|
open class LessFilterElementRow : QuantityFilterElementRow() |
|
|
|
|
|
|
|
|
|
open class SingleValueFilterElementRow(val value: Int) : FilterElementRow() |
|
|
|
|
|
|
|
|
|
data class Blind(var sb: Double? = null, var bb: Double? = null, var code: String? = null) : FilterElementRow() |
|
|
|
|
@ -57,8 +64,11 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
|
data class TournamentName(val tournamentName: Manageable) : DataFilterElementRow(tournamentName) |
|
|
|
|
data class AllTournamentFeature(val tournamentFeature: Manageable) : DataFilterElementRow(tournamentFeature) |
|
|
|
|
data class AnyTournamentFeature(val tournamentFeature: Manageable) : DataFilterElementRow(tournamentFeature) |
|
|
|
|
data class ResultMoreThan(var value: Double) : FilterElementRow() |
|
|
|
|
data class ResultLessThan(var value: Double) : FilterElementRow() |
|
|
|
|
|
|
|
|
|
data class ResultMoreThan(var value: Double) : MoreFilterElementRow() |
|
|
|
|
data class ResultLessThan(var value: Double) : LessFilterElementRow() |
|
|
|
|
data class DurationMoreThan(var minutes: Int) : MoreFilterElementRow() |
|
|
|
|
data class DurationLessThan(var minutes: Int) : LessFilterElementRow() |
|
|
|
|
|
|
|
|
|
lateinit var filterSectionRow: FilterSectionRow |
|
|
|
|
|
|
|
|
|
@ -99,6 +109,8 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
|
is AllTournamentFeature -> QueryCondition.ALL_TOURNAMENT_FEATURES |
|
|
|
|
is ResultMoreThan -> QueryCondition.MORE_THAN_NET_RESULT |
|
|
|
|
is ResultLessThan -> QueryCondition.LESS_THAN_NET_RESULT |
|
|
|
|
is DurationMoreThan -> QueryCondition.MORE_THAN_DURATION |
|
|
|
|
is DurationLessThan -> QueryCondition.LESS_THAN_DURATION |
|
|
|
|
else -> throw PokerAnalyticsException.UnknownQueryTypeForRow(this) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -138,8 +150,8 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
|
is Day -> R.string.day_of_the_week |
|
|
|
|
is PastDays -> R.string.period_in_days |
|
|
|
|
is Blind -> R.string.blinds |
|
|
|
|
is ResultMoreThan -> R.string.more_than |
|
|
|
|
is ResultLessThan -> R.string.less_than |
|
|
|
|
is ResultMoreThan, is DurationMoreThan -> R.string.more_than |
|
|
|
|
is ResultLessThan, is DurationLessThan -> R.string.less_than |
|
|
|
|
else -> null |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -147,11 +159,33 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
|
override val viewType: Int |
|
|
|
|
get() { |
|
|
|
|
return when (this) { |
|
|
|
|
is ResultMoreThan -> RowViewType.TITLE_VALUE_CHECK.ordinal |
|
|
|
|
is DurationMoreThan, is DurationLessThan -> RowViewType.TITLE_VALUE_CHECK.ordinal |
|
|
|
|
else -> RowViewType.TITLE_CHECK.ordinal |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override val bottomSheetType: BottomSheetType |
|
|
|
|
get() { |
|
|
|
|
return when (this) { |
|
|
|
|
is DurationMoreThan, is DurationLessThan -> BottomSheetType.DOUBLE_EDIT_TEXT |
|
|
|
|
else -> BottomSheetType.NONE |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun editingDescriptors(map: Map<String, Any?>): ArrayList<RowRepresentableEditDescriptor>? { |
|
|
|
|
return when (this) { |
|
|
|
|
is DurationMoreThan, is DurationLessThan -> { |
|
|
|
|
val hours: String? by map |
|
|
|
|
val minutes: String? by map |
|
|
|
|
arrayListOf( |
|
|
|
|
RowRepresentableEditDescriptor(hours, R.string.hour, inputType = InputType.TYPE_CLASS_NUMBER), |
|
|
|
|
RowRepresentableEditDescriptor(minutes, R.string.minute, inputType = InputType.TYPE_CLASS_NUMBER) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
else -> super.editingDescriptors(map) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun getDisplayName(): String { |
|
|
|
|
return when (this) { |
|
|
|
|
is DataFilterElementRow -> this.name |
|
|
|
|
|