diff --git a/app/src/main/java/net/pokeranalytics/android/ui/fragment/FilterDetailsFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/fragment/FilterDetailsFragment.kt index 153f1704..62849a70 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/fragment/FilterDetailsFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/fragment/FilterDetailsFragment.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 { diff --git a/app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterElementRow.kt b/app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterElementRow.kt index e14ab6b2..ab5b1978 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterElementRow.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterElementRow.kt @@ -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 diff --git a/app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterSectionRow.kt b/app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterSectionRow.kt index 005feb89..61223a17 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterSectionRow.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterSectionRow.kt @@ -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() val realm = Realm.getDefaultInstance() val sessions = realm.where().findAll().sort("cgSmallBlind", Sort.ASCENDING) - // TODO: manage for big blind too... ? - val distinctBlinds = sessions.distinctBy { it.cgSmallBlind } + val distinctBlinds: ArrayList = ArrayList() + val blindsHashMap: ArrayList = 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()