Merge branch 'dev' of gitlab.com:stax-river/poker-analytics into dev

feature/top10
Laurent 7 years ago
commit 32334f8dac
  1. 3
      app/proguard-rules.pro
  2. 3
      app/src/main/java/net/pokeranalytics/android/model/filter/QueryCondition.kt
  3. 2
      app/src/main/java/net/pokeranalytics/android/model/realm/FilterCondition.kt
  4. 2
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  5. 22
      app/src/main/java/net/pokeranalytics/android/model/utils/Seed.kt
  6. 9
      app/src/main/java/net/pokeranalytics/android/ui/fragment/FilterDetailsFragment.kt
  7. 9
      app/src/main/java/net/pokeranalytics/android/ui/helpers/DateTimePickerManager.kt
  8. 36
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterElementRow.kt
  9. 38
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/FilterSectionRow.kt
  10. 21
      app/src/main/java/net/pokeranalytics/android/util/CurrencyUtils.kt

@ -58,3 +58,6 @@
# Guava # Guava
-dontwarn com.google.j2objc.annotations.** -dontwarn com.google.j2objc.annotations.**
-keep class com.google.j2objc.annotations.** { *; } -keep class com.google.j2objc.annotations.** { *; }
# Enum
-optimizations !class/unboxing/enum

