update / refactor filters

feature/top10
Razmig Sarkissian 7 years ago
parent 88f76685df
commit ff646f6c31
  1. 11
      app/src/main/java/net/pokeranalytics/android/model/Limit.kt
  2. 11
      app/src/main/java/net/pokeranalytics/android/model/realm/Game.kt
  3. 93
      app/src/main/java/net/pokeranalytics/android/ui/fragment/FilterDetailsFragment.kt
  4. 7
      app/src/main/java/net/pokeranalytics/android/ui/fragment/FiltersFragment.kt
  5. 30
      app/src/main/java/net/pokeranalytics/android/ui/view/RowRepresentable.kt
  6. 81
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterCategory.kt
  7. 117
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterCategoryRow.kt
  8. 155
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterRow.kt
  9. 150
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterSection.kt

@ -1,7 +1,7 @@
package net.pokeranalytics.android.model
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterSubcategoryRow
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterSection
enum class Limit : RowRepresentable {
NO,
@ -36,13 +36,4 @@ enum class Limit : RowRepresentable {
override fun getDisplayName(): String {
return this.longName
}
/**
* Filters management
*/
override fun subcategoryRow(): FilterSubcategoryRow? {
return FilterSubcategoryRow.LIMIT_TYPE
}
}

@ -8,7 +8,7 @@ import net.pokeranalytics.android.model.interfaces.Manageable
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterSubcategoryRow
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterSection
import net.pokeranalytics.android.ui.view.rowrepresentable.GameRow
import net.pokeranalytics.android.ui.view.rowrepresentable.SimpleRow
import net.pokeranalytics.android.util.NULL_TEXT
@ -76,13 +76,4 @@ open class Game : RealmObject(), Manageable, StaticRowRepresentableDataSource, R
override fun getFailedSaveMessage(): Int {
return R.string.variant_empty_name_error
}
/**
* Filters management
*/
override fun subcategoryRow(): FilterSubcategoryRow? {
return FilterSubcategoryRow.GAME
}
}

