|
|
|
|
@ -16,71 +16,109 @@ import java.util.* |
|
|
|
|
|
|
|
|
|
sealed class FilterElementRow : RowRepresentable { |
|
|
|
|
|
|
|
|
|
// Objects |
|
|
|
|
|
|
|
|
|
object Cash : FilterElementRow() |
|
|
|
|
object Tournament : FilterElementRow() |
|
|
|
|
object Live : FilterElementRow() |
|
|
|
|
object Online : FilterElementRow() |
|
|
|
|
object Today : FilterElementRow() |
|
|
|
|
object Yesterday : FilterElementRow() |
|
|
|
|
object TodayAndYesterday : FilterElementRow() |
|
|
|
|
object CurrentWeek : FilterElementRow() |
|
|
|
|
object CurrentMonth : FilterElementRow() |
|
|
|
|
object CurrentYear : FilterElementRow() |
|
|
|
|
object Weekday : FilterElementRow() |
|
|
|
|
object Weekend : FilterElementRow() |
|
|
|
|
|
|
|
|
|
object ResultMoreThan : MoreFilterElementRow() |
|
|
|
|
object ResultLessThan : LessFilterElementRow() |
|
|
|
|
object DurationMoreThan : MoreTimeFilterElementRow() |
|
|
|
|
object DurationLessThan : LessTimeFilterElementRow() |
|
|
|
|
|
|
|
|
|
// Subclasses |
|
|
|
|
|
|
|
|
|
open class SingleValueFilterElementRow(val value: Int) : FilterElementRow() |
|
|
|
|
|
|
|
|
|
open class DataFilterElementRow(data: Manageable) : FilterElementRow() { |
|
|
|
|
val id: String = data.id |
|
|
|
|
val name: String = (data as RowRepresentable).getDisplayName() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
open class StaticDataFilterElementRow(var row: RowRepresentable, var id: String) : FilterElementRow() { |
|
|
|
|
|
|
|
|
|
override val resId: Int? = row.resId |
|
|
|
|
val name: String = row.getDisplayName() |
|
|
|
|
|
|
|
|
|
fun getDataLocalizedTitle(context: Context): String { |
|
|
|
|
return row.localizedTitle(context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
open class QuantityFilterElementRow(var value: Double = 0.0) : FilterElementRow() |
|
|
|
|
open class TimeFilterElementRow : QuantityFilterElementRow() { |
|
|
|
|
var minutes = value.toInt() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
open class MoreFilterElementRow : QuantityFilterElementRow() |
|
|
|
|
open class LessFilterElementRow : QuantityFilterElementRow() |
|
|
|
|
open class MoreTimeFilterElementRow : TimeFilterElementRow() |
|
|
|
|
open class LessTimeFilterElementRow : TimeFilterElementRow() |
|
|
|
|
|
|
|
|
|
// Data classes |
|
|
|
|
interface Duration { |
|
|
|
|
var minutes : Int |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
interface Operator |
|
|
|
|
interface MoreOperator : Operator |
|
|
|
|
interface LessOperator : Operator |
|
|
|
|
|
|
|
|
|
open class BoolFilterElementRow : FilterElementRow() |
|
|
|
|
open class DateFilterElementRow(var dateValue: Date = Date()) : FilterElementRow() |
|
|
|
|
open class NumericFilterElementRow(open val doubleValue : Double = 0.0 ) : FilterElementRow() |
|
|
|
|
open class StringFilterElementRow(val stringValue : String = "") : FilterElementRow() |
|
|
|
|
|
|
|
|
|
// Subclasses |
|
|
|
|
open class SingleValueFilterElementRow(open val intValue: Int) : NumericFilterElementRow() { |
|
|
|
|
override val doubleValue : Double |
|
|
|
|
get() { |
|
|
|
|
return intValue.toDouble() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
open class DataFilterElementRow(data: Manageable) : StringFilterElementRow(data.id) { |
|
|
|
|
val id: String = data.id |
|
|
|
|
val name: String = (data as RowRepresentable).getDisplayName() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
open class StaticDataFilterElementRow(var row: RowRepresentable, var id: Int) : NumericFilterElementRow(id.toDouble()) { |
|
|
|
|
|
|
|
|
|
override val resId: Int? = row.resId |
|
|
|
|
val name: String = row.getDisplayName() |
|
|
|
|
|
|
|
|
|
fun getDataLocalizedTitle(context: Context): String { |
|
|
|
|
return row.localizedTitle(context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
open class DurationFilterElement : NumericFilterElementRow(), Duration { |
|
|
|
|
override var minutes: Int = 0 |
|
|
|
|
override val doubleValue : Double |
|
|
|
|
get() { |
|
|
|
|
return minutes.toDouble() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
open class AmountFilterElement : NumericFilterElementRow() { |
|
|
|
|
var amount: Double = 0.0 |
|
|
|
|
override val doubleValue : Double |
|
|
|
|
get() { |
|
|
|
|
return amount |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
object Cash : BoolFilterElementRow() |
|
|
|
|
object Tournament : BoolFilterElementRow() |
|
|
|
|
object Live : BoolFilterElementRow() |
|
|
|
|
object Online : BoolFilterElementRow() |
|
|
|
|
object Today : BoolFilterElementRow() |
|
|
|
|
object Yesterday : BoolFilterElementRow() |
|
|
|
|
object TodayAndYesterday : BoolFilterElementRow() |
|
|
|
|
object CurrentWeek : BoolFilterElementRow() |
|
|
|
|
object CurrentMonth : BoolFilterElementRow() |
|
|
|
|
object CurrentYear : BoolFilterElementRow() |
|
|
|
|
object Weekday : BoolFilterElementRow() |
|
|
|
|
object Weekend : BoolFilterElementRow() |
|
|
|
|
|
|
|
|
|
// Data classes - holding value |
|
|
|
|
object ResultMoreThan : AmountFilterElement(), MoreOperator |
|
|
|
|
object ResultLessThan : AmountFilterElement(), LessOperator |
|
|
|
|
object DurationMoreThan : DurationFilterElement(), MoreOperator |
|
|
|
|
object DurationLessThan : DurationFilterElement(), LessOperator |
|
|
|
|
|
|
|
|
|
data class Blind(var sb: Double? = null, var bb: Double? = null, var code: String? = null) : FilterElementRow() |
|
|
|
|
data class From(var date: Date = Date()) : FilterElementRow() |
|
|
|
|
data class To(var date: Date = Date()) : FilterElementRow() |
|
|
|
|
object From : DateFilterElementRow() |
|
|
|
|
object To : DateFilterElementRow() |
|
|
|
|
|
|
|
|
|
data class Year(val year: Int) : SingleValueFilterElementRow(year) |
|
|
|
|
data class Month(val month: Int) : SingleValueFilterElementRow(month) |
|
|
|
|
data class Day(val day: Int) : SingleValueFilterElementRow(day) |
|
|
|
|
|
|
|
|
|
//TODO: Refactor? |
|
|
|
|
data class PastDays(var lastDays: Int = 0) : FilterElementRow() |
|
|
|
|
data class LastGames(var lastGames: Int) : FilterElementRow() |
|
|
|
|
data class LastSessions(var lastSessions: Int) : FilterElementRow() |
|
|
|
|
data class PastDays(var lastDays: Int = 0) : SingleValueFilterElementRow(lastDays) { |
|
|
|
|
override val intValue: Int |
|
|
|
|
get() { |
|
|
|
|
return lastDays |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
data class LastGames(var lastGames: Int) : SingleValueFilterElementRow(lastGames) { |
|
|
|
|
override val intValue: Int |
|
|
|
|
get() { |
|
|
|
|
return lastGames |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
data class LastSessions(var lastSessions: Int) : SingleValueFilterElementRow(lastSessions) { |
|
|
|
|
override val intValue: Int |
|
|
|
|
get() { |
|
|
|
|
return lastSessions |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 Limit(val limit: net.pokeranalytics.android.model.Limit) : StaticDataFilterElementRow(limit, limit.longName) |
|
|
|
|
data class TableSize(val tableSize: net.pokeranalytics.android.model.TableSize) : StaticDataFilterElementRow(tableSize, tableSize.numberOfPlayer.toString()) |
|
|
|
|
data class Bankroll(val bankroll: Manageable) : DataFilterElementRow(bankroll) |
|
|
|
|
data class Game(val game: Manageable) : DataFilterElementRow(game) |
|
|
|
|
data class Location(val location: Manageable) : DataFilterElementRow(location) |
|
|
|
|
@ -138,14 +176,11 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
|
fun contains(filterConditions: List<FilterCondition>): Boolean { |
|
|
|
|
return when (this) { |
|
|
|
|
is SingleValueFilterElementRow -> filterConditions.any { |
|
|
|
|
it.values.contains(this.value) |
|
|
|
|
it.values.contains(this.intValue) |
|
|
|
|
} |
|
|
|
|
is DataFilterElementRow -> filterConditions.any { |
|
|
|
|
it.ids.contains(this.id) |
|
|
|
|
} |
|
|
|
|
is StaticDataFilterElementRow -> filterConditions.any { |
|
|
|
|
it.ids.contains(this.id) |
|
|
|
|
} |
|
|
|
|
else -> true |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -172,8 +207,8 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
|
is Blind -> R.string.blinds |
|
|
|
|
is LastGames -> R.string.last_records |
|
|
|
|
is LastSessions -> R.string.last_sessions |
|
|
|
|
is MoreFilterElementRow, is MoreTimeFilterElementRow -> R.string.more_than |
|
|
|
|
is LessFilterElementRow, is LessTimeFilterElementRow -> R.string.less_than |
|
|
|
|
is MoreOperator -> R.string.more_than |
|
|
|
|
is LessOperator -> R.string.less_than |
|
|
|
|
else -> null |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -218,7 +253,7 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
|
RowRepresentableEditDescriptor(lastSessions, R.string.last_sessions, inputType = InputType.TYPE_CLASS_NUMBER) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
is DurationMoreThan, is DurationLessThan -> { |
|
|
|
|
is DurationFilterElement -> { |
|
|
|
|
val hours: String? by map |
|
|
|
|
val minutes: String? by map |
|
|
|
|
arrayListOf( |
|
|
|
|
@ -234,9 +269,9 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
|
return when (this) { |
|
|
|
|
is SingleValueFilterElementRow -> { |
|
|
|
|
when (this) { |
|
|
|
|
is Day -> DateFormatSymbols.getInstance(Locale.getDefault()).weekdays[this.value] |
|
|
|
|
is Month -> DateFormatSymbols.getInstance(Locale.getDefault()).months[this.value] |
|
|
|
|
else -> "${this.value}" |
|
|
|
|
is Day -> DateFormatSymbols.getInstance(Locale.getDefault()).weekdays[this.intValue] |
|
|
|
|
is Month -> DateFormatSymbols.getInstance(Locale.getDefault()).months[this.intValue] |
|
|
|
|
else -> "${this.intValue}" |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
is DataFilterElementRow -> this.name |
|
|
|
|
|