Work on cash filters

feature/top10
Aurelien Hubert 7 years ago
parent 8051bf4ba2
commit 83de823e66
  1. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/FilterDetailsFragment.kt
  2. 22
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterElementRow.kt
  3. 16
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterSectionRow.kt

@ -109,6 +109,8 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresenta
is FilterElementRow.PastDays -> if (row.lastDays > 0) row.lastDays.toString() else NULL_TEXT
is FilterElementRow.LastGames -> if (row.lastGames > 0) row.lastGames.toString() else NULL_TEXT
is FilterElementRow.LastSessions -> if (row.lastSessions > 0) row.lastSessions.toString() else NULL_TEXT
is FilterElementRow.ReBuyLessThan -> if (row.value > 0) row.value.toString() else NULL_TEXT
is FilterElementRow.ReBuyMoreThan -> if (row.value > 0) row.value.toString() else NULL_TEXT
is FilterElementRow.From -> row.date.shortDate()
is FilterElementRow.To -> row.date.shortDate()
is FilterElementRow.TimeFilterElementRow -> row.minutes.toMinutes(requireContext())
@ -130,6 +132,8 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresenta
is FilterElementRow.PastDays -> row.lastDays = if (value != null && value is String) value.toInt() else 0
is FilterElementRow.LastGames -> row.lastGames = if (value != null && value is String) value.toInt() else 0
is FilterElementRow.LastSessions -> row.lastSessions = if (value != null && value is String) value.toInt() else 0
is FilterElementRow.ReBuyLessThan -> row.value = if (value != null && value is String) value.toDouble() else 0.0
is FilterElementRow.ReBuyMoreThan -> row.value = if (value != null && value is String) value.toDouble() else 0.0
is FilterElementRow.TimeFilterElementRow -> {
if (value is ArrayList<*>) {
val hours = try {

@ -33,6 +33,8 @@ sealed class FilterElementRow : RowRepresentable {
object ResultMoreThan : MoreFilterElementRow()
object ResultLessThan : LessFilterElementRow()
object ReBuyMoreThan: MoreFilterElementRow()
object ReBuyLessThan: LessFilterElementRow()
object DurationMoreThan : MoreTimeFilterElementRow()
object DurationLessThan : LessTimeFilterElementRow()
@ -172,6 +174,8 @@ sealed class FilterElementRow : RowRepresentable {
is Blind -> R.string.blinds
is LastGames -> R.string.last_records
is LastSessions -> R.string.last_sessions
is ReBuyMoreThan -> R.string.maximum
is ReBuyLessThan -> R.string.minimum
is MoreFilterElementRow, is MoreTimeFilterElementRow -> R.string.more_than
is LessFilterElementRow, is LessTimeFilterElementRow -> R.string.less_than
else -> null
@ -181,9 +185,7 @@ sealed class FilterElementRow : RowRepresentable {
override val viewType: Int
get() {
return when (this) {
is PastDays,
is From, is To,
is LastGames, is LastSessions,
is PastDays, is From, is To, is LastGames, is LastSessions, is ReBuyMoreThan, is ReBuyLessThan,
is DurationMoreThan, is DurationLessThan -> RowViewType.TITLE_VALUE_CHECK.ordinal
else -> RowViewType.TITLE_CHECK.ordinal
}
@ -192,7 +194,7 @@ sealed class FilterElementRow : RowRepresentable {
override val bottomSheetType: BottomSheetType
get() {
return when (this) {
is PastDays, is LastGames, is LastSessions -> BottomSheetType.EDIT_TEXT
is PastDays, is LastGames, is LastSessions, is ReBuyMoreThan, is ReBuyLessThan -> BottomSheetType.EDIT_TEXT
is DurationMoreThan, is DurationLessThan -> BottomSheetType.DOUBLE_EDIT_TEXT
else -> BottomSheetType.NONE
}
@ -218,6 +220,18 @@ sealed class FilterElementRow : RowRepresentable {
RowRepresentableEditDescriptor(lastSessions, R.string.last_sessions, inputType = InputType.TYPE_CLASS_NUMBER)
)
}
is ReBuyMoreThan -> {
val reBuyMore: String? by map
arrayListOf(
RowRepresentableEditDescriptor(reBuyMore, R.string.maximum, inputType = InputType.TYPE_CLASS_NUMBER)
)
}
is ReBuyLessThan -> {
val reBuyLess: String? by map
arrayListOf(
RowRepresentableEditDescriptor(reBuyLess, R.string.minimum, inputType = InputType.TYPE_CLASS_NUMBER)
)
}
is DurationMoreThan, is DurationLessThan -> {
val hours: String? by map
val minutes: String? by map

@ -9,7 +9,6 @@ import net.pokeranalytics.android.model.realm.Session
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterElementRow.*
import timber.log.Timber
import java.text.DateFormatSymbols
import java.util.*
@ -140,18 +139,27 @@ enum class FilterSectionRow(override val resId: Int?) : RowRepresentable {
}
BLINDS -> {
// TODO: Improve the way we get the blinds distinctly
val blinds = arrayListOf<FilterElementRow.Blind>()
val realm = Realm.getDefaultInstance()
val sessions = realm.where<Session>().findAll().sort("cgSmallBlind", Sort.ASCENDING)
// TODO: manage for big blind too... ?
val distinctBlinds = sessions.distinctBy { it.cgSmallBlind }
val distinctBlinds: ArrayList<Session> = ArrayList()
val blindsHashMap: ArrayList<String> = ArrayList()
sessions.forEach {
if (!blindsHashMap.contains(it.getBlinds())) {
blindsHashMap.add(it.getBlinds())
distinctBlinds.add(it)
}
}
distinctBlinds.forEach { session ->
blinds.add(Blind(session.cgSmallBlind, session.cgBigBlind))
session.getBlinds()
Timber.d("Blinds: ${session.cgSmallBlind} / ${session.cgBigBlind}")
}
realm.close()
blinds
}
CASH_RE_BUY_COUNT -> arrayListOf()

Loading…
Cancel
Save