@ -6,6 +6,7 @@ import net.pokeranalytics.android.exceptions.PokerAnalyticsException
import net.pokeranalytics.android.model.realm.FilterCondition import net.pokeranalytics.android.model.realm.FilterCondition
import net.pokeranalytics.android.model.realm.FilterElementBlind import net.pokeranalytics.android.model.realm.FilterElementBlind
import net.pokeranalytics.android.model.realm.Session import net.pokeranalytics.android.model.realm.Session
import net.pokeranalytics.android.util.Preferences
import net.pokeranalytics.android.util.extensions.endOfDay import net.pokeranalytics.android.util.extensions.endOfDay
import net.pokeranalytics.android.util.extensions.startOfDay import net.pokeranalytics.android.util.extensions.startOfDay
import java.util.* import java.util.*
@ -73,6 +74,8 @@ enum class QueryCondition(var operator: Operator? = null) {
PAST_DAYS, PAST_DAYS,
MORE_THAN_DURATION(Operator.MORE), MORE_THAN_DURATION(Operator.MORE),
LESS_THAN_DURATION(Operator.LESS), LESS_THAN_DURATION(Operator.LESS),
STARTED_FROM_TIME,
ENDED_TO_TIME,
CURRENCY, CURRENCY,
CURRENCY_CODE, CURRENCY_CODE,

@ -116,7 +116,7 @@ open class FilterCondition() : RealmObject() {
*/ */
fun getFilterConditionValue(filterElementRow: FilterElementRow): Any? { fun getFilterConditionValue(filterElementRow: FilterElementRow): Any? {
return when (filterElementRow) { return when (filterElementRow) {
is From, is To -> dateValue //TODO: Probably change by 'date' (doesn't work now because the value isn't correctly saved is DateFilterElementRow -> date
is PastDays -> values is PastDays -> values
else -> throw PokerAnalyticsException.FilterElementTypeMissing(filterElementRow) else -> throw PokerAnalyticsException.FilterElementTypeMissing(filterElementRow)
} }

@ -486,7 +486,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
* Return the formatted blinds * Return the formatted blinds
*/ */
fun getBlinds(): String { fun getBlinds(): String {
val currencyCode = bankroll?.currency?.code ?: Currency.getInstance(Locale.getDefault()).currencyCode val currencyCode = bankroll?.currency?.code ?: CurrencyUtils.getLocaleCurrency().currencyCode
val currencySymbol = Currency.getInstance(currencyCode).symbol val currencySymbol = Currency.getInstance(currencyCode).symbol
return if (cgSmallBlind == null) NULL_TEXT else "$currencySymbol ${cgSmallBlind?.formatted()}/${cgBigBlind?.round()}" return if (cgSmallBlind == null) NULL_TEXT else "$currencySymbol ${cgSmallBlind?.formatted()}/${cgBigBlind?.round()}"
} }

@ -3,12 +3,15 @@ package net.pokeranalytics.android.model.utils
import android.content.Context import android.content.Context
import io.realm.Realm import io.realm.Realm
import io.realm.kotlin.where import io.realm.kotlin.where
import net.pokeranalytics.android.R import net.pokeranalytics.android.model.realm.Bankroll
import net.pokeranalytics.android.model.realm.*
import net.pokeranalytics.android.model.realm.Currency import net.pokeranalytics.android.model.realm.Currency
import net.pokeranalytics.android.util.Preferences import net.pokeranalytics.android.model.realm.Game
import net.pokeranalytics.android.model.realm.TournamentFeature
import net.pokeranalytics.android.util.CurrencyUtils
import java.util.* import java.util.*
class Seed(var context:Context) : Realm.Transaction { class Seed(var context:Context) : Realm.Transaction {
override fun execute(realm: Realm) { override fun execute(realm: Realm) {
@ -18,7 +21,7 @@ class Seed(var context:Context) : Realm.Transaction {
} }
private fun createDefaultTournamentFeatures(realm: Realm) { private fun createDefaultTournamentFeatures(realm: Realm) {
context.resources.getStringArray(R.array.seed_tournament_features).forEach { context.resources.getStringArray(net.pokeranalytics.android.R.array.seed_tournament_features).forEach {
val tournamentFeature = TournamentFeature() val tournamentFeature = TournamentFeature()
tournamentFeature.id = UUID.randomUUID().toString() tournamentFeature.id = UUID.randomUUID().toString()
tournamentFeature.name = it tournamentFeature.name = it
@ -27,23 +30,26 @@ class Seed(var context:Context) : Realm.Transaction {
} }
private fun createDefaultCurrencyAndBankroll(realm: Realm) { private fun createDefaultCurrencyAndBankroll(realm: Realm) {
Locale.setDefault(Locale.JAPANESE)
// Currency // Currency
val localeCurrency = java.util.Currency.getInstance(Locale.getDefault()) val localeCurrency = CurrencyUtils.getLocaleCurrency()
val defaultCurrency = Currency() val defaultCurrency = Currency()
defaultCurrency.code = localeCurrency.currencyCode defaultCurrency.code = localeCurrency.currencyCode
realm.insertOrUpdate(defaultCurrency) realm.insertOrUpdate(defaultCurrency)
// Bankroll // Bankroll
val bankroll = Bankroll() val bankroll = Bankroll()
bankroll.name = context.resources.getString(R.string.live) bankroll.name = context.resources.getString(net.pokeranalytics.android.R.string.live)
bankroll.live = true bankroll.live = true
bankroll.currency = realm.where<Currency>().equalTo("code", localeCurrency.currencyCode).findFirst() bankroll.currency = realm.where<Currency>().equalTo("code", localeCurrency.currencyCode).findFirst()
realm.insertOrUpdate(bankroll) realm.insertOrUpdate(bankroll)
} }
private fun createDefaultGames(realm: Realm) { private fun createDefaultGames(realm: Realm) {
val gamesName = context.resources.getStringArray(R.array.seed_games) val gamesName = context.resources.getStringArray(net.pokeranalytics.android.R.array.seed_games)
val gamesShortName = context.resources.getStringArray(R.array.seed_games_short_name) val gamesShortName = context.resources.getStringArray(net.pokeranalytics.android.R.array.seed_games_short_name)
for ((index, name) in gamesName.withIndex()) { for ((index, name) in gamesName.withIndex()) {
val game = Game() val game = Game()
game.id = UUID.randomUUID().toString() game.id = UUID.randomUUID().toString()

@ -27,12 +27,13 @@ import net.pokeranalytics.android.ui.view.rowrepresentable.FilterElementRow
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterSectionRow import net.pokeranalytics.android.ui.view.rowrepresentable.FilterSectionRow
import net.pokeranalytics.android.util.NULL_TEXT import net.pokeranalytics.android.util.NULL_TEXT
import net.pokeranalytics.android.util.extensions.shortDate import net.pokeranalytics.android.util.extensions.shortDate
import net.pokeranalytics.android.util.extensions.shortTime
import net.pokeranalytics.android.util.extensions.toMinutes import net.pokeranalytics.android.util.extensions.toMinutes
import timber.log.Timber import timber.log.Timber
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentableDataSource, RowRepresentableDelegate { open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentableDataSource, RowRepresentableDelegate {
lateinit var parentActivity: PokerAnalyticsActivity lateinit var parentActivity: PokerAnalyticsActivity
lateinit var rowRepresentableAdapter: RowRepresentableAdapter lateinit var rowRepresentableAdapter: RowRepresentableAdapter
@ -69,7 +70,7 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresenta
Timber.d("Row: $row") Timber.d("Row: $row")
when (row) { when (row) {
is FilterElementRow.DateFilterElementRow -> DateTimePickerManager.create(requireContext(), row, this, row.dateValue, onlyDate = true) is FilterElementRow.DateFilterElementRow -> DateTimePickerManager.create(requireContext(), row, this, row.dateValue, onlyDate = !row.showTime, onlyTime = row.showTime)
is FilterElementRow.PastDays -> { is FilterElementRow.PastDays -> {
val pastDays = if (row.lastDays > 0) row.lastDays.toString() else "" val pastDays = if (row.lastDays > 0) row.lastDays.toString() else ""
val data = row.editingDescriptors(mapOf("pastDays" to pastDays)) val data = row.editingDescriptors(mapOf("pastDays" to pastDays))
@ -107,7 +108,7 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresenta
is FilterElementRow.PastDays -> if (row.lastDays > 0) row.lastDays.toString() else NULL_TEXT 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.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.LastSessions -> if (row.lastSessions > 0) row.lastSessions.toString() else NULL_TEXT
is FilterElementRow.DateFilterElementRow -> row.dateValue.shortDate() is FilterElementRow.DateFilterElementRow -> if (row.showTime) row.dateValue.shortTime() else row.dateValue.shortDate()
is FilterElementRow.AmountFilterElement -> if (row.amount > 0) row.amount.toString() else NULL_TEXT is FilterElementRow.AmountFilterElement -> if (row.amount > 0) row.amount.toString() else NULL_TEXT
is FilterElementRow.DurationFilterElement -> row.minutes.toMinutes(requireContext()) is FilterElementRow.DurationFilterElement -> row.minutes.toMinutes(requireContext())
else -> super.stringForRow(row) else -> super.stringForRow(row)
@ -243,7 +244,7 @@ open class FilterDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresenta
private fun saveData() { private fun saveData() {
//TODO: Save currentFilter details data //TODO: Save currentFilter details data
Timber.d("Save data for filter: ${currentFilter?.id}") Timber.d("Save data for filter: ${currentFilter?.id}")
selectedRows?.forEach { selectedRows.forEach {
Timber.d("Selected rows: $it") Timber.d("Selected rows: $it")
} }

@ -23,6 +23,7 @@ class DateTimePickerManager : DatePickerDialog.OnDateSetListener,
private lateinit var calendar: Calendar private lateinit var calendar: Calendar
private var minimumDate: Date? = null private var minimumDate: Date? = null
private var onlyDate: Boolean = false private var onlyDate: Boolean = false
private var onlyTime: Boolean = false
private var isClearable: Boolean = true private var isClearable: Boolean = true
companion object { companion object {
@ -33,6 +34,7 @@ class DateTimePickerManager : DatePickerDialog.OnDateSetListener,
date: Date?, date: Date?,
minimumDate: Date? = null, minimumDate: Date? = null,
onlyDate: Boolean? = false, onlyDate: Boolean? = false,
onlyTime: Boolean? = false,
isClearable: Boolean? = true isClearable: Boolean? = true
): DateTimePickerManager { ): DateTimePickerManager {
@ -46,9 +48,14 @@ class DateTimePickerManager : DatePickerDialog.OnDateSetListener,
dateTimePickerManager.calendar = calendar dateTimePickerManager.calendar = calendar
dateTimePickerManager.minimumDate = minimumDate dateTimePickerManager.minimumDate = minimumDate
dateTimePickerManager.onlyDate = onlyDate ?: false dateTimePickerManager.onlyDate = onlyDate ?: false
dateTimePickerManager.onlyTime = onlyTime ?: false
dateTimePickerManager.isClearable = isClearable ?: true dateTimePickerManager.isClearable = isClearable ?: true
dateTimePickerManager.showDatePicker() if (dateTimePickerManager.onlyTime) {
dateTimePickerManager.showTimePicker()
} else {
dateTimePickerManager.showDatePicker()
}
return dateTimePickerManager return dateTimePickerManager
} }

@ -11,6 +11,7 @@ import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheet
import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor
import net.pokeranalytics.android.ui.view.RowViewType import net.pokeranalytics.android.ui.view.RowViewType
import net.pokeranalytics.android.util.CurrencyUtils
import net.pokeranalytics.android.util.NULL_TEXT import net.pokeranalytics.android.util.NULL_TEXT
import net.pokeranalytics.android.util.extensions.formatted import net.pokeranalytics.android.util.extensions.formatted
import net.pokeranalytics.android.util.extensions.round import net.pokeranalytics.android.util.extensions.round
@ -28,7 +29,7 @@ sealed class FilterElementRow : RowRepresentable {
interface LessOperator : Operator interface LessOperator : Operator
open class BoolFilterElementRow : FilterElementRow() open class BoolFilterElementRow : FilterElementRow()
open class DateFilterElementRow(var dateValue: Date = Date()) : FilterElementRow() open class DateFilterElementRow(var dateValue: Date = Date(), var showTime: Boolean = false) : FilterElementRow()
open class NumericFilterElementRow(open val doubleValue: Double = 0.0) : FilterElementRow() open class NumericFilterElementRow(open val doubleValue: Double = 0.0) : FilterElementRow()
open class StringFilterElementRow(val stringValue: String = "") : FilterElementRow() open class StringFilterElementRow(val stringValue: String = "") : FilterElementRow()
@ -86,6 +87,10 @@ sealed class FilterElementRow : RowRepresentable {
object From : DateFilterElementRow() object From : DateFilterElementRow()
object To : DateFilterElementRow() object To : DateFilterElementRow()
object FromTime : DateFilterElementRow(showTime = true)
object ToTime : DateFilterElementRow(showTime = true)
// Data classes - holding value // Data classes - holding value
object ResultMoreThan : AmountFilterElement(), MoreOperator object ResultMoreThan : AmountFilterElement(), MoreOperator
@ -103,7 +108,7 @@ sealed class FilterElementRow : RowRepresentable {
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() {
val name: String val name: String
get() { get() {
val currencyCode = code ?: Currency.getInstance(Locale.getDefault()).currencyCode val currencyCode = code ?: CurrencyUtils.getLocaleCurrency().currencyCode
val currencySymbol = Currency.getInstance(currencyCode).symbol val currencySymbol = Currency.getInstance(currencyCode).symbol
return if (sb == null) NULL_TEXT else "$currencySymbol ${sb?.formatted()}/${bb?.round()}" return if (sb == null) NULL_TEXT else "$currencySymbol ${sb?.formatted()}/${bb?.round()}"
} }
@ -153,6 +158,8 @@ sealed class FilterElementRow : RowRepresentable {
is Blind -> QueryCondition.BLINDS is Blind -> QueryCondition.BLINDS
is From -> QueryCondition.STARTED_FROM_DATE is From -> QueryCondition.STARTED_FROM_DATE
is To -> QueryCondition.ENDED_TO_DATE is To -> QueryCondition.ENDED_TO_DATE
is FromTime -> QueryCondition.STARTED_FROM_TIME
is ToTime -> QueryCondition.ENDED_TO_TIME
is Month -> QueryCondition.MONTH is Month -> QueryCondition.MONTH
is Day -> QueryCondition.DAY_OF_WEEK is Day -> QueryCondition.DAY_OF_WEEK
is Year -> QueryCondition.YEAR is Year -> QueryCondition.YEAR
@ -180,7 +187,6 @@ sealed class FilterElementRow : RowRepresentable {
is DurationMoreThan -> QueryCondition.MORE_THAN_DURATION is DurationMoreThan -> QueryCondition.MORE_THAN_DURATION
is DurationLessThan -> QueryCondition.LESS_THAN_DURATION is DurationLessThan -> QueryCondition.LESS_THAN_DURATION
//TODO: Check the conditions //TODO: Check the conditions
is LastGames -> QueryCondition.LAST_GAMES is LastGames -> QueryCondition.LAST_GAMES
is LastSessions -> QueryCondition.LAST_SESSIONS is LastSessions -> QueryCondition.LAST_SESSIONS
@ -215,8 +221,8 @@ sealed class FilterElementRow : RowRepresentable {
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 From -> R.string.from is From, FromTime -> R.string.from
is To -> R.string.to is To, ToTime -> R.string.to
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
@ -235,7 +241,7 @@ sealed class FilterElementRow : RowRepresentable {
override val viewType: Int override val viewType: Int
get() { get() {
return when (this) { return when (this) {
is PastDays, is From, is To, is LastGames, is LastSessions, is ReBuyMoreThan, is ReBuyLessThan, is PastDays, is From, is To, is FromTime, is ToTime, is LastGames, is LastSessions, is ReBuyMoreThan, is ReBuyLessThan,
is DurationMoreThan, is DurationLessThan -> RowViewType.TITLE_VALUE_CHECK.ordinal is DurationMoreThan, is DurationLessThan -> RowViewType.TITLE_VALUE_CHECK.ordinal
else -> RowViewType.TITLE_CHECK.ordinal else -> RowViewType.TITLE_CHECK.ordinal
} }
@ -330,22 +336,4 @@ sealed class FilterElementRow : RowRepresentable {
return null return null
} }
/*
override fun editingDescriptors(map: Map<String, Any?>): ArrayList<RowRepresentableEditDescriptor>? {
when (this) {
PAST_DAYS -> {
val defaultValue: String? by map
val data = arrayListOf<RowRepresentableEditDescriptor>()
data.add(
RowRepresentableEditDescriptor(
defaultValue,
inputType = InputType.TYPE_CLASS_NUMBER
)
)
}
}
return super.editingDescriptors(map)
}
*/
} }

@ -9,6 +9,8 @@ import net.pokeranalytics.android.model.realm.Session
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 net.pokeranalytics.android.ui.view.rowrepresentable.FilterElementRow.* import net.pokeranalytics.android.ui.view.rowrepresentable.FilterElementRow.*
import net.pokeranalytics.android.util.extensions.endOfDay
import net.pokeranalytics.android.util.extensions.startOfDay
import java.text.DateFormatSymbols import java.text.DateFormatSymbols
import java.util.* import java.util.*
@ -86,7 +88,8 @@ enum class FilterSectionRow(override val resId: Int?) : RowRepresentable {
TABLE_SIZE -> { TABLE_SIZE -> {
val tableSizes = arrayListOf<FilterElementRow.TableSize>() val tableSizes = arrayListOf<FilterElementRow.TableSize>()
val realm = Realm.getDefaultInstance() val realm = Realm.getDefaultInstance()
val distinctTableSizes = realm.where<Session>().distinct("tableSize").findAll().sort("tableSize", Sort.ASCENDING) val distinctTableSizes =
realm.where<Session>().distinct("tableSize").findAll().sort("tableSize", Sort.ASCENDING)
distinctTableSizes.forEach { session -> distinctTableSizes.forEach { session ->
session.tableSize?.let { tableSize -> session.tableSize?.let { tableSize ->
tableSizes.add(TableSize(net.pokeranalytics.android.model.TableSize(tableSize))) tableSizes.add(TableSize(net.pokeranalytics.android.model.TableSize(tableSize)))
@ -110,7 +113,8 @@ enum class FilterSectionRow(override val resId: Int?) : RowRepresentable {
YEAR -> { YEAR -> {
val years = arrayListOf<FilterElementRow.Year>() val years = arrayListOf<FilterElementRow.Year>()
val realm = Realm.getDefaultInstance() val realm = Realm.getDefaultInstance()
val distinctYears = realm.where<Session>().distinct("year").findAll().sort("year", Sort.DESCENDING) val distinctYears =
realm.where<Session>().distinct("year").findAll().sort("year", Sort.DESCENDING)
distinctYears.forEach { session -> distinctYears.forEach { session ->
session.year?.let { year -> session.year?.let { year ->
years.add(Year(year)) years.add(Year(year))
@ -140,8 +144,17 @@ enum class FilterSectionRow(override val resId: Int?) : RowRepresentable {
} }
// Duration // Duration
SESSION_DURATION -> arrayListOf(DurationMoreThan as FilterElementRow, DurationLessThan as FilterElementRow) SESSION_DURATION -> arrayListOf(
RANGE -> arrayListOf(From, To) DurationMoreThan as FilterElementRow,
DurationLessThan as FilterElementRow
)
RANGE -> {
val fromTime = FromTime
fromTime.dateValue = Date().startOfDay()
val toTime = ToTime
toTime.dateValue = Date().endOfDay()
arrayListOf(fromTime, toTime)
}
// Sessions // Sessions
SESSIONS -> arrayListOf(LastGames(0), LastSessions(0)) SESSIONS -> arrayListOf(LastGames(0), LastSessions(0))
@ -152,7 +165,9 @@ enum class FilterSectionRow(override val resId: Int?) : RowRepresentable {
// TODO: Improve the way we get the blinds distinctly // TODO: Improve the way we get the blinds distinctly
val blinds = arrayListOf<FilterElementRow.Blind>() val blinds = arrayListOf<FilterElementRow.Blind>()
val realm = Realm.getDefaultInstance() val realm = Realm.getDefaultInstance()
val sessions = realm.where<Session>().findAll().sort("cgSmallBlind", Sort.ASCENDING) val sessions =
realm.where<Session>().isNotNull("cgSmallBlind").isNotNull("cgBigBlind").findAll()
.sort("cgSmallBlind", Sort.ASCENDING)
val distinctBlinds: ArrayList<Session> = ArrayList() val distinctBlinds: ArrayList<Session> = ArrayList()
val blindsHashMap: ArrayList<String> = ArrayList() val blindsHashMap: ArrayList<String> = ArrayList()
@ -164,14 +179,23 @@ enum class FilterSectionRow(override val resId: Int?) : RowRepresentable {
} }
distinctBlinds.forEach { session -> distinctBlinds.forEach { session ->
blinds.add(Blind(session.cgSmallBlind, session.cgBigBlind, session.bankroll?.currency?.code)) blinds.add(
Blind(
session.cgSmallBlind,
session.cgBigBlind,
session.bankroll?.currency?.code
)
)
session.getBlinds() session.getBlinds()
} }
realm.close() realm.close()
blinds blinds
} }
CASH_RE_BUY_COUNT -> arrayListOf(ReBuyMoreThan as FilterElementRow, ReBuyLessThan as FilterElementRow) CASH_RE_BUY_COUNT -> arrayListOf(
ReBuyMoreThan as FilterElementRow,
ReBuyLessThan as FilterElementRow
)
// Tournament // Tournament
TOURNAMENT_TYPE -> arrayListOf() TOURNAMENT_TYPE -> arrayListOf()

@ -13,7 +13,7 @@ class CurrencyUtils {
* return the currency associated with this bankroll * return the currency associated with this bankroll
*/ */
fun getCurrency(bankroll: Bankroll? = null) : Currency { fun getCurrency(bankroll: Bankroll? = null) : Currency {
val currencyCode = bankroll?.currency?.code ?: Currency.getInstance(Locale.getDefault()).currencyCode val currencyCode = bankroll?.currency?.code ?: CurrencyUtils.getLocaleCurrency().currencyCode
return Currency.getInstance(currencyCode) return Currency.getInstance(currencyCode)
} }
@ -40,6 +40,25 @@ class CurrencyUtils {
return currencyFormatter return currencyFormatter
} }
/**
* Return the locale currency, or en_US if there
*/
fun getLocaleCurrency() : Currency {
return try {
Currency.getInstance(Locale.getDefault())
} catch (ex: Exception) {
when (Locale.getDefault().language) {
"en" -> Currency.getInstance(Locale("en", "US"))
"fr" -> Currency.getInstance(Locale("fr", "FR"))
"es" -> Currency.getInstance(Locale("es", "ES"))
"de" -> Currency.getInstance(Locale("de", "DE"))
"ja" -> Currency.getInstance(Locale("ja", "JP"))
"zh" -> Currency.getInstance(Locale("zh", "CN"))
else -> Currency.getInstance(Locale("en", "US"))
}
}
}
} }
} }
Loading…
Cancel
Save