|
|
|
@ -11,62 +11,65 @@ import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheet |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor |
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
|
|
|
|
import net.pokeranalytics.android.util.NULL_TEXT |
|
|
|
|
|
|
|
import net.pokeranalytics.android.util.extensions.formatted |
|
|
|
|
|
|
|
import net.pokeranalytics.android.util.extensions.round |
|
|
|
import java.text.DateFormatSymbols |
|
|
|
import java.text.DateFormatSymbols |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
sealed class FilterElementRow : RowRepresentable { |
|
|
|
sealed class FilterElementRow : RowRepresentable { |
|
|
|
|
|
|
|
|
|
|
|
interface Duration { |
|
|
|
interface Duration { |
|
|
|
var minutes : Int |
|
|
|
var minutes: Int |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface Operator |
|
|
|
interface Operator |
|
|
|
interface MoreOperator : Operator |
|
|
|
interface MoreOperator : Operator |
|
|
|
interface LessOperator : Operator |
|
|
|
interface LessOperator : Operator |
|
|
|
|
|
|
|
|
|
|
|
open class BoolFilterElementRow : FilterElementRow() |
|
|
|
open class BoolFilterElementRow : FilterElementRow() |
|
|
|
open class DateFilterElementRow(var dateValue: Date = Date()) : FilterElementRow() |
|
|
|
open class DateFilterElementRow(var dateValue: Date = Date()) : FilterElementRow() |
|
|
|
open class NumericFilterElementRow(open val doubleValue : Double = 0.0 ) : FilterElementRow() |
|
|
|
open class NumericFilterElementRow(open val doubleValue: Double = 0.0) : FilterElementRow() |
|
|
|
open class StringFilterElementRow(val stringValue : String = "") : FilterElementRow() |
|
|
|
open class StringFilterElementRow(val stringValue: String = "") : FilterElementRow() |
|
|
|
|
|
|
|
|
|
|
|
// Subclasses |
|
|
|
// Subclasses |
|
|
|
open class SingleValueFilterElementRow(open val intValue: Int) : NumericFilterElementRow() { |
|
|
|
open class SingleValueFilterElementRow(open val intValue: Int) : NumericFilterElementRow() { |
|
|
|
override val doubleValue : Double |
|
|
|
override val doubleValue: Double |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
return intValue.toDouble() |
|
|
|
return intValue.toDouble() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
open class DataFilterElementRow(data: Manageable) : StringFilterElementRow(data.id) { |
|
|
|
open class DataFilterElementRow(data: Manageable) : StringFilterElementRow(data.id) { |
|
|
|
val id: String = data.id |
|
|
|
val id: String = data.id |
|
|
|
val name: String = (data as RowRepresentable).getDisplayName() |
|
|
|
val name: String = (data as RowRepresentable).getDisplayName() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
open class StaticDataFilterElementRow(var row: RowRepresentable, var id: Int) : NumericFilterElementRow(id.toDouble()) { |
|
|
|
open class StaticDataFilterElementRow(val row: RowRepresentable, val id: Int) : NumericFilterElementRow(id.toDouble()) { |
|
|
|
|
|
|
|
|
|
|
|
override val resId: Int? = row.resId |
|
|
|
override val resId: Int? = row.resId |
|
|
|
val name: String = row.getDisplayName() |
|
|
|
val name: String = row.getDisplayName() |
|
|
|
|
|
|
|
|
|
|
|
fun getDataLocalizedTitle(context: Context): String { |
|
|
|
fun getDataLocalizedTitle(context: Context): String { |
|
|
|
return row.localizedTitle(context) |
|
|
|
return row.localizedTitle(context) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
open class DurationFilterElement : NumericFilterElementRow(), Duration { |
|
|
|
open class DurationFilterElement : NumericFilterElementRow(), Duration { |
|
|
|
override var minutes: Int = 0 |
|
|
|
override var minutes: Int = 0 |
|
|
|
override val doubleValue : Double |
|
|
|
override val doubleValue: Double |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
return minutes.toDouble() |
|
|
|
return minutes.toDouble() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
open class AmountFilterElement : NumericFilterElementRow() { |
|
|
|
open class AmountFilterElement : NumericFilterElementRow() { |
|
|
|
var amount: Double = 0.0 |
|
|
|
var amount: Double = 0.0 |
|
|
|
override val doubleValue : Double |
|
|
|
override val doubleValue: Double |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
return amount |
|
|
|
return amount |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
object Cash : BoolFilterElementRow() |
|
|
|
object Cash : BoolFilterElementRow() |
|
|
|
object Tournament : BoolFilterElementRow() |
|
|
|
object Tournament : BoolFilterElementRow() |
|
|
|
@ -80,43 +83,53 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
object CurrentYear : BoolFilterElementRow() |
|
|
|
object CurrentYear : BoolFilterElementRow() |
|
|
|
object Weekday : BoolFilterElementRow() |
|
|
|
object Weekday : BoolFilterElementRow() |
|
|
|
object Weekend : BoolFilterElementRow() |
|
|
|
object Weekend : BoolFilterElementRow() |
|
|
|
|
|
|
|
object From : DateFilterElementRow() |
|
|
|
|
|
|
|
object To : DateFilterElementRow() |
|
|
|
|
|
|
|
|
|
|
|
// Data classes - holding value |
|
|
|
// Data classes - holding value |
|
|
|
object ResultMoreThan : AmountFilterElement(), MoreOperator |
|
|
|
object ResultMoreThan : AmountFilterElement(), MoreOperator |
|
|
|
object ResultLessThan : AmountFilterElement(), LessOperator |
|
|
|
|
|
|
|
object DurationMoreThan : DurationFilterElement(), MoreOperator |
|
|
|
object ResultLessThan : AmountFilterElement(), LessOperator |
|
|
|
object DurationLessThan : DurationFilterElement(), LessOperator |
|
|
|
object DurationMoreThan : DurationFilterElement(), MoreOperator |
|
|
|
object ReBuyMoreThan: AmountFilterElement(), MoreOperator |
|
|
|
object DurationLessThan : DurationFilterElement(), LessOperator |
|
|
|
object ReBuyLessThan: AmountFilterElement(), LessOperator |
|
|
|
object ReBuyMoreThan : AmountFilterElement(), MoreOperator |
|
|
|
|
|
|
|
object ReBuyLessThan : AmountFilterElement(), LessOperator |
|
|
|
|
|
|
|
|
|
|
|
data class Blind(var sb: Double? = null, var bb: Double? = null, var code: String? = null) : FilterElementRow() |
|
|
|
|
|
|
|
object From : DateFilterElementRow() |
|
|
|
|
|
|
|
object To : DateFilterElementRow() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data class Year(val year: Int) : SingleValueFilterElementRow(year) |
|
|
|
data class Year(val year: Int) : SingleValueFilterElementRow(year) |
|
|
|
data class Month(val month: Int) : SingleValueFilterElementRow(month) |
|
|
|
data class Month(val month: Int) : SingleValueFilterElementRow(month) |
|
|
|
data class Day(val day: Int) : SingleValueFilterElementRow(day) |
|
|
|
data class Day(val day: Int) : SingleValueFilterElementRow(day) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data class Blind(var sb: Double? = null, var bb: Double? = null, var code: String? = null) : FilterElementRow() { |
|
|
|
|
|
|
|
val name: String |
|
|
|
|
|
|
|
get() { |
|
|
|
|
|
|
|
val currencyCode = code ?: Currency.getInstance(Locale.getDefault()).currencyCode |
|
|
|
|
|
|
|
val currencySymbol = Currency.getInstance(currencyCode).symbol |
|
|
|
|
|
|
|
return if (sb == null) NULL_TEXT else "$currencySymbol ${sb?.formatted()}/${bb?.round()}" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//TODO: Refactor? |
|
|
|
//TODO: Refactor? |
|
|
|
data class PastDays(var lastDays: Int = 0) : SingleValueFilterElementRow(lastDays) { |
|
|
|
data class PastDays(var lastDays: Int = 0) : SingleValueFilterElementRow(lastDays) { |
|
|
|
override val intValue: Int |
|
|
|
override val intValue: Int |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
return lastDays |
|
|
|
return lastDays |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
data class LastGames(var lastGames: Int) : SingleValueFilterElementRow(lastGames) { |
|
|
|
data class LastGames(var lastGames: Int) : SingleValueFilterElementRow(lastGames) { |
|
|
|
override val intValue: Int |
|
|
|
override val intValue: Int |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
return lastGames |
|
|
|
return lastGames |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
data class LastSessions(var lastSessions: Int) : SingleValueFilterElementRow(lastSessions) { |
|
|
|
data class LastSessions(var lastSessions: Int) : SingleValueFilterElementRow(lastSessions) { |
|
|
|
override val intValue: Int |
|
|
|
override val intValue: Int |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
return lastSessions |
|
|
|
return lastSessions |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
data class Limit(val limit: net.pokeranalytics.android.model.Limit) : StaticDataFilterElementRow(limit, limit.ordinal) |
|
|
|
data class Limit(val limit: net.pokeranalytics.android.model.Limit) : StaticDataFilterElementRow(limit, limit.ordinal) |
|
|
|
data class TableSize(val tableSize: net.pokeranalytics.android.model.TableSize) : StaticDataFilterElementRow(tableSize, tableSize.numberOfPlayer) |
|
|
|
data class TableSize(val tableSize: net.pokeranalytics.android.model.TableSize) : StaticDataFilterElementRow(tableSize, tableSize.numberOfPlayer) |
|
|
|
@ -167,9 +180,12 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
is DurationMoreThan -> QueryCondition.MORE_THAN_DURATION |
|
|
|
is DurationMoreThan -> QueryCondition.MORE_THAN_DURATION |
|
|
|
is DurationLessThan -> QueryCondition.LESS_THAN_DURATION |
|
|
|
is DurationLessThan -> QueryCondition.LESS_THAN_DURATION |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: Check the conditions |
|
|
|
//TODO: Check the conditions |
|
|
|
is LastGames -> QueryCondition.LAST_GAMES |
|
|
|
is LastGames -> QueryCondition.LAST_GAMES |
|
|
|
is LastSessions -> QueryCondition.LAST_SESSIONS |
|
|
|
is LastSessions -> QueryCondition.LAST_SESSIONS |
|
|
|
|
|
|
|
is ReBuyMoreThan -> QueryCondition.MIN_RE_BUY |
|
|
|
|
|
|
|
is ReBuyLessThan -> QueryCondition.MAX_RE_BUY |
|
|
|
|
|
|
|
|
|
|
|
else -> throw PokerAnalyticsException.UnknownQueryTypeForRow(this) |
|
|
|
else -> throw PokerAnalyticsException.UnknownQueryTypeForRow(this) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -206,9 +222,10 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
is Weekday -> R.string.week_days |
|
|
|
is Weekday -> R.string.week_days |
|
|
|
is Weekend -> R.string.weekend |
|
|
|
is Weekend -> R.string.weekend |
|
|
|
is PastDays -> R.string.period_in_days |
|
|
|
is PastDays -> R.string.period_in_days |
|
|
|
is Blind -> R.string.blinds |
|
|
|
|
|
|
|
is LastGames -> R.string.last_records |
|
|
|
is LastGames -> R.string.last_records |
|
|
|
is LastSessions -> R.string.last_sessions |
|
|
|
is LastSessions -> R.string.last_sessions |
|
|
|
|
|
|
|
is ReBuyMoreThan -> R.string.minimum |
|
|
|
|
|
|
|
is ReBuyLessThan -> R.string.maximum |
|
|
|
is MoreOperator -> R.string.more_than |
|
|
|
is MoreOperator -> R.string.more_than |
|
|
|
is LessOperator -> R.string.less_than |
|
|
|
is LessOperator -> R.string.less_than |
|
|
|
else -> null |
|
|
|
else -> null |
|
|
|
@ -254,20 +271,16 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
is ReBuyMoreThan -> { |
|
|
|
//TODO: Refactor that |
|
|
|
val reBuyMore: String? by map |
|
|
|
is AmountFilterElement -> { |
|
|
|
arrayListOf( |
|
|
|
val amount: String? by map |
|
|
|
RowRepresentableEditDescriptor(reBuyMore, R.string.maximum, inputType = InputType.TYPE_CLASS_NUMBER) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
is ReBuyLessThan -> { |
|
|
|
|
|
|
|
val reBuyLess: String? by map |
|
|
|
|
|
|
|
arrayListOf( |
|
|
|
arrayListOf( |
|
|
|
RowRepresentableEditDescriptor(reBuyLess, R.string.minimum, inputType = InputType.TYPE_CLASS_NUMBER) |
|
|
|
RowRepresentableEditDescriptor(amount, R.string.amount, inputType = InputType.TYPE_CLASS_NUMBER) |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
is DurationFilterElement -> { val hours: String? by map |
|
|
|
is DurationFilterElement -> { |
|
|
|
|
|
|
|
val hours: String? by map |
|
|
|
val minutes: String? by map |
|
|
|
val minutes: String? by map |
|
|
|
arrayListOf( |
|
|
|
arrayListOf( |
|
|
|
RowRepresentableEditDescriptor(hours, R.string.hour, inputType = InputType.TYPE_CLASS_NUMBER), |
|
|
|
RowRepresentableEditDescriptor(hours, R.string.hour, inputType = InputType.TYPE_CLASS_NUMBER), |
|
|
|
@ -289,6 +302,7 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
} |
|
|
|
} |
|
|
|
is DataFilterElementRow -> this.name |
|
|
|
is DataFilterElementRow -> this.name |
|
|
|
is StaticDataFilterElementRow -> this.name |
|
|
|
is StaticDataFilterElementRow -> this.name |
|
|
|
|
|
|
|
is Blind -> this.name |
|
|
|
else -> super.getDisplayName() |
|
|
|
else -> super.getDisplayName() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|