|
|
|
@ -13,7 +13,6 @@ import io.realm.annotations.LinkingObjects |
|
|
|
import io.realm.annotations.PrimaryKey |
|
|
|
import io.realm.annotations.PrimaryKey |
|
|
|
import io.realm.kotlin.where |
|
|
|
import io.realm.kotlin.where |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.calculus.ComputedStat |
|
|
|
|
|
|
|
import net.pokeranalytics.android.calculus.Stat |
|
|
|
import net.pokeranalytics.android.calculus.Stat |
|
|
|
import net.pokeranalytics.android.calculus.StatFormattingException |
|
|
|
import net.pokeranalytics.android.calculus.StatFormattingException |
|
|
|
import net.pokeranalytics.android.exceptions.ModelException |
|
|
|
import net.pokeranalytics.android.exceptions.ModelException |
|
|
|
@ -30,12 +29,9 @@ import net.pokeranalytics.android.model.filter.QueryCondition.* |
|
|
|
import net.pokeranalytics.android.model.interfaces.* |
|
|
|
import net.pokeranalytics.android.model.interfaces.* |
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.HandHistory |
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.HandHistory |
|
|
|
import net.pokeranalytics.android.model.utils.SessionSetManager |
|
|
|
import net.pokeranalytics.android.model.utils.SessionSetManager |
|
|
|
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.adapter.UnmanagedRowRepresentableException |
|
|
|
import net.pokeranalytics.android.ui.adapter.UnmanagedRowRepresentableException |
|
|
|
import net.pokeranalytics.android.ui.fragment.GraphFragment |
|
|
|
import net.pokeranalytics.android.ui.fragment.GraphFragment |
|
|
|
import net.pokeranalytics.android.ui.view.* |
|
|
|
import net.pokeranalytics.android.ui.view.* |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SeparatorRow |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SessionRow |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SessionRow |
|
|
|
import net.pokeranalytics.android.util.NULL_TEXT |
|
|
|
import net.pokeranalytics.android.util.NULL_TEXT |
|
|
|
import net.pokeranalytics.android.util.TextFormat |
|
|
|
import net.pokeranalytics.android.util.TextFormat |
|
|
|
@ -44,11 +40,10 @@ import net.pokeranalytics.android.util.extensions.* |
|
|
|
import java.text.DateFormat |
|
|
|
import java.text.DateFormat |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
import java.util.Currency |
|
|
|
import java.util.Currency |
|
|
|
import kotlin.collections.ArrayList |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typealias BB = Double |
|
|
|
typealias BB = Double |
|
|
|
|
|
|
|
|
|
|
|
open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDataSource, RowRepresentable, Timed, |
|
|
|
open class Session : RealmObject(), Savable, Editable, RowRepresentable, Timed, |
|
|
|
TimeFilterable, Filterable, DatedBankrollGraphEntry { |
|
|
|
TimeFilterable, Filterable, DatedBankrollGraphEntry { |
|
|
|
|
|
|
|
|
|
|
|
enum class Type(val value: String) { |
|
|
|
enum class Type(val value: String) { |
|
|
|
@ -252,7 +247,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
override var pauseDate: Date? = null |
|
|
|
override var pauseDate: Date? = null |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
field = value |
|
|
|
field = value |
|
|
|
this.updateRowRepresentation() |
|
|
|
// this.updateRowRepresentation() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// The session set containing the sessions, which can contain multiple endedSessions |
|
|
|
// The session set containing the sessions, which can contain multiple endedSessions |
|
|
|
@ -266,7 +261,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
field = value |
|
|
|
field = value |
|
|
|
this.formatBlinds() |
|
|
|
this.formatBlinds() |
|
|
|
this.updateRowRepresentation() |
|
|
|
// this.updateRowRepresentation() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// The limit type: NL, PL... |
|
|
|
// The limit type: NL, PL... |
|
|
|
@ -353,7 +348,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
} else if (this.sessionSet != null) { |
|
|
|
} else if (this.sessionSet != null) { |
|
|
|
SessionSetManager.removeFromTimeline(this) |
|
|
|
SessionSetManager.removeFromTimeline(this) |
|
|
|
} |
|
|
|
} |
|
|
|
this.updateRowRepresentation() |
|
|
|
// this.updateRowRepresentation() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -465,7 +460,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
return playerHandsPerHour / tableSize.toDouble() |
|
|
|
return playerHandsPerHour / tableSize.toDouble() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private val hourlyRate: Double |
|
|
|
val hourlyRate: Double |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
this.result?.let { result -> |
|
|
|
this.result?.let { result -> |
|
|
|
return result.net / this.hourlyDuration |
|
|
|
return result.net / this.hourlyDuration |
|
|
|
@ -706,273 +701,10 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
@Ignore |
|
|
|
@Ignore |
|
|
|
override val viewType: Int = RowViewType.ROW_SESSION.ordinal |
|
|
|
override val viewType: Int = RowViewType.ROW_SESSION.ordinal |
|
|
|
|
|
|
|
|
|
|
|
// Override to surcharge custom field viewType |
|
|
|
|
|
|
|
override fun viewTypeForPosition(position: Int): Int { |
|
|
|
|
|
|
|
rowRepresentationForCurrentState[position].let { |
|
|
|
|
|
|
|
if (it is CustomField) { |
|
|
|
|
|
|
|
return RowViewType.TITLE_VALUE.ordinal |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return super.viewTypeForPosition(position) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun getDisplayName(context: Context): String { |
|
|
|
override fun getDisplayName(context: Context): String { |
|
|
|
return "Session ${this.creationDate}" |
|
|
|
return "Session ${this.creationDate}" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
|
|
|
|
private var rowRepresentationForCurrentState: List<RowRepresentable> = mutableListOf() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun updatedRowRepresentationForCurrentState(): List<RowRepresentable> { |
|
|
|
|
|
|
|
val rows = ArrayList<RowRepresentable>() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Headers |
|
|
|
|
|
|
|
when (getState()) { |
|
|
|
|
|
|
|
SessionState.STARTED -> { |
|
|
|
|
|
|
|
rows.add( |
|
|
|
|
|
|
|
CustomizableRowRepresentable( |
|
|
|
|
|
|
|
RowViewType.HEADER_TITLE_AMOUNT_BIG, |
|
|
|
|
|
|
|
title = getFormattedDuration(), |
|
|
|
|
|
|
|
valueTextFormat = ComputedStat(Stat.NET_RESULT, result?.net ?: 0.0, currency = currency).textFormat |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
rows.add(SeparatorRow()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionState.PAUSED -> { |
|
|
|
|
|
|
|
rows.add( |
|
|
|
|
|
|
|
CustomizableRowRepresentable( |
|
|
|
|
|
|
|
RowViewType.HEADER_TITLE_AMOUNT_BIG, |
|
|
|
|
|
|
|
resId = R.string.pause, |
|
|
|
|
|
|
|
valueTextFormat = ComputedStat(Stat.NET_RESULT, result?.net ?: 0.0, currency = currency).textFormat |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
rows.add(SeparatorRow()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionState.FINISHED -> { |
|
|
|
|
|
|
|
rows.add( |
|
|
|
|
|
|
|
CustomizableRowRepresentable( |
|
|
|
|
|
|
|
RowViewType.HEADER_TITLE_AMOUNT_BIG, |
|
|
|
|
|
|
|
title = getFormattedDuration(), |
|
|
|
|
|
|
|
valueTextFormat = ComputedStat(Stat.NET_RESULT, result?.net ?: 0.0, currency = currency).textFormat |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
rows.add( |
|
|
|
|
|
|
|
CustomizableRowRepresentable( |
|
|
|
|
|
|
|
RowViewType.HEADER_TITLE_AMOUNT, |
|
|
|
|
|
|
|
resId = R.string.hour_rate_without_pauses, |
|
|
|
|
|
|
|
valueTextFormat = ComputedStat(Stat.HOURLY_RATE, this.hourlyRate, currency = currency).textFormat |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (!isTournament()) { |
|
|
|
|
|
|
|
// rows.add( |
|
|
|
|
|
|
|
// CustomizableRowRepresentable( |
|
|
|
|
|
|
|
// RowViewType.HEADER_TITLE_VALUE, |
|
|
|
|
|
|
|
// resId = R.string.bankroll_variation, |
|
|
|
|
|
|
|
// computedStat = ComputedStat(Stat.HOURLY_RATE, 0.0, CurrencyUtils.getCurrency(bankroll)) |
|
|
|
|
|
|
|
// ) |
|
|
|
|
|
|
|
// ) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
rows.add(SeparatorRow()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else -> { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Rows |
|
|
|
|
|
|
|
rows.addAll(SessionRow.getRows(this)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add custom fields |
|
|
|
|
|
|
|
realm?.let { |
|
|
|
|
|
|
|
rows.add(SeparatorRow()) |
|
|
|
|
|
|
|
rows.addAll(it.sorted<CustomField>()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return rows |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun updateRowRepresentation() { |
|
|
|
|
|
|
|
this.rowRepresentationForCurrentState = this.updatedRowRepresentationForCurrentState() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun adapterRows(): List<RowRepresentable>? { |
|
|
|
|
|
|
|
return this.rowRepresentationForCurrentState |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun boolForRow(row: RowRepresentable): Boolean { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun charSequenceForRow(row: RowRepresentable, context: Context): String { |
|
|
|
|
|
|
|
return when (row) { |
|
|
|
|
|
|
|
SessionRow.BANKROLL -> bankroll?.name ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.BLINDS -> getFormattedBlinds() |
|
|
|
|
|
|
|
SessionRow.BREAK_TIME -> if (this.breakDuration > 0.0) this.breakDuration.toMinutes() else NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.BUY_IN -> this.result?.buyin?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.CASHED_OUT, SessionRow.PRIZE -> this.result?.cashout?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.NET_RESULT -> this.result?.netResult?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.COMMENT -> if (this.comment.isNotEmpty()) this.comment else NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.END_DATE -> this.endDate?.shortDateTime() ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.GAME -> getFormattedGame() |
|
|
|
|
|
|
|
SessionRow.INITIAL_BUY_IN -> tournamentEntryFee?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.LOCATION -> location?.name ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.PLAYERS -> tournamentNumberOfPlayers?.toString() ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.POSITION -> result?.tournamentFinalPosition?.toString() ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.START_DATE -> this.startDate?.shortDateTime() ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.TABLE_SIZE -> this.tableSize?.let { TableSize(it).localizedTitle(context) } ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.TIPS -> result?.tips?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.TOURNAMENT_TYPE -> { |
|
|
|
|
|
|
|
this.tournamentType?.let { |
|
|
|
|
|
|
|
TournamentType.values()[it].localizedTitle(context) |
|
|
|
|
|
|
|
} ?: run { |
|
|
|
|
|
|
|
NULL_TEXT |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.TOURNAMENT_FEATURE -> { |
|
|
|
|
|
|
|
if (tournamentFeatures.size > 2) { |
|
|
|
|
|
|
|
"${tournamentFeatures.subList(0, 2).joinToString { |
|
|
|
|
|
|
|
it.name |
|
|
|
|
|
|
|
}}, ..." |
|
|
|
|
|
|
|
} else if (tournamentFeatures.size > 0) { |
|
|
|
|
|
|
|
tournamentFeatures.joinToString { |
|
|
|
|
|
|
|
it.name |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
NULL_TEXT |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.TOURNAMENT_NAME -> tournamentName?.name ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.HANDS -> this.handHistories?.size.toString() |
|
|
|
|
|
|
|
is CustomField -> { |
|
|
|
|
|
|
|
customFieldEntries.find { it.customField?.id == row.id }?.let { customFieldEntry -> |
|
|
|
|
|
|
|
return customFieldEntry.getFormattedValue(currency) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return NULL_TEXT |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else -> throw UnmanagedRowRepresentableException("Unmanaged row = $row") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun actionIconForRow(row: RowRepresentable): Int? { |
|
|
|
|
|
|
|
return when (row) { |
|
|
|
|
|
|
|
SessionRow.START_DATE, SessionRow.END_DATE -> { |
|
|
|
|
|
|
|
R.drawable.ic_close |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else -> null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun editDescriptors(row: RowRepresentable): List<RowRepresentableEditDescriptor>? { |
|
|
|
|
|
|
|
return when (row) { |
|
|
|
|
|
|
|
SessionRow.BANKROLL -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"defaultValue" to this.bankroll, |
|
|
|
|
|
|
|
"data" to realm.sorted<Bankroll>() // LiveData.Bankroll.items(realm) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
SessionRow.GAME -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"limit" to this.limit, |
|
|
|
|
|
|
|
"defaultValue" to this.game, |
|
|
|
|
|
|
|
"data" to realm.sorted<Game>() //LiveData.Game.items(realm) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
SessionRow.LOCATION -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"defaultValue" to this.location, |
|
|
|
|
|
|
|
"data" to realm.sorted<Location>() // LiveData.Location.items(realm) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
SessionRow.TOURNAMENT_FEATURE -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"defaultValue" to this.tournamentFeatures, |
|
|
|
|
|
|
|
"data" to realm.sorted<TournamentFeature>() //LiveData.TournamentFeature.items(realm) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
SessionRow.TOURNAMENT_NAME -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"defaultValue" to this.tournamentName, |
|
|
|
|
|
|
|
"data" to realm.sorted<TournamentName>() //LiveData.TournamentName.items(realm) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
SessionRow.TOURNAMENT_TYPE -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"defaultValue" to this.tournamentType |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
SessionRow.TABLE_SIZE -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"defaultValue" to this.tableSize |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
SessionRow.BLINDS -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"sb" to cgSmallBlind?.round(), |
|
|
|
|
|
|
|
"bb" to cgBigBlind?.round() |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
SessionRow.BUY_IN -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"bb" to cgBigBlind, |
|
|
|
|
|
|
|
"fee" to this.tournamentEntryFee, |
|
|
|
|
|
|
|
"ratedBuyin" to result?.buyin |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
SessionRow.BREAK_TIME -> row.editingDescriptors(mapOf()) |
|
|
|
|
|
|
|
SessionRow.CASHED_OUT, SessionRow.PRIZE -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"defaultValue" to result?.cashout |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
SessionRow.NET_RESULT -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"defaultValue" to result?.netResult |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
SessionRow.COMMENT -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"defaultValue" to this.comment |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
SessionRow.INITIAL_BUY_IN -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"defaultValue" to this.tournamentEntryFee |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
SessionRow.PLAYERS -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"defaultValue" to this.tournamentNumberOfPlayers |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
SessionRow.POSITION -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"defaultValue" to this.result?.tournamentFinalPosition |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
SessionRow.TIPS -> row.editingDescriptors( |
|
|
|
|
|
|
|
mapOf( |
|
|
|
|
|
|
|
"sb" to cgSmallBlind?.round(), |
|
|
|
|
|
|
|
"bb" to cgBigBlind?.round(), |
|
|
|
|
|
|
|
"tips" to result?.tips |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
is CustomField -> { |
|
|
|
|
|
|
|
row.editingDescriptors( |
|
|
|
|
|
|
|
when (row.type) { |
|
|
|
|
|
|
|
CustomField.Type.LIST.uniqueIdentifier -> mapOf( |
|
|
|
|
|
|
|
"defaultValue" to customFieldEntries.find { it.customField?.id == row.id }?.value, |
|
|
|
|
|
|
|
"data" to row.entries |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
else -> mapOf( |
|
|
|
|
|
|
|
"defaultValue" to customFieldEntries.find { it.customField?.id == row.id }?.numericValue |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else -> null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun updateValue(value: Any?, row: RowRepresentable) { |
|
|
|
override fun updateValue(value: Any?, row: RowRepresentable) { |
|
|
|
|
|
|
|
|
|
|
|
when (row) { |
|
|
|
when (row) { |
|
|
|
@ -1005,7 +737,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
SessionRow.BUY_IN -> { |
|
|
|
SessionRow.BUY_IN -> { |
|
|
|
val localResult = getOrCreateResult() |
|
|
|
val localResult = getOrCreateResult() |
|
|
|
localResult.buyin = value as Double? |
|
|
|
localResult.buyin = value as Double? |
|
|
|
this.updateRowRepresentation() |
|
|
|
// this.updateRowRepresentation() |
|
|
|
} |
|
|
|
} |
|
|
|
SessionRow.CASHED_OUT, SessionRow.PRIZE -> { |
|
|
|
SessionRow.CASHED_OUT, SessionRow.PRIZE -> { |
|
|
|
val localResult = getOrCreateResult() |
|
|
|
val localResult = getOrCreateResult() |
|
|
|
@ -1210,4 +942,55 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
@Ignore |
|
|
|
@Ignore |
|
|
|
override val realmObjectClass: Class<out Identifiable> = Session::class.java |
|
|
|
override val realmObjectClass: Class<out Identifiable> = Session::class.java |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun charSequenceForRow(row: RowRepresentable, context: Context): String { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return when (row) { |
|
|
|
|
|
|
|
SessionRow.BANKROLL -> bankroll?.name ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.BLINDS -> getFormattedBlinds() |
|
|
|
|
|
|
|
SessionRow.BREAK_TIME -> if (this.breakDuration > 0.0) this.breakDuration.toMinutes() else NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.BUY_IN -> this.result?.buyin?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.CASHED_OUT, SessionRow.PRIZE -> this.result?.cashout?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.NET_RESULT -> this.result?.netResult?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.COMMENT -> if (this.comment.isNotEmpty()) this.comment else NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.END_DATE -> this.endDate?.shortDateTime() ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.GAME -> getFormattedGame() |
|
|
|
|
|
|
|
SessionRow.INITIAL_BUY_IN -> tournamentEntryFee?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.LOCATION -> location?.name ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.PLAYERS -> tournamentNumberOfPlayers?.toString() ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.POSITION -> result?.tournamentFinalPosition?.toString() ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.START_DATE -> this.startDate?.shortDateTime() ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.TABLE_SIZE -> this.tableSize?.let { TableSize(it).localizedTitle(context) } ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.TIPS -> result?.tips?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.TOURNAMENT_TYPE -> { |
|
|
|
|
|
|
|
this.tournamentType?.let { |
|
|
|
|
|
|
|
TournamentType.values()[it].localizedTitle(context) |
|
|
|
|
|
|
|
} ?: run { |
|
|
|
|
|
|
|
NULL_TEXT |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.TOURNAMENT_FEATURE -> { |
|
|
|
|
|
|
|
if (tournamentFeatures.size > 2) { |
|
|
|
|
|
|
|
"${tournamentFeatures.subList(0, 2).joinToString { |
|
|
|
|
|
|
|
it.name |
|
|
|
|
|
|
|
}}, ..." |
|
|
|
|
|
|
|
} else if (tournamentFeatures.size > 0) { |
|
|
|
|
|
|
|
tournamentFeatures.joinToString { |
|
|
|
|
|
|
|
it.name |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
NULL_TEXT |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.TOURNAMENT_NAME -> tournamentName?.name ?: NULL_TEXT |
|
|
|
|
|
|
|
SessionRow.HANDS -> this.handHistories?.size.toString() |
|
|
|
|
|
|
|
is CustomField -> { |
|
|
|
|
|
|
|
customFieldEntries.find { it.customField?.id == row.id }?.let { customFieldEntry -> |
|
|
|
|
|
|
|
return customFieldEntry.getFormattedValue(currency) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return NULL_TEXT |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else -> throw UnmanagedRowRepresentableException("Unmanaged row = $row") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|