|
|
|
@ -1,5 +1,6 @@ |
|
|
|
package net.pokeranalytics.android.ui.view.rowrepresentable |
|
|
|
package net.pokeranalytics.android.ui.view.rowrepresentable |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.exceptions.PokerAnalyticsException |
|
|
|
import net.pokeranalytics.android.exceptions.PokerAnalyticsException |
|
|
|
import net.pokeranalytics.android.model.filter.QueryType |
|
|
|
import net.pokeranalytics.android.model.filter.QueryType |
|
|
|
@ -7,7 +8,6 @@ import net.pokeranalytics.android.model.interfaces.Manageable |
|
|
|
import net.pokeranalytics.android.model.realm.FilterElement |
|
|
|
import net.pokeranalytics.android.model.realm.FilterElement |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
|
|
|
|
|
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
sealed class FilterElementRow : RowRepresentable { |
|
|
|
sealed class FilterElementRow : RowRepresentable { |
|
|
|
@ -21,16 +21,29 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
object TodayAndYesterday : FilterElementRow() |
|
|
|
object TodayAndYesterday : FilterElementRow() |
|
|
|
object CurrentWeek : FilterElementRow() |
|
|
|
object CurrentWeek : FilterElementRow() |
|
|
|
object CurrentMonth : FilterElementRow() |
|
|
|
object CurrentMonth : FilterElementRow() |
|
|
|
object CurrentYear: FilterElementRow() |
|
|
|
object CurrentYear : FilterElementRow() |
|
|
|
object Weekday: FilterElementRow() |
|
|
|
object Weekday : FilterElementRow() |
|
|
|
object Weekend : FilterElementRow() |
|
|
|
object Weekend : FilterElementRow() |
|
|
|
|
|
|
|
|
|
|
|
open class DataFilterElementRow(data:Manageable) : FilterElementRow() { |
|
|
|
open class DataFilterElementRow(data: Manageable) : FilterElementRow() { |
|
|
|
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 SingleValueFilterElementRow(val value:Int) : FilterElementRow() |
|
|
|
open class StaticDataFilterElementRow(var row: RowRepresentable) : FilterElementRow() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override val resId: Int? = row.resId |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun getDataDisplayName() : String { |
|
|
|
|
|
|
|
return row.getDisplayName() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun getDataLocalizedTitle(context: Context): String { |
|
|
|
|
|
|
|
return row.localizedTitle(context) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
open class SingleValueFilterElementRow(val value: Int) : FilterElementRow() |
|
|
|
|
|
|
|
|
|
|
|
data class Blind(var sb: Double? = null, var bb: Double? = null, var code: String? = null) : FilterElementRow() |
|
|
|
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 From(var date: Date = Date()) : FilterElementRow() |
|
|
|
@ -38,23 +51,23 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
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 PastDays(var lastDays : Int = 0) : FilterElementRow() |
|
|
|
data class PastDays(var lastDays: Int = 0) : FilterElementRow() |
|
|
|
data class Limit(val limit : net.pokeranalytics.android.model.Limit) : FilterElementRow() |
|
|
|
data class Limit(val limit: net.pokeranalytics.android.model.Limit) : StaticDataFilterElementRow(limit) |
|
|
|
data class TableSize(val tableSize : net.pokeranalytics.android.model.TableSize) : FilterElementRow() |
|
|
|
data class TableSize(val tableSize: net.pokeranalytics.android.model.TableSize) : StaticDataFilterElementRow(tableSize) |
|
|
|
data class Bankroll(val bankroll: Manageable) : DataFilterElementRow(bankroll) |
|
|
|
data class Bankroll(val bankroll: Manageable) : DataFilterElementRow(bankroll) |
|
|
|
data class Game(val game: Manageable) : DataFilterElementRow(game) |
|
|
|
data class Game(val game: Manageable) : DataFilterElementRow(game) |
|
|
|
data class Location(val location: Manageable) : DataFilterElementRow(location) |
|
|
|
data class Location(val location: Manageable) : DataFilterElementRow(location) |
|
|
|
data class TournamentName(val tournamentName: Manageable) : DataFilterElementRow(tournamentName) |
|
|
|
data class TournamentName(val tournamentName: Manageable) : DataFilterElementRow(tournamentName) |
|
|
|
data class AllTournamentFeature(val tournamentFeature: Manageable) : DataFilterElementRow(tournamentFeature) |
|
|
|
data class AllTournamentFeature(val tournamentFeature: Manageable) : DataFilterElementRow(tournamentFeature) |
|
|
|
data class AnyTournamentFeature(val tournamentFeature: Manageable) : DataFilterElementRow(tournamentFeature) |
|
|
|
data class AnyTournamentFeature(val tournamentFeature: Manageable) : DataFilterElementRow(tournamentFeature) |
|
|
|
data class ResultMoreThan(var value:Double) : FilterElementRow() |
|
|
|
data class ResultMoreThan(var value: Double) : FilterElementRow() |
|
|
|
data class ResultLessThan(var value:Double) : FilterElementRow() |
|
|
|
data class ResultLessThan(var value: Double) : FilterElementRow() |
|
|
|
|
|
|
|
|
|
|
|
lateinit var filterSectionRow: FilterSectionRow |
|
|
|
lateinit var filterSectionRow: FilterSectionRow |
|
|
|
|
|
|
|
|
|
|
|
val filterName : String = this.queryType.name |
|
|
|
val filterName: String = this.queryType.name |
|
|
|
|
|
|
|
|
|
|
|
private val queryType : QueryType |
|
|
|
private val queryType: QueryType |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
return when (this) { |
|
|
|
return when (this) { |
|
|
|
is Cash -> QueryType.CASH |
|
|
|
is Cash -> QueryType.CASH |
|
|
|
@ -68,17 +81,19 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
is Live -> QueryType.LIVE |
|
|
|
is Live -> QueryType.LIVE |
|
|
|
is Online -> QueryType.ONLINE |
|
|
|
is Online -> QueryType.ONLINE |
|
|
|
is Weekday -> QueryType.WEEK_DAY |
|
|
|
is Weekday -> QueryType.WEEK_DAY |
|
|
|
is Weekend-> QueryType.WEEK_END |
|
|
|
is Weekend -> QueryType.WEEK_END |
|
|
|
|
|
|
|
|
|
|
|
/* is Today -> QueryType. |
|
|
|
/* |
|
|
|
|
|
|
|
is Today -> QueryType. |
|
|
|
is Yesterday -> R.string.yesterday |
|
|
|
is Yesterday -> R.string.yesterday |
|
|
|
is TodayAndYesterday -> R.string.yesterday_and_today |
|
|
|
is TodayAndYesterday -> R.string.yesterday_and_today |
|
|
|
is CurrentWeek -> R.string.current_week |
|
|
|
is CurrentWeek -> R.string.current_week |
|
|
|
is CurrentMonth -> R.string.current_month |
|
|
|
is CurrentMonth -> R.string.current_month |
|
|
|
is CurrentYear -> R.string.current_year |
|
|
|
is CurrentYear -> R.string.current_year |
|
|
|
is PastDays -> R.string.period_in_days |
|
|
|
is PastDays -> R.string.period_in_days |
|
|
|
is Limit -> R.string.limit |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
is Limit -> QueryType.LIMIT |
|
|
|
is TableSize -> QueryType.TABLE_SIZE |
|
|
|
is TableSize -> QueryType.TABLE_SIZE |
|
|
|
is Game -> QueryType.GAME |
|
|
|
is Game -> QueryType.GAME |
|
|
|
is Bankroll -> QueryType.BANKROLL |
|
|
|
is Bankroll -> QueryType.BANKROLL |
|
|
|
@ -92,7 +107,7 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun contains(filterElements: List<FilterElement>) : Boolean { |
|
|
|
fun contains(filterElements: List<FilterElement>): Boolean { |
|
|
|
return when (this) { |
|
|
|
return when (this) { |
|
|
|
is DataFilterElementRow -> filterElements.any { |
|
|
|
is DataFilterElementRow -> filterElements.any { |
|
|
|
it.ids.contains(this.id) |
|
|
|
it.ids.contains(this.id) |
|
|
|
@ -118,13 +133,11 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
is Live -> R.string.live |
|
|
|
is Live -> R.string.live |
|
|
|
is Online -> R.string.online |
|
|
|
is Online -> R.string.online |
|
|
|
is Weekday -> R.string.week_days |
|
|
|
is Weekday -> R.string.week_days |
|
|
|
is Weekend-> R.string.weekend |
|
|
|
is Weekend -> R.string.weekend |
|
|
|
is Year-> R.string.year |
|
|
|
is Year -> R.string.year |
|
|
|
is Month-> R.string.month_of_the_year |
|
|
|
is Month -> R.string.month_of_the_year |
|
|
|
is Day -> R.string.day_of_the_week |
|
|
|
is Day -> R.string.day_of_the_week |
|
|
|
is PastDays -> R.string.period_in_days |
|
|
|
is PastDays -> R.string.period_in_days |
|
|
|
is Limit -> R.string.limit |
|
|
|
|
|
|
|
is TableSize -> R.string.table_size |
|
|
|
|
|
|
|
is Blind -> TODO() |
|
|
|
is Blind -> TODO() |
|
|
|
is ResultMoreThan -> TODO() |
|
|
|
is ResultMoreThan -> TODO() |
|
|
|
is ResultLessThan -> TODO() |
|
|
|
is ResultLessThan -> TODO() |
|
|
|
@ -135,13 +148,21 @@ sealed class FilterElementRow : RowRepresentable { |
|
|
|
override fun getDisplayName(): String { |
|
|
|
override fun getDisplayName(): String { |
|
|
|
return when (this) { |
|
|
|
return when (this) { |
|
|
|
is DataFilterElementRow -> this.name |
|
|
|
is DataFilterElementRow -> this.name |
|
|
|
else -> return super.getDisplayName() |
|
|
|
is StaticDataFilterElementRow -> this.getDataDisplayName() |
|
|
|
|
|
|
|
else -> super.getDisplayName() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun localizedTitle(context: Context): String { |
|
|
|
|
|
|
|
return when (this) { |
|
|
|
|
|
|
|
is StaticDataFilterElementRow -> this.getDataLocalizedTitle(context) |
|
|
|
|
|
|
|
else -> super.localizedTitle(context) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override val viewType: Int = RowViewType.TITLE_CHECK.ordinal |
|
|
|
override val viewType: Int = RowViewType.TITLE_CHECK.ordinal |
|
|
|
|
|
|
|
|
|
|
|
val sectionToExclude : List < FilterSectionRow > ? |
|
|
|
val sectionToExclude: List<FilterSectionRow>? |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
val excluded = arrayListOf<FilterSectionRow>() |
|
|
|
val excluded = arrayListOf<FilterSectionRow>() |
|
|
|
if (!this.filterSectionRow.allowMultiSelection) { |
|
|
|
if (!this.filterSectionRow.allowMultiSelection) { |
|
|
|
|