feature/top10
Aurelien Hubert 7 years ago
parent 62e73494d3
commit 2422d65c06
  1. 101
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterSectionRow.kt

@ -164,104 +164,3 @@ enum class FilterSectionRow(override val resId: Int?) : RowRepresentable {
} }
} }
} }
/*
/**
* Return the type of the selection
*/
fun getType(): Type {
return when (this) {
GAME, LIMIT_TYPE -> Type.MULTIPLE
FIXED_DATE, YEAR, WEEKDAYS_OR_WEEKEND, DAY_OF_WEEK, MONTH_OF_YEAR -> Type.MULTIPLE
else -> Type.SINGLE
}
}
/**
* Returns the filter rows
*/
fun getFilterRows(realm: Realm): ArrayList<RowRepresentable> {
val rows = ArrayList<RowRepresentable>()
when (this) {
// General
CASH_TOURNAMENT -> rows.addAll(arrayListOf(FilterRow.CASH_GAME, FilterRow.TOURNAMENT))
LIVE_ONLINE -> rows.addAll(arrayListOf(FilterRow.LIVE, FilterRow.ONLINE))
GAME -> {
val games = realm.copyFromRealm(LiveData.GAME.items(realm) as RealmResults<Game>)
rows.addAll(games)
}
LIMIT_TYPE -> rows.addAll(Limit.numericValues())
TABLE_SIZE -> {
val sessions = realm.where<Session>().sort("tableSize").distinct("tableSize").findAll()
for (session in sessions) {
session.tableSize?.let {
rows.add(TableSize(it, RowViewType.TITLE_CHECK.ordinal))
}
}
}
// Date
DYNAMIC_DATE -> rows.addAll(
arrayListOf(
FilterRow.TODAY, FilterRow.YESTERDAY, FilterRow.TODAY_AND_YESTERDAY, FilterRow.CURRENT_WEEK,
FilterRow.CURRENT_MONTH, FilterRow.CURRENT_YEAR
)
)
FIXED_DATE -> {
rows.addAll(arrayListOf(FilterRow.FROM, FilterRow.TO))
}
DURATION -> rows.addAll(arrayListOf(FilterRow.PAST_DAYS))
YEAR -> {
//TODO: Maybe move this code
val calendar = Calendar.getInstance()
val sessions = realm.where<Session>().sort("endDate", Sort.DESCENDING).findAll()
val years = ArrayList<Int>()
for (session in sessions) {
session.endDate?.let {
calendar.time = it
val year = calendar.get(Calendar.YEAR)
if (!years.contains(year)) {
years.add(year)
}
}
}
for (year in years) {
rows.add(CustomizableRowRepresentable(customViewType = RowViewType.TITLE_CHECK, title = year.toString(), isSelectable = true))
}
}
WEEKDAYS_OR_WEEKEND -> rows.addAll(arrayListOf(FilterRow.WEEKDAYS, FilterRow.WEEKEND))
DAY_OF_WEEK -> {
val dfs = DateFormatSymbols.getInstance(Locale.getDefault())
for (day in dfs.weekdays) {
if (day.isNotEmpty()) {
rows.add(CustomizableRowRepresentable(customViewType = RowViewType.TITLE_CHECK, title = day, isSelectable = true))
}
}
}
MONTH_OF_YEAR -> {
val dfs = DateFormatSymbols.getInstance(Locale.getDefault())
for (month in dfs.months) {
if (month.isNotEmpty()) {
rows.add(CustomizableRowRepresentable(customViewType = RowViewType.TITLE_CHECK, title = month, isSelectable = true))
}
}
}
else -> rows.addAll(arrayListOf())
}
return rows
}
}
*/
Loading…
Cancel
Save