|
|
|
@ -37,6 +37,7 @@ import net.pokeranalytics.android.ui.view.rowrepresentable.SeparatorRowRepresent |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SessionRow |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SessionRow |
|
|
|
import net.pokeranalytics.android.util.CurrencyUtils |
|
|
|
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.Preferences |
|
|
|
import net.pokeranalytics.android.util.extensions.* |
|
|
|
import net.pokeranalytics.android.util.extensions.* |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
import java.util.Currency |
|
|
|
import java.util.Currency |
|
|
|
@ -219,7 +220,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
var cgSmallBlind: Double? = null |
|
|
|
var cgSmallBlind: Double? = null |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
field = value |
|
|
|
field = value |
|
|
|
this.stake = getBlinds() |
|
|
|
computeStakeAsString() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// The big blind value |
|
|
|
// The big blind value |
|
|
|
@ -227,16 +228,11 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
field = value |
|
|
|
field = value |
|
|
|
this.computeStats() |
|
|
|
this.computeStats() |
|
|
|
this.stake = getBlinds() |
|
|
|
computeStakeAsString() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private var stake: String? = null |
|
|
|
var stake: String? = null |
|
|
|
get() { |
|
|
|
private set |
|
|
|
if (field == null) { |
|
|
|
|
|
|
|
field = getBlinds() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return field |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tournament |
|
|
|
// Tournament |
|
|
|
|
|
|
|
|
|
|
|
@ -256,7 +252,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
var tournamentFeatures: RealmList<TournamentFeature> = RealmList() |
|
|
|
var tournamentFeatures: RealmList<TournamentFeature> = RealmList() |
|
|
|
|
|
|
|
|
|
|
|
fun bankrollHasBeenUpdated() { |
|
|
|
fun bankrollHasBeenUpdated() { |
|
|
|
this.stake = getBlinds() |
|
|
|
computeStakeAsString() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -499,10 +495,15 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the formatted blinds |
|
|
|
* Return the formatted blinds |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun getBlinds(): String { |
|
|
|
fun getCurrencyFormattedStake(context:Context) : String { |
|
|
|
val currencyCode = bankroll?.currency?.code ?: Currency.getInstance(Locale.getDefault()).currencyCode |
|
|
|
val currency : Currency = Preferences.getCurrencyLocale(context)?.let { |
|
|
|
val currencySymbol = Currency.getInstance(currencyCode).symbol |
|
|
|
Currency.getInstance(it) |
|
|
|
return if (cgSmallBlind == null) NULL_TEXT else "$currencySymbol ${cgSmallBlind?.formatted()}/${cgBigBlind?.round()}" |
|
|
|
} ?: run { |
|
|
|
|
|
|
|
net.pokeranalytics.android.model.realm.Currency.localeCurrency |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val currencySymbol = currencySymbol ?: currency.symbol |
|
|
|
|
|
|
|
return "$currencySymbol $stake" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -522,6 +523,23 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
return if (gameTitle.isNotBlank()) gameTitle else NULL_TEXT |
|
|
|
return if (gameTitle.isNotBlank()) gameTitle else NULL_TEXT |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val currencySymbol : String? |
|
|
|
|
|
|
|
get() { |
|
|
|
|
|
|
|
bankroll?.currency?.code?.let { |
|
|
|
|
|
|
|
return Currency.getInstance(it).symbol |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun computeStakeAsString() { |
|
|
|
|
|
|
|
stake = null |
|
|
|
|
|
|
|
if (cgBigBlind == null) return |
|
|
|
|
|
|
|
cgBigBlind?.let { bb -> |
|
|
|
|
|
|
|
val sb = cgSmallBlind ?: bb / 2.0 |
|
|
|
|
|
|
|
stake = "${sb.formatted()}/${bb.round()}" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// LifeCycle |
|
|
|
// LifeCycle |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -638,7 +656,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
override fun stringForRow(row: RowRepresentable, context: Context): String { |
|
|
|
override fun stringForRow(row: RowRepresentable, context: Context): String { |
|
|
|
return when (row) { |
|
|
|
return when (row) { |
|
|
|
SessionRow.BANKROLL -> bankroll?.name ?: NULL_TEXT |
|
|
|
SessionRow.BANKROLL -> bankroll?.name ?: NULL_TEXT |
|
|
|
SessionRow.BLINDS -> getBlinds() |
|
|
|
SessionRow.BLINDS -> getCurrencyFormattedStake(context) |
|
|
|
SessionRow.BREAK_TIME -> if (this.breakDuration > 0.0) this.breakDuration.toMinutes() else NULL_TEXT |
|
|
|
SessionRow.BREAK_TIME -> if (this.breakDuration > 0.0) this.breakDuration.toMinutes() else NULL_TEXT |
|
|
|
SessionRow.BUY_IN -> this.result?.buyin?.toCurrency(CurrencyUtils.getCurrency(bankroll)) ?: NULL_TEXT |
|
|
|
SessionRow.BUY_IN -> this.result?.buyin?.toCurrency(CurrencyUtils.getCurrency(bankroll)) ?: NULL_TEXT |
|
|
|
SessionRow.CASHED_OUT, SessionRow.PRIZE, SessionRow.NET_RESULT -> this.result?.cashout?.toCurrency(CurrencyUtils.getCurrency(bankroll)) ?: NULL_TEXT |
|
|
|
SessionRow.CASHED_OUT, SessionRow.PRIZE, SessionRow.NET_RESULT -> this.result?.cashout?.toCurrency(CurrencyUtils.getCurrency(bankroll)) ?: NULL_TEXT |
|
|
|
|