|
|
|
@ -31,7 +31,6 @@ import kotlin.reflect.KClass |
|
|
|
* Enum describing the way a query should be handled |
|
|
|
* Enum describing the way a query should be handled |
|
|
|
* Some queries requires a value to be checked upon through equals, in, more, less, between |
|
|
|
* Some queries requires a value to be checked upon through equals, in, more, less, between |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
sealed class QueryCondition : RowRepresentable { |
|
|
|
sealed class QueryCondition : RowRepresentable { |
|
|
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
companion object { |
|
|
|
@ -177,9 +176,23 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
abstract class SingleValue<T>(value: T) : ListOfValues<T>() where T : Comparable<T> { |
|
|
|
abstract class SingleValue<T>(value: T) : QueryCondition() where T : Comparable<T> { |
|
|
|
override var listOfValues = mutableListOf<T>() |
|
|
|
// override var listOfValues = mutableListOf<T>() |
|
|
|
var singleValue: T = value |
|
|
|
var singleValue: T = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract fun labelForValue(value: T, context: Context): String |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun getDisplayName(context: Context): String { |
|
|
|
|
|
|
|
return getDisplayName(context, singleValue) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun getDisplayName(context: Context, value: T): String { |
|
|
|
|
|
|
|
val prefix = this.resId?.let { |
|
|
|
|
|
|
|
context.getString(it) + " " |
|
|
|
|
|
|
|
} ?: "" |
|
|
|
|
|
|
|
return prefix + labelForValue(value, context) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
abstract class ListOfDouble : ListOfValues<Double>() { |
|
|
|
abstract class ListOfDouble : ListOfValues<Double>() { |
|
|
|
@ -194,10 +207,6 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
override fun labelForValue(value: Double, context: Context): String { |
|
|
|
override fun labelForValue(value: Double, context: Context): String { |
|
|
|
return value.toCurrency(UserDefaults.currency) |
|
|
|
return value.toCurrency(UserDefaults.currency) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun toRowWrapper(filterSectionRow: FilterSectionRow): FilterItemRow { |
|
|
|
|
|
|
|
return DoubleValueListFilterItemRow(this, filterSectionRow) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
abstract class ListOfInt : ListOfValues<Int>() { |
|
|
|
abstract class ListOfInt : ListOfValues<Int>() { |
|
|
|
@ -211,7 +220,9 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
return value.toString() |
|
|
|
return value.toString() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract class UserInputListOfInt : ListOfInt() { |
|
|
|
override fun toRowWrapper(filterSectionRow: FilterSectionRow): FilterItemRow { |
|
|
|
override fun toRowWrapper(filterSectionRow: FilterSectionRow): FilterItemRow { |
|
|
|
return IntValueListFilterItemRow(this, filterSectionRow) |
|
|
|
return IntValueListFilterItemRow(this, filterSectionRow) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -228,10 +239,6 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
super.updateValueBy(filterCondition) |
|
|
|
super.updateValueBy(filterCondition) |
|
|
|
listOfValues = filterCondition.getValues() |
|
|
|
listOfValues = filterCondition.getValues() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun toRowWrapper(filterSectionRow: FilterSectionRow): FilterItemRow { |
|
|
|
|
|
|
|
return StringValueListFilterItemRow(this, filterSectionRow) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
abstract class SingleDate(date: Date) : SingleValue<Date>(date) { |
|
|
|
abstract class SingleDate(date: Date) : SingleValue<Date>(date) { |
|
|
|
@ -239,7 +246,7 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
return value.shortDate() |
|
|
|
return value.shortDate() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override var listOfValues = mutableListOf<Date>() |
|
|
|
// override var listOfValues = mutableListOf<Date>() |
|
|
|
|
|
|
|
|
|
|
|
override fun updateValueBy(filterCondition: FilterCondition) { |
|
|
|
override fun updateValueBy(filterCondition: FilterCondition) { |
|
|
|
super.updateValueBy(filterCondition) |
|
|
|
super.updateValueBy(filterCondition) |
|
|
|
@ -261,6 +268,9 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
singleValue = filterCondition.getValue() |
|
|
|
singleValue = filterCondition.getValue() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract class UserInputSingleInt(value: Int) : SingleInt(value) { |
|
|
|
override fun toRowWrapper(filterSectionRow: FilterSectionRow): FilterItemRow { |
|
|
|
override fun toRowWrapper(filterSectionRow: FilterSectionRow): FilterItemRow { |
|
|
|
return IntFilterItemRow(this, filterSectionRow) |
|
|
|
return IntFilterItemRow(this, filterSectionRow) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -307,12 +317,11 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface DateTime { |
|
|
|
interface DateTime { |
|
|
|
val showTime: Boolean |
|
|
|
val showTime: Boolean |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
abstract class DateQuery(date: Date) : SingleDate(date), DateTime { |
|
|
|
abstract class DateQuery(date: Date) : UserInputSingleDate(date), DateTime { |
|
|
|
override val showTime: Boolean = false |
|
|
|
override val showTime: Boolean = false |
|
|
|
|
|
|
|
|
|
|
|
override fun labelForValue(value: Date, context: Context): String { |
|
|
|
override fun labelForValue(value: Date, context: Context): String { |
|
|
|
@ -324,6 +333,12 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract class UserInputSingleDate(date: Date) : SingleDate(date) { |
|
|
|
|
|
|
|
override fun toRowWrapper(filterSectionRow: FilterSectionRow): FilterItemRow { |
|
|
|
|
|
|
|
return DateFilterItemRow(this, filterSectionRow) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
abstract class TimeQuery(date: Date) : DateQuery(date) { |
|
|
|
abstract class TimeQuery(date: Date) : DateQuery(date) { |
|
|
|
override val showTime: Boolean = true |
|
|
|
override val showTime: Boolean = true |
|
|
|
} |
|
|
|
} |
|
|
|
@ -446,15 +461,12 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
override fun entityName(context: Context): String { |
|
|
|
override fun entityName(context: Context): String { |
|
|
|
return context.getString(R.string.blinds) |
|
|
|
return context.getString(R.string.blinds) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun toRowWrapper(filterSectionRow: FilterSectionRow): FilterItemRow { |
|
|
|
|
|
|
|
return FixedValueFilterItemRow(this, filterSectionRow) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// object Last : SingleInt() { |
|
|
|
} |
|
|
|
// override var operator = Operator.EQUALS |
|
|
|
|
|
|
|
// override fun getDisplayName(context: Context): String { |
|
|
|
|
|
|
|
// //TODO update string "last %i" |
|
|
|
|
|
|
|
// return "${context.getString(R.string.last_i_records)} $singleValue" |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NumberOfTable : ListOfInt() { |
|
|
|
class NumberOfTable : ListOfInt() { |
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
@ -466,7 +478,13 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class NumberOfRebuy() : ListOfDouble() { |
|
|
|
open class UserInputListOfDouble : ListOfDouble() { |
|
|
|
|
|
|
|
override fun toRowWrapper(filterSectionRow: FilterSectionRow): FilterItemRow { |
|
|
|
|
|
|
|
return DoubleValueListFilterItemRow(this, filterSectionRow) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NumberOfRebuy() : UserInputListOfDouble() { |
|
|
|
constructor(operator: Operator, numberOfRebuy: Double) : this() { |
|
|
|
constructor(operator: Operator, numberOfRebuy: Double) : this() { |
|
|
|
this.operator = operator |
|
|
|
this.operator = operator |
|
|
|
this.listOfValues = arrayListOf(numberOfRebuy) |
|
|
|
this.listOfValues = arrayListOf(numberOfRebuy) |
|
|
|
@ -477,20 +495,20 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class TournamentFinalPosition() : ListOfInt() { |
|
|
|
class TournamentFinalPosition() : UserInputListOfInt() { |
|
|
|
constructor(operator: Operator, finalPosition: Int) : this() { |
|
|
|
constructor(operator: Operator, finalPosition: Int) : this() { |
|
|
|
this.operator = operator |
|
|
|
this.operator = operator |
|
|
|
this.listOfValues = arrayListOf(finalPosition) |
|
|
|
this.listOfValues = arrayListOf(finalPosition) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
val suffix = when (value%10) { |
|
|
|
val suffix = when (value % 10) { |
|
|
|
1 -> context.getString(R.string.ordinal_suffix_first) |
|
|
|
1 -> context.getString(R.string.ordinal_suffix_first) |
|
|
|
2 -> context.getString(R.string.ordinal_suffix_second) |
|
|
|
2 -> context.getString(R.string.ordinal_suffix_second) |
|
|
|
3 -> context.getString(R.string.ordinal_suffix_third) |
|
|
|
3 -> context.getString(R.string.ordinal_suffix_third) |
|
|
|
else -> context.getString(R.string.ordinal_suffix_default) |
|
|
|
else -> context.getString(R.string.ordinal_suffix_default) |
|
|
|
} |
|
|
|
} |
|
|
|
return "$value$suffix "+context.getString(R.string.position) |
|
|
|
return "$value$suffix " + context.getString(R.string.position) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun entityName(context: Context): String { |
|
|
|
override fun entityName(context: Context): String { |
|
|
|
@ -498,14 +516,18 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
open class NetAmount : ListOfDouble() |
|
|
|
open class NetAmount : ListOfDouble() { |
|
|
|
|
|
|
|
override fun toRowWrapper(filterSectionRow: FilterSectionRow): FilterItemRow { |
|
|
|
|
|
|
|
return DoubleValueListFilterItemRow(this, filterSectionRow) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class NetAmountWon : NetAmount() |
|
|
|
class NetAmountWon : NetAmount() |
|
|
|
class NetAmountLost : NetAmount() { |
|
|
|
class NetAmountLost : NetAmount() { |
|
|
|
override var sign: Int = -1 |
|
|
|
override var sign: Int = -1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class TournamentNumberOfPlayer : ListOfInt() { |
|
|
|
class TournamentNumberOfPlayer : UserInputListOfInt() { |
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
return value.toString() + " " + context.getString(R.string.number_of_players) |
|
|
|
return value.toString() + " " + context.getString(R.string.number_of_players) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -547,7 +569,7 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class AnyYear() : ListOfInt() { |
|
|
|
class AnyYear() : UserInputListOfInt() { |
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
return "$value" |
|
|
|
return "$value" |
|
|
|
} |
|
|
|
} |
|
|
|
@ -580,14 +602,14 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
return value.toString() |
|
|
|
return value.toString() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun entityName(context: Context): String { |
|
|
|
// override fun entityName(context: Context): String { |
|
|
|
return this.resId?.let { |
|
|
|
// return this.resId?.let { |
|
|
|
" " + context.getString(it) |
|
|
|
// " " + context.getString(it) |
|
|
|
} ?: "" |
|
|
|
// } ?: "" |
|
|
|
} |
|
|
|
// } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class Duration(value: Int) : SingleInt(value) { |
|
|
|
class Duration(value: Int) : UserInputSingleInt(value) { |
|
|
|
override var operator = Operator.EQUALS |
|
|
|
override var operator = Operator.EQUALS |
|
|
|
|
|
|
|
|
|
|
|
var minutes: Int |
|
|
|
var minutes: Int |
|
|
|
@ -617,20 +639,10 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
|
|
|
|
|
|
|
|
class StartedFromTime(date: Date) : TimeQuery(date) { |
|
|
|
class StartedFromTime(date: Date) : TimeQuery(date) { |
|
|
|
override var operator = Operator.MORE |
|
|
|
override var operator = Operator.MORE |
|
|
|
|
|
|
|
|
|
|
|
// constructor(date: Date) : this() { |
|
|
|
|
|
|
|
// singleValue = date |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class EndedToTime(date: Date) : TimeQuery(date) { |
|
|
|
class EndedToTime(date: Date) : TimeQuery(date) { |
|
|
|
override var operator = Operator.LESS |
|
|
|
override var operator = Operator.LESS |
|
|
|
|
|
|
|
|
|
|
|
// constructor(date: Date) : this() { |
|
|
|
|
|
|
|
// singleValue = date |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface CustomFieldRelated { |
|
|
|
interface CustomFieldRelated { |
|
|
|
@ -717,7 +729,7 @@ sealed class QueryCondition : RowRepresentable { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
open fun toRowWrapper(filterSectionRow: FilterSectionRow): FilterItemRow { |
|
|
|
open fun toRowWrapper(filterSectionRow: FilterSectionRow): FilterItemRow { |
|
|
|
return BaseFilterItemRow(this, filterSectionRow) |
|
|
|
return FixedValueFilterItemRow(this, filterSectionRow) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|