|
|
|
@ -35,9 +35,8 @@ import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SeparatorRowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SeparatorRowRepresentable |
|
|
|
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.NULL_TEXT |
|
|
|
import net.pokeranalytics.android.util.NULL_TEXT |
|
|
|
import net.pokeranalytics.android.util.Preferences |
|
|
|
import net.pokeranalytics.android.util.UserDefaults |
|
|
|
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 |
|
|
|
@ -220,7 +219,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
var cgSmallBlind: Double? = null |
|
|
|
var cgSmallBlind: Double? = null |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
field = value |
|
|
|
field = value |
|
|
|
computeStakeAsString() |
|
|
|
formatBlinds() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// The big blind value |
|
|
|
// The big blind value |
|
|
|
@ -228,10 +227,10 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
field = value |
|
|
|
field = value |
|
|
|
this.computeStats() |
|
|
|
this.computeStats() |
|
|
|
computeStakeAsString() |
|
|
|
formatBlinds() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var stake: String? = null |
|
|
|
var blinds: String? = null |
|
|
|
private set |
|
|
|
private set |
|
|
|
|
|
|
|
|
|
|
|
// Tournament |
|
|
|
// Tournament |
|
|
|
@ -252,7 +251,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
var tournamentFeatures: RealmList<TournamentFeature> = RealmList() |
|
|
|
var tournamentFeatures: RealmList<TournamentFeature> = RealmList() |
|
|
|
|
|
|
|
|
|
|
|
fun bankrollHasBeenUpdated() { |
|
|
|
fun bankrollHasBeenUpdated() { |
|
|
|
computeStakeAsString() |
|
|
|
formatBlinds() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -492,12 +491,18 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
return NULL_TEXT |
|
|
|
return NULL_TEXT |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
val hasDefaultCurrency: Boolean |
|
|
|
* Return the formatted blinds |
|
|
|
get() { |
|
|
|
*/ |
|
|
|
return bankroll?.currency?.code == null |
|
|
|
fun getCurrencyFormattedStake(context:Context) : String { |
|
|
|
} |
|
|
|
val currencySymbol = currencySymbol ?: Preferences.getDefaultCurrency(context).symbol |
|
|
|
|
|
|
|
return "$currencySymbol $stake" |
|
|
|
val currency : Currency |
|
|
|
|
|
|
|
get() { |
|
|
|
|
|
|
|
return bankroll?.currency?.code?.let { |
|
|
|
|
|
|
|
Currency.getInstance(it) |
|
|
|
|
|
|
|
} ?: run { |
|
|
|
|
|
|
|
UserDefaults.currency |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -517,20 +522,16 @@ 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? |
|
|
|
fun getFormattedBlinds(): String { |
|
|
|
get() { |
|
|
|
return blinds ?: NULL_TEXT |
|
|
|
bankroll?.currency?.code?.let { |
|
|
|
|
|
|
|
return Currency.getInstance(it).symbol |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun computeStakeAsString() { |
|
|
|
private fun formatBlinds() { |
|
|
|
stake = null |
|
|
|
blinds = null |
|
|
|
if (cgBigBlind == null) return |
|
|
|
if (cgBigBlind == null) return |
|
|
|
cgBigBlind?.let { bb -> |
|
|
|
cgBigBlind?.let { bb -> |
|
|
|
val sb = cgSmallBlind ?: bb / 2.0 |
|
|
|
val sb = cgSmallBlind ?: bb / 2.0 |
|
|
|
stake = "${sb.formatted()}/${bb.round()}" |
|
|
|
blinds = "${currency.symbol} ${sb.formatted()}/${bb.round()}" |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -584,7 +585,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
CustomizableRowRepresentable( |
|
|
|
CustomizableRowRepresentable( |
|
|
|
RowViewType.HEADER_TITLE_AMOUNT_BIG, |
|
|
|
RowViewType.HEADER_TITLE_AMOUNT_BIG, |
|
|
|
title = getFormattedDuration(), |
|
|
|
title = getFormattedDuration(), |
|
|
|
computedStat = ComputedStat(Stat.NETRESULT, result?.net ?: 0.0, CurrencyUtils.getCurrency(bankroll)) |
|
|
|
computedStat = ComputedStat(Stat.NETRESULT, result?.net ?: 0.0, currency) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
rows.add(SeparatorRowRepresentable()) |
|
|
|
rows.add(SeparatorRowRepresentable()) |
|
|
|
@ -594,7 +595,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
CustomizableRowRepresentable( |
|
|
|
CustomizableRowRepresentable( |
|
|
|
RowViewType.HEADER_TITLE_AMOUNT_BIG, |
|
|
|
RowViewType.HEADER_TITLE_AMOUNT_BIG, |
|
|
|
resId = R.string.pause, |
|
|
|
resId = R.string.pause, |
|
|
|
computedStat = ComputedStat(Stat.NETRESULT, result?.net ?: 0.0, CurrencyUtils.getCurrency(bankroll)) |
|
|
|
computedStat = ComputedStat(Stat.NETRESULT, result?.net ?: 0.0, currency) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
rows.add(SeparatorRowRepresentable()) |
|
|
|
rows.add(SeparatorRowRepresentable()) |
|
|
|
@ -604,14 +605,14 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
CustomizableRowRepresentable( |
|
|
|
CustomizableRowRepresentable( |
|
|
|
RowViewType.HEADER_TITLE_AMOUNT_BIG, |
|
|
|
RowViewType.HEADER_TITLE_AMOUNT_BIG, |
|
|
|
title = getFormattedDuration(), |
|
|
|
title = getFormattedDuration(), |
|
|
|
computedStat = ComputedStat(Stat.NETRESULT, result?.net ?: 0.0, CurrencyUtils.getCurrency(bankroll)) |
|
|
|
computedStat = ComputedStat(Stat.NETRESULT, result?.net ?: 0.0, currency) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
rows.add( |
|
|
|
rows.add( |
|
|
|
CustomizableRowRepresentable( |
|
|
|
CustomizableRowRepresentable( |
|
|
|
RowViewType.HEADER_TITLE_AMOUNT, |
|
|
|
RowViewType.HEADER_TITLE_AMOUNT, |
|
|
|
resId = R.string.hour_rate_without_pauses, |
|
|
|
resId = R.string.hour_rate_without_pauses, |
|
|
|
computedStat = ComputedStat(Stat.HOURLY_RATE, this.hourlyRate, CurrencyUtils.getCurrency(bankroll)) |
|
|
|
computedStat = ComputedStat(Stat.HOURLY_RATE, this.hourlyRate, currency) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
@ -650,20 +651,20 @@ 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 -> getCurrencyFormattedStake(context) |
|
|
|
SessionRow.BLINDS -> getFormattedBlinds() |
|
|
|
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(currency) ?: 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(currency) ?: NULL_TEXT |
|
|
|
SessionRow.COMMENT -> if (this.comment.isNotEmpty()) this.comment else NULL_TEXT |
|
|
|
SessionRow.COMMENT -> if (this.comment.isNotEmpty()) this.comment else NULL_TEXT |
|
|
|
SessionRow.END_DATE -> this.endDate?.shortDateTime() ?: NULL_TEXT |
|
|
|
SessionRow.END_DATE -> this.endDate?.shortDateTime() ?: NULL_TEXT |
|
|
|
SessionRow.GAME -> getFormattedGame() |
|
|
|
SessionRow.GAME -> getFormattedGame() |
|
|
|
SessionRow.INITIAL_BUY_IN -> tournamentEntryFee?.toCurrency(CurrencyUtils.getCurrency(bankroll)) ?: NULL_TEXT |
|
|
|
SessionRow.INITIAL_BUY_IN -> tournamentEntryFee?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
SessionRow.LOCATION -> location?.name ?: NULL_TEXT |
|
|
|
SessionRow.LOCATION -> location?.name ?: NULL_TEXT |
|
|
|
SessionRow.PLAYERS -> tournamentNumberOfPlayers?.toString() ?: NULL_TEXT |
|
|
|
SessionRow.PLAYERS -> tournamentNumberOfPlayers?.toString() ?: NULL_TEXT |
|
|
|
SessionRow.POSITION -> result?.tournamentFinalPosition?.toString() ?: NULL_TEXT |
|
|
|
SessionRow.POSITION -> result?.tournamentFinalPosition?.toString() ?: NULL_TEXT |
|
|
|
SessionRow.START_DATE -> this.startDate?.shortDateTime() ?: NULL_TEXT |
|
|
|
SessionRow.START_DATE -> this.startDate?.shortDateTime() ?: NULL_TEXT |
|
|
|
SessionRow.TABLE_SIZE -> this.tableSize?.let { TableSize(it).localizedTitle(context) } ?: NULL_TEXT |
|
|
|
SessionRow.TABLE_SIZE -> this.tableSize?.let { TableSize(it).localizedTitle(context) } ?: NULL_TEXT |
|
|
|
SessionRow.TIPS -> result?.tips?.toCurrency(CurrencyUtils.getCurrency(bankroll)) ?: NULL_TEXT |
|
|
|
SessionRow.TIPS -> result?.tips?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
SessionRow.TOURNAMENT_TYPE -> this.tournamentType?.let { |
|
|
|
SessionRow.TOURNAMENT_TYPE -> this.tournamentType?.let { |
|
|
|
TournamentType.values()[it].localizedTitle(context) |
|
|
|
TournamentType.values()[it].localizedTitle(context) |
|
|
|
} ?: run { |
|
|
|
} ?: run { |
|
|
|
@ -886,7 +887,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
value?.let { |
|
|
|
value?.let { |
|
|
|
return stat.format(it, CurrencyUtils.getCurrency(this.bankroll), context) |
|
|
|
return stat.format(it, currency, context) |
|
|
|
} ?: run { |
|
|
|
} ?: run { |
|
|
|
return TextFormat(NULL_TEXT) |
|
|
|
return TextFormat(NULL_TEXT) |
|
|
|
} |
|
|
|
} |
|
|
|
|