@ -12,32 +12,30 @@ import kotlinx.android.synthetic.main.fragment_filter_details.view.*
import net.pokeranalytics.android.R
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter
import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetFragment
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterCategoryRow
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterRow
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterSubcategoryRow
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterCategory
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterElement
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterSection
import timber.log.Timber
open class FilterDetailsFragment : PokerAnalyticsFragment(), RowRepresentableDataSource, RowRepresentableDelegate {
open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentableDataSource, RowRepresentableDelegate {
lateinit var parentActivity: PokerAnalyticsActivity
lateinit var item: RealmObject
lateinit var rowRepresentableAdapter: RowRepresentableAdapter
private var rows: ArrayList<RowRepresentable> = ArrayList()
private var rowsForFilterSubcategory: HashMap<FilterSubcategoryRow, ArrayList<RowRepresentable>> = HashMap()
private var rowsForFilterSubcategory: HashMap<FilterSection, ArrayList<RowRepresentable>> = HashMap()
private var filterMenu: Menu? = null
private var filterCategory: FilterCategoryRow? = null
private var filterCategory: FilterCategory? = null
val selectedRows = ArrayList<RowRepresentable>()
val selectedRows = ArrayList<FilterElement>()
var isUpdating = false
@ -63,83 +61,38 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), RowRepresentableDat
val oldRows = ArrayList<RowRepresentable>()
oldRows.addAll(rows)
if (selectedRows.contains(row)) {
selectedRows.remove(row)
} else {
val excludedRows = ArrayList<RowRepresentable>()
// Exclude the rows of the same subcategory if we are an a single row selection
if (row.subcategoryRow()?.getType() == FilterSubcategoryRow.Type.SINGLE) {
row.subcategoryRow()?.let { filterSubcategory ->
rowsForFilterSubcategory[filterSubcategory]?.let { filterRows ->
excludedRows.addAll(filterRows)
if (row is FilterElement) {
row.sectionToExclude?.let { filterSectionToExclude ->
val excludedFilters = selectedRows.filter {
filterSectionToExclude.contains(it.filterSection)
}
}
}
// Exclude the filter rows of the subcategories
row.excludedFilterSubcategoryRows()?.let { subcategories ->
for (subcategory in subcategories) {
rowsForFilterSubcategory[subcategory]?.let { rows ->
excludedRows.addAll(rows)
excludedFilters .forEach {
selectedRows.remove(it)
rowRepresentableAdapter.refreshRow(it)
}
}
}
// Exclude the filter rows
row.excludedFilterRows()?.let {
excludedRows.addAll(it)
}
for (filterRow in excludedRows) {
if (selectedRows.contains(filterRow)) {
selectedRows.remove(filterRow)
rowRepresentableAdapter.refreshRow(filterRow)
}
}
selectedRows.add(row)
}
selectedRows.add(row)
}
rowRepresentableAdapter.refreshRow(row)
when(row) {
FilterRow.FROM -> BottomSheetFragment.create(fragmentManager, row, this, null)
}
}
override fun isSelected(row: RowRepresentable): Boolean {
return selectedRows.contains(row)
}
override fun onRowValueChanged(value: Any?, row: RowRepresentable) {
super.onRowValueChanged(value, row)
}
override fun adapterRows(): List<RowRepresentable>? {
return rows
}
override fun rowRepresentableForPosition(position: Int): RowRepresentable? {
return rows[position]
}
override fun numberOfRows(): Int {
return rows.size
}
override fun viewTypeForPosition(position: Int): Int {
val rowViewType = rowRepresentableForPosition(position)?.viewType ?: -1
return if (rowViewType != -1) rowViewType else RowViewType.TITLE_CHECK.ordinal
}
override fun indexForRow(row: RowRepresentable): Int {
return rows.indexOf(row)
}
/**
* Init UI
*/
@ -172,15 +125,7 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), RowRepresentableDat
this.rows.clear()
this.rowsForFilterSubcategory.clear()
for (subcategory in it.getSubcategories()) {
this.rows.add(subcategory)
val subcategoryRows = subcategory.getFilterRows(getRealm())
this.rowsForFilterSubcategory.put(subcategory, subcategoryRows)
this.rows.addAll(subcategoryRows)
}
this.rows.addAll(it.filterElements)
this.rowRepresentableAdapter = RowRepresentableAdapter(this, this)
this.recyclerView.adapter = rowRepresentableAdapter
}
@ -217,7 +162,7 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), RowRepresentableDat
*/
fun setData(filterCategory: Int) {
this.filterCategory = FilterCategoryRow.values()[filterCategory]
this.filterCategory = FilterCategory.values()[filterCategory]
/*
this.dataType = dataType

@ -15,7 +15,7 @@ import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterCategoryRow
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterCategory
import timber.log.Timber
@ -90,8 +90,7 @@ open class FiltersFragment : PokerAnalyticsFragment(), StaticRowRepresentableDat
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) {
super.onRowSelected(position, row, fromAction)
if (row is FilterCategoryRow) {
Timber.d("Subcategories: ${row.getSubcategories()}")
if (row is FilterCategory) {
selectedRow = row
FilterDetailsActivity.newInstanceForResult(this, row.ordinal, REQUEST_CODE_FILTER_DETAILS)
}
@ -126,7 +125,7 @@ open class FiltersFragment : PokerAnalyticsFragment(), StaticRowRepresentableDat
this.appBar.toolbar.title = getString(R.string.filter)
rows.addAll(FilterCategoryRow.values())
rows.addAll(FilterCategory.values())
this.rowRepresentableAdapter = RowRepresentableAdapter(this, this)
this.recyclerView.adapter = rowRepresentableAdapter

@ -3,46 +3,18 @@ package net.pokeranalytics.android.ui.view
import android.content.Context
import net.pokeranalytics.android.model.LiveData
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetType
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterRow
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterSubcategoryRow
import net.pokeranalytics.android.util.NULL_TEXT
/**
* An interface extending Displayable to add a way to represent an object as a String
*/
interface RowRepresentable : Displayable, Editable, Filterable {
interface RowRepresentable : Displayable, Editable {
fun getDisplayName(): String {
return NULL_TEXT
}
}
/**
* An interface used to manage the filters
*/
interface Filterable {
/**
* The subcategory of a filter
*/
fun subcategoryRow(): FilterSubcategoryRow? {
return null
}
/**
* Return the filter rows to deactivate
*/
fun excludedFilterRows(): ArrayList<FilterRow>? {
return null
}
/**
* Return the Filter Subcategory rows to deactivate
*/
fun excludedFilterSubcategoryRows(): ArrayList<FilterSubcategoryRow>? {
return null
}
}
interface Editable {
fun editingDescriptors(map: Map<String, Any?>): ArrayList<RowRepresentableEditDescriptor>? {
return null

@ -0,0 +1,81 @@
package net.pokeranalytics.android.ui.view.rowrepresentable
import net.pokeranalytics.android.R
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType
enum class FilterCategory(override val resId: Int?, override val viewType: Int = RowViewType.TITLE_VALUE_ARROW.ordinal) : RowRepresentable {
GENERAL(R.string.general),
DATE(R.string.date),
/*
DURATION(R.string.duration, DurationSubCategory.values()),
SESSION(R.string.session, SessionSubCategory.values()),
CASH(R.string.cash, CashSubCategory.values()),
TOURNAMENT(R.string.tournament, TournamentSubCategory.values()),
ONLINE(R.string.online, OnlineSubCategory.values()),
RESULT(R.string.result, ResultSubCategory.values()),
TRANSACTION_TYPES(R.string.operation_types, TransactionSubCategory.values()),
LOCATION(R.string.locations, LocationSubCategory.values()),
BANKROLL(R.string.bankrolls, BankrollSubCategory.values()),
PLAYERS(R.string.players, PlayerSubCategory.values());
*/
;
val filterElements : List < RowRepresentable >
get() {
return filterSections.flatMap {
it.filterElements
}
}
private val filterSections : List < FilterSectionDataSource >
get() {
return FilterSection.filterSectionsFor(this)
}
/*
private enum class DurationSubCategory(val category : FilterCategory = DURATION): RowRepresentable {
SESSION_DURATION,
RANGE,
}
private enum class CashSubCategory(val category : FilterCategory = CASH): RowRepresentable {
BLINDS,
CASH_RE_BUY_COUNT,
}
private enum class TournamentSubCategory(val category : FilterCategory = TOURNAMENT): RowRepresentable {
TOURNAMENT_TYPE,
COMPLETION_PERCENTAGE,
PLACE,
PLAYERS_COUNT,
TOURNAMENT_RE_BUY_COUNT,
BUY_IN,
}
private enum class OnlineSubCategory(val category : FilterCategory = ONLINE): RowRepresentable {
MULTI_TABLING,
}
private enum class SessionSubCategory(val category : FilterCategory = SESSION): RowRepresentable
private enum class TransactionSubCategory(val category : FilterCategory = TRANSACTION_TYPES): RowRepresentable
private enum class ResultSubCategory(val category : FilterCategory = RESULT): RowRepresentable {
VALUE,
}
private enum class LocationSubCategory(val category : FilterCategory = FilterCategory.LOCATION): RowRepresentable {
LOCATION,
}
private enum class BankrollSubCategory(val category : FilterCategory = FilterCategory.BANKROLL): RowRepresentable {
BANKROLL,
}
private enum class PlayerSubCategory(val category : FilterCategory = PLAYERS): RowRepresentable {
NUMBER_OF_PLAYERS,
MULTI_PLAYER;
}
*/
}

@ -1,117 +0,0 @@
package net.pokeranalytics.android.ui.view.rowrepresentable
import net.pokeranalytics.android.R
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType
/*
enum class FilterCategoryRow(override val resId: Int?, val subCategories:Array<out RowRepresentable>, override val viewType: Int = RowViewType.TITLE_VALUE_ARROW.ordinal) : RowRepresentable {
GENERAL(R.string.general, GeneralSubCategory.values()),
DATE,
DURATION,
SESSION,
CASH,
TOURNAMENT,
ONLINE,
RESULT,
TRANSACTION_TYPES,
// Title Custom fields
LOCATION,
BANKROLL,
PLAYERS;
private enum class GeneralSubCategory(val category : FilterCategoryRow = GENERAL): RowRepresentable {
CASH_TOURNAMENT,
LIVE_ONLINE,
GAME,
LIMIT_TYPE,
TABLE_SIZE,
}
*/
enum class FilterCategoryRow : RowRepresentable {
GENERAL,
DATE,
DURATION,
SESSION,
CASH,
TOURNAMENT,
ONLINE,
RESULT,
TRANSACTION_TYPES,
// Title Custom fields
LOCATION,
BANKROLL,
PLAYERS;
override val resId: Int?
get() {
return when (this) {
GENERAL -> R.string.general
DATE -> R.string.date
DURATION -> R.string.duration
SESSION -> R.string.session
CASH -> R.string.cash
TOURNAMENT -> R.string.tournament
ONLINE -> R.string.online
RESULT -> R.string.result
TRANSACTION_TYPES -> R.string.operation_types
LOCATION -> R.string.location
BANKROLL -> R.string.bankroll
PLAYERS -> R.string.players
}
}
override val viewType: Int
get() {
return when (this) {
GENERAL, DATE, DURATION, SESSION, CASH, TOURNAMENT, ONLINE, RESULT, TRANSACTION_TYPES,
LOCATION, BANKROLL, PLAYERS -> RowViewType.TITLE_VALUE_ARROW.ordinal
}
}
/**
* Get subcategories of filters
*/
fun getSubcategories(): ArrayList<FilterSubcategoryRow> {
val subcategories = ArrayList<FilterSubcategoryRow>()
when (this) {
GENERAL -> subcategories.addAll(
arrayListOf(
FilterSubcategoryRow.CASH_TOURNAMENT, FilterSubcategoryRow.LIVE_ONLINE, FilterSubcategoryRow.GAME,
FilterSubcategoryRow.LIMIT_TYPE, FilterSubcategoryRow.TABLE_SIZE
)
)
DATE -> subcategories.addAll(
arrayListOf(
FilterSubcategoryRow.DYNAMIC_DATE, FilterSubcategoryRow.FIXED_DATE, FilterSubcategoryRow.DURATION, FilterSubcategoryRow.YEAR,
FilterSubcategoryRow.WEEKDAYS_OR_WEEKEND, FilterSubcategoryRow.DAY_OF_WEEK, FilterSubcategoryRow.MONTH_OF_YEAR
)
)
DURATION -> subcategories.addAll(arrayListOf(FilterSubcategoryRow.SESSION_DURATION, FilterSubcategoryRow.RANGE))
SESSION -> subcategories.addAll(arrayListOf())
CASH -> subcategories.addAll(arrayListOf(FilterSubcategoryRow.BLINDS, FilterSubcategoryRow.CASH_RE_BUY_COUNT))
TOURNAMENT -> subcategories.addAll(
arrayListOf(
FilterSubcategoryRow.TOURNAMENT_TYPE, FilterSubcategoryRow.COMPLETION_PERCENTAGE, FilterSubcategoryRow.PLACE,
FilterSubcategoryRow.PLAYERS_COUNT, FilterSubcategoryRow.TOURNAMENT_RE_BUY_COUNT, FilterSubcategoryRow.BUY_IN
)
)
ONLINE -> subcategories.addAll(arrayListOf(FilterSubcategoryRow.MULTI_TABLING))
RESULT -> subcategories.addAll(arrayListOf(FilterSubcategoryRow.VALUE))
TRANSACTION_TYPES -> subcategories.addAll(arrayListOf())
LOCATION -> subcategories.addAll(arrayListOf(FilterSubcategoryRow.LOCATION))
BANKROLL -> subcategories.addAll(arrayListOf(FilterSubcategoryRow.BANKROLL))
PLAYERS -> subcategories.addAll(arrayListOf(FilterSubcategoryRow.NUMBER_OF_PLAYERS, FilterSubcategoryRow.MULTI_PLAYER))
}
return subcategories
}
}

@ -1,117 +1,96 @@
package net.pokeranalytics.android.ui.view.rowrepresentable
import io.realm.Realm
import net.pokeranalytics.android.R
import net.pokeranalytics.android.model.LiveData
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType
/*
import java.lang.Exception
import java.util.*
sealed class FilterElement : RowRepresentable {
class Cash : FilterElement()
class Tournament : FilterElement()
data class Game(val game: net.pokeranalytics.android.model.realm.Game) : FilterElement()
var value : Any? = null
override val resId: Int?
get() {
return when (this) {
is Cash -> R.string.cash_game
is Tournament -> R.string.tournament
else -> null
}
}
override val viewType: Int
get() {
return when (this) {
else -> RowViewType.TITLE_CHECK.ordinal
companion object {
fun filterElementsFor(filterSection: FilterSectionDataSource) : List<FilterElement> {
return when (filterSection) {
FilterSection.CASH_TOURNAMENT -> arrayListOf(Cash, Tournament)
FilterSection.DYNAMIC_DATE -> arrayListOf(Today, Yesterday, TodayAndYesterday, CurrentWeek, CurrentMonth, CurrentYear)
FilterSection.FIXED_DATE -> arrayListOf(From(), To())
FilterSection.GAMES -> {
val games = arrayListOf<Game>()
val realm = Realm.getDefaultInstance()
LiveData.GAME.items(realm).forEach {
val game = Game(it as net.pokeranalytics.android.model.realm.Game)
games.add(game)
}
realm.close()
games
}
else -> throw Exception() //TODO create exception
}
}
}
}
*/
enum class FilterRow : RowRepresentable {
// General
CASH_GAME,
TOURNAMENT,
LIVE,
ONLINE,
object Cash : FilterElement()
object Tournament : FilterElement()
object Today : FilterElement()
object Yesterday : FilterElement()
object TodayAndYesterday : FilterElement()
object CurrentWeek : FilterElement()
object CurrentMonth : FilterElement()
object CurrentYear: FilterElement()
data class From(var date: Date = Date()) : FilterElement()
data class To(var date: Date = Date()) : FilterElement()
// Date
TODAY,
YESTERDAY,
TODAY_AND_YESTERDAY,
CURRENT_WEEK,
CURRENT_MONTH,
CURRENT_YEAR,
FROM,
TO,
PAST_DAYS,
WEEKDAYS,
WEEKEND,
data class Game(val game: net.pokeranalytics.android.model.realm.Game) : FilterElement()
;
var filterSection: FilterSectionDataSource? = null
override val resId: Int?
get() {
return when (this) {
CASH_GAME -> R.string.cash_game
TOURNAMENT -> R.string.tournament
LIVE -> R.string.live
ONLINE -> R.string.online
TODAY -> R.string.today
YESTERDAY -> R.string.yesterday
TODAY_AND_YESTERDAY -> R.string.yesterday_and_today
CURRENT_WEEK -> R.string.current_week
CURRENT_MONTH -> R.string.current_month
CURRENT_YEAR -> R.string.current_year
FROM -> R.string.from
TO -> R.string.to
PAST_DAYS -> R.string.period_in_days
WEEKDAYS -> R.string.week_days
WEEKEND -> R.string.weekend
is Cash -> R.string.cash_game
is Tournament -> R.string.tournament
is Today -> R.string.today
is Yesterday -> R.string.yesterday
is TodayAndYesterday -> R.string.yesterday_and_today
is CurrentWeek -> R.string.current_week
is CurrentMonth -> R.string.current_month
is CurrentYear -> R.string.current_year
is From -> R.string.from
is To -> R.string.to
else -> null
}
}
override val viewType: Int
get() {
return when (this) {
FROM, TO -> RowViewType.TITLE_VALUE_CHECK.ordinal
else -> RowViewType.TITLE_CHECK.ordinal
}
}
override fun excludedFilterRows(): ArrayList<FilterRow>? {
override fun getDisplayName(): String {
return when (this) {
CASH_GAME, TOURNAMENT -> arrayListOf(CASH_GAME, TOURNAMENT)
LIVE, ONLINE -> arrayListOf(LIVE, ONLINE)
else -> ArrayList()
is Game -> game.getDisplayName()
else -> return super.getDisplayName()
}
}
override fun excludedFilterSubcategoryRows(): ArrayList<FilterSubcategoryRow>? {
return when (this) {
TODAY, YESTERDAY, TODAY_AND_YESTERDAY, CURRENT_WEEK, CURRENT_MONTH, CURRENT_YEAR -> arrayListOf(FilterSubcategoryRow.FIXED_DATE)
FROM, TO -> arrayListOf(FilterSubcategoryRow.DYNAMIC_DATE)
else -> null
}
}
override val viewType: Int = RowViewType.TITLE_CHECK.ordinal
val sectionToExclude : List < FilterSectionDataSource > ?
get() {
val excluded = arrayListOf<FilterSectionDataSource>()
this.filterSection?.let {
if (!it.allowMultiSelection) {
excluded.add(it)
}
it.exclusiveWith?.let { exclusives ->
excluded.addAll(exclusives)
}
if (excluded.size > 0) {
return excluded
}
} ?: run {
return null
}
override fun subcategoryRow(): FilterSubcategoryRow? {
return when (this) {
CASH_GAME, TOURNAMENT -> FilterSubcategoryRow.TOURNAMENT_TYPE
LIVE, ONLINE -> FilterSubcategoryRow.LIVE_ONLINE
TODAY, YESTERDAY, TODAY_AND_YESTERDAY, CURRENT_WEEK, CURRENT_MONTH, CURRENT_YEAR -> FilterSubcategoryRow.DYNAMIC_DATE
FROM, TO -> FilterSubcategoryRow.FIXED_DATE
PAST_DAYS -> FilterSubcategoryRow.DURATION
WEEKDAYS, WEEKEND -> FilterSubcategoryRow.WEEKDAYS_OR_WEEKEND
else -> null
return null
}
}
}

@ -1,19 +1,139 @@
package net.pokeranalytics.android.ui.view.rowrepresentable
import io.realm.Realm
import io.realm.RealmResults
import io.realm.Sort
import io.realm.kotlin.where
import net.pokeranalytics.android.model.Limit
import net.pokeranalytics.android.model.LiveData
import net.pokeranalytics.android.model.TableSize
import net.pokeranalytics.android.model.realm.Game
import net.pokeranalytics.android.model.realm.Session
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType
import java.text.DateFormatSymbols
import java.util.*
import kotlin.collections.ArrayList
interface FilterSectionDataSource : RowRepresentable {
enum class SelectionType {
SINGLE,
MULTIPLE,
}
val allowMultiSelection : Boolean
val exclusiveWith : List < FilterSectionDataSource > ?
val filterElementRows : List < FilterElement >
val filterElements : List < RowRepresentable >
val selectionType : SelectionType
}
private interface DefaultFilterSectionDataSource : FilterSectionDataSource {
override val viewType: Int
get() = RowViewType.HEADER_TITLE.ordinal
override val exclusiveWith: List<FilterSectionDataSource>?
get() = null
override val allowMultiSelection : Boolean
get() = (this.selectionType == FilterSectionDataSource.SelectionType.MULTIPLE)
override val selectionType: FilterSectionDataSource.SelectionType
get() = FilterSectionDataSource.SelectionType.MULTIPLE
override val filterElementRows: List < FilterElement >
get() = FilterElement.filterElementsFor(this)
override val filterElements : List < RowRepresentable >
get() {
val elements = arrayListOf<RowRepresentable>(this)
filterElementRows.forEach {
it.filterSection = this
elements.add(it)
}
return elements
}
}
enum class FilterSection(override val resId: Int?): DefaultFilterSectionDataSource, RowRepresentable {
CASH_TOURNAMENT(net.pokeranalytics.android.R.string.cash_or_tournament),
GAMES(net.pokeranalytics.android.R.string.games),
/*
LIVE_ONLINE,
GAME,
LIMIT_TYPE,
TABLE_SIZE,
*/
DYNAMIC_DATE(net.pokeranalytics.android.R.string.dynamic_date),
FIXED_DATE(net.pokeranalytics.android.R.string.fixed_date),
/*
DURATION,
YEAR,
WEEKDAYS_OR_WEEKEND,
DAY_OF_WEEK,
MONTH_OF_YEAR,
// Duration
SESSION_DURATION,
RANGE,
// Sessions
// -
// Cash
BLINDS,
CASH_RE_BUY_COUNT,
// Tournament
TOURNAMENT_TYPE,
COMPLETION_PERCENTAGE,
PLACE,
PLAYERS_COUNT,
TOURNAMENT_RE_BUY_COUNT,
BUY_IN,
// Online
MULTI_TABLING,
// Result
VALUE,
// Transaction types
// -
// Location
LOCATION,
// Bankroll
BANKROLL,
// Players
NUMBER_OF_PLAYERS,
MULTI_PLAYER;
*/
;
companion object {
fun filterSectionsFor(category: FilterCategory) : List < FilterSection > {
return when (category) {
FilterCategory.GENERAL -> arrayListOf(CASH_TOURNAMENT, GAMES)
FilterCategory.DATE -> arrayListOf(DYNAMIC_DATE, FIXED_DATE)
}
}
}
override val viewType: Int = RowViewType.HEADER_TITLE.ordinal
override val selectionType: FilterSectionDataSource.SelectionType
get() {
return when (this) {
CASH_TOURNAMENT, DYNAMIC_DATE -> FilterSectionDataSource.SelectionType.SINGLE
else -> FilterSectionDataSource.SelectionType.MULTIPLE
}
}
override val exclusiveWith: List<FilterSection>?
get() {
return when (this) {
DYNAMIC_DATE -> arrayListOf(FIXED_DATE)
FIXED_DATE -> arrayListOf(DYNAMIC_DATE)
else -> null
}
}
}
/*
GAME -> {
@ -23,7 +143,9 @@ import kotlin.collections.ArrayList
}
}
*/
enum class FilterSubcategoryRow : RowRepresentable {
/*
enum class FilterSection : RowRepresentable {
// General
CASH_TOURNAMENT,
@ -224,3 +346,5 @@ enum class FilterSubcategoryRow : RowRepresentable {
}
}
*/
Loading…
Cancel
Save