Merge branch 'master' of gitlab.com:stax-river/poker-analytics

csv
Laurent 6 years ago
commit e05a9dc1cf
  1. 74
      app/src/main/java/net/pokeranalytics/android/model/filter/QueryCondition.kt

@ -89,7 +89,7 @@ sealed class QueryCondition : FilterElementRow {
EQUALS,
TRUE,
;
}
}
val baseId = this::class.simpleName ?: throw PokerAnalyticsException.FilterElementUnknownName
@ -257,7 +257,7 @@ sealed class QueryCondition : FilterElementRow {
override fun getDisplayName(context: Context): String {
val realm = Realm.getDefaultInstance()
val entityName = entityName(realm)
val entityName = entityName(realm, context)
val completeLabel = when (listOfValues.size) {
0 -> NULL_TEXT
1, 2 -> {
@ -269,9 +269,9 @@ sealed class QueryCondition : FilterElementRow {
return completeLabel
}
open fun entityName(realm: Realm): String {
return baseId
}
open fun entityName(realm: Realm, context: Context): String {
return entityName(context)
}
private fun labelForValue(realm: Realm, value: String): String {
val query = realm.where(entity)
@ -320,7 +320,11 @@ sealed class QueryCondition : FilterElementRow {
constructor(bankroll: Bankroll) : this() {
this.setObject(bankroll)
}
}
override fun entityName(context: Context): String {
return context.getString(R.string.bankrolls)
}
}
class AnyGame() : QueryDataCondition<Game>() {
override val entity: Class<Game> = Game::class.java
@ -328,7 +332,11 @@ sealed class QueryCondition : FilterElementRow {
constructor(game: Game) : this() {
this.setObject(game)
}
}
override fun entityName(context: Context): String {
return context.getString(R.string.games)
}
}
class AnyTournamentName() : QueryDataCondition<TournamentName>() {
override val entity: Class<TournamentName> = TournamentName::class.java
@ -336,7 +344,11 @@ sealed class QueryCondition : FilterElementRow {
constructor(tournamentName: TournamentName) : this() {
this.setObject(tournamentName)
}
}
override fun entityName(context: Context): String {
return context.getString(R.string.tournament_names)
}
}
class AnyTournamentFeature() : QueryDataCondition<TournamentFeature>() {
override val entity: Class<TournamentFeature> = TournamentFeature::class.java
@ -344,7 +356,11 @@ sealed class QueryCondition : FilterElementRow {
constructor(tournamentFeature: TournamentFeature) : this() {
this.setObject(tournamentFeature)
}
}
override fun entityName(context: Context): String {
return context.getString(R.string.tournament_features)
}
}
class AllTournamentFeature() : QueryDataCondition<TournamentFeature>() {
override var operator = Operator.ALL
@ -353,7 +369,11 @@ sealed class QueryCondition : FilterElementRow {
constructor(tournamentFeature: TournamentFeature) : this() {
this.setObject(tournamentFeature)
}
}
override fun entityName(context: Context): String {
return context.getString(R.string.tournament_features)
}
}
class AnyLocation() : QueryDataCondition<Location>() {
override val entity: Class<Location> = Location::class.java
@ -361,7 +381,11 @@ sealed class QueryCondition : FilterElementRow {
constructor(location: Location) : this() {
this.setObject(location)
}
}
override fun entityName(context: Context): String {
return context.getString(R.string.locations)
}
}
class AnyTransactionType() : QueryDataCondition<TransactionType>() {
override val entity: Class<TransactionType> = TransactionType::class.java
@ -369,27 +393,47 @@ sealed class QueryCondition : FilterElementRow {
constructor(transactionType: TransactionType) : this() {
this.setObject(transactionType)
}
}
override fun entityName(context: Context): String {
return context.getString(R.string.operation_types)
}
}
class AnyLimit : ListOfInt() {
override fun labelForValue(value: Int, context: Context): String {
return Limit.values()[value].getDisplayName(context)
}
override fun entityName(context: Context): String {
return context.getString(R.string.limits)
}
}
class AnyTableSize : ListOfInt() {
override fun labelForValue(value: Int, context: Context): String {
return TableSize(value).getDisplayName(context)
}
override fun entityName(context: Context): String {
return context.getString(R.string.table_sizes)
}
}
class AnyTournamentType : ListOfInt() {
override fun labelForValue(value: Int, context: Context): String {
return TournamentType.values()[value].getDisplayName(context)
}
override fun entityName(context: Context): String {
return context.getString(R.string.tournament_types)
}
}
class AnyBlind : ListOfString()
class AnyBlind : ListOfString() {
override fun entityName(context: Context): String {
return context.getString(R.string.blinds)
}
}
object Last : SingleInt() {
override var operator = Operator.EQUALS
@ -649,7 +693,7 @@ sealed class QueryCondition : FilterElementRow {
?: throw PokerAnalyticsException.QueryValueMapUnexpectedValue
}
override fun entityName(realm: Realm): String {
override fun entityName(realm: Realm, context: Context): String {
return customFieldName(realm)
}
@ -940,7 +984,7 @@ sealed class QueryCondition : FilterElementRow {
is IsWeekDay -> R.string.week_days
is IsWeekEnd -> R.string.weekend
is PastDay -> R.string.period_in_days
is TournamentNumberOfPlayer -> {
is TournamentNumberOfPlayer -> {
when (this.operator) {
Operator.MORE -> R.string.minimum
Operator.LESS -> R.string.maximum

Loading…
Cancel
Save