|
|
|
@ -29,10 +29,9 @@ import net.pokeranalytics.android.model.realm.handhistory.HandHistory |
|
|
|
import net.pokeranalytics.android.model.utils.CrashLogging |
|
|
|
import net.pokeranalytics.android.model.utils.CrashLogging |
|
|
|
import net.pokeranalytics.android.model.utils.SessionSetManager |
|
|
|
import net.pokeranalytics.android.model.utils.SessionSetManager |
|
|
|
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.graph.Graph |
|
|
|
import net.pokeranalytics.android.ui.graph.Graph |
|
|
|
import net.pokeranalytics.android.ui.view.* |
|
|
|
import net.pokeranalytics.android.ui.view.* |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SessionRow |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SessionPropertiesRow |
|
|
|
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 |
|
|
|
import net.pokeranalytics.android.util.UserDefaults |
|
|
|
import net.pokeranalytics.android.util.UserDefaults |
|
|
|
@ -708,8 +707,8 @@ open class Session : RealmObject(), Savable, Editable, RowRepresentable, Timed, |
|
|
|
override fun updateValue(value: Any?, row: RowRepresentable) { |
|
|
|
override fun updateValue(value: Any?, row: RowRepresentable) { |
|
|
|
|
|
|
|
|
|
|
|
when (row) { |
|
|
|
when (row) { |
|
|
|
SessionRow.BANKROLL -> bankroll = value as Bankroll? |
|
|
|
SessionPropertiesRow.BANKROLL -> bankroll = value as Bankroll? |
|
|
|
SessionRow.BLINDS -> if (value is ArrayList<*>) { |
|
|
|
SessionPropertiesRow.BLINDS -> if (value is ArrayList<*>) { |
|
|
|
cgSmallBlind = try { |
|
|
|
cgSmallBlind = try { |
|
|
|
(value[0] as String? ?: "0").toDouble() |
|
|
|
(value[0] as String? ?: "0").toDouble() |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
@ -731,27 +730,27 @@ open class Session : RealmObject(), Savable, Editable, RowRepresentable, Timed, |
|
|
|
cgSmallBlind = null |
|
|
|
cgSmallBlind = null |
|
|
|
cgBigBlind = null |
|
|
|
cgBigBlind = null |
|
|
|
} |
|
|
|
} |
|
|
|
SessionRow.BREAK_TIME -> { |
|
|
|
SessionPropertiesRow.BREAK_TIME -> { |
|
|
|
this.breakDuration = (value as Double? ?: 0.0).toLong() * 60 * 1000 |
|
|
|
this.breakDuration = (value as Double? ?: 0.0).toLong() * 60 * 1000 |
|
|
|
} |
|
|
|
} |
|
|
|
SessionRow.BUY_IN -> { |
|
|
|
SessionPropertiesRow.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 -> { |
|
|
|
SessionPropertiesRow.CASHED_OUT, SessionPropertiesRow.PRIZE -> { |
|
|
|
val localResult = getOrCreateResult() |
|
|
|
val localResult = getOrCreateResult() |
|
|
|
localResult.cashout = value as Double? |
|
|
|
localResult.cashout = value as Double? |
|
|
|
} |
|
|
|
} |
|
|
|
SessionRow.NET_RESULT -> { |
|
|
|
SessionPropertiesRow.NET_RESULT -> { |
|
|
|
val localResult = getOrCreateResult() |
|
|
|
val localResult = getOrCreateResult() |
|
|
|
localResult.netResult = value as Double? |
|
|
|
localResult.netResult = value as Double? |
|
|
|
} |
|
|
|
} |
|
|
|
SessionRow.COMMENT -> comment = value as String? ?: "" |
|
|
|
SessionPropertiesRow.COMMENT -> comment = value as String? ?: "" |
|
|
|
SessionRow.END_DATE -> if (value is Date?) { |
|
|
|
SessionPropertiesRow.END_DATE -> if (value is Date?) { |
|
|
|
this.endDate = value |
|
|
|
this.endDate = value |
|
|
|
} |
|
|
|
} |
|
|
|
SessionRow.GAME -> { |
|
|
|
SessionPropertiesRow.GAME -> { |
|
|
|
if (value is ArrayList<*>) { |
|
|
|
if (value is ArrayList<*>) { |
|
|
|
limit = try { |
|
|
|
limit = try { |
|
|
|
(value[0] as Int?) |
|
|
|
(value[0] as Int?) |
|
|
|
@ -770,18 +769,18 @@ open class Session : RealmObject(), Savable, Editable, RowRepresentable, Timed, |
|
|
|
game = null |
|
|
|
game = null |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
SessionRow.INITIAL_BUY_IN -> { |
|
|
|
SessionPropertiesRow.INITIAL_BUY_IN -> { |
|
|
|
this.tournamentEntryFee = (value as Double?) |
|
|
|
this.tournamentEntryFee = (value as Double?) |
|
|
|
} |
|
|
|
} |
|
|
|
SessionRow.LOCATION -> location = value as Location? |
|
|
|
SessionPropertiesRow.LOCATION -> location = value as Location? |
|
|
|
SessionRow.PLAYERS -> { |
|
|
|
SessionPropertiesRow.PLAYERS -> { |
|
|
|
if (value is Double) { |
|
|
|
if (value is Double) { |
|
|
|
this.tournamentNumberOfPlayers = value.toInt() |
|
|
|
this.tournamentNumberOfPlayers = value.toInt() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.tournamentNumberOfPlayers = null |
|
|
|
this.tournamentNumberOfPlayers = null |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
SessionRow.POSITION -> { |
|
|
|
SessionPropertiesRow.POSITION -> { |
|
|
|
val localResult = if (result != null) result as Result else realm.createObject(Result::class.java) |
|
|
|
val localResult = if (result != null) result as Result else realm.createObject(Result::class.java) |
|
|
|
if (value is Double) { |
|
|
|
if (value is Double) { |
|
|
|
localResult.tournamentFinalPosition = value.toInt() |
|
|
|
localResult.tournamentFinalPosition = value.toInt() |
|
|
|
@ -790,17 +789,17 @@ open class Session : RealmObject(), Savable, Editable, RowRepresentable, Timed, |
|
|
|
} |
|
|
|
} |
|
|
|
result = localResult |
|
|
|
result = localResult |
|
|
|
} |
|
|
|
} |
|
|
|
SessionRow.START_DATE -> if (value is Date) { |
|
|
|
SessionPropertiesRow.START_DATE -> if (value is Date) { |
|
|
|
this.startDate = value |
|
|
|
this.startDate = value |
|
|
|
} |
|
|
|
} |
|
|
|
SessionRow.TABLE_SIZE -> tableSize = value as Int? |
|
|
|
SessionPropertiesRow.TABLE_SIZE -> tableSize = value as Int? |
|
|
|
SessionRow.TIPS -> { |
|
|
|
SessionPropertiesRow.TIPS -> { |
|
|
|
val localResult = getOrCreateResult() |
|
|
|
val localResult = getOrCreateResult() |
|
|
|
localResult.tips = value as Double? |
|
|
|
localResult.tips = value as Double? |
|
|
|
} |
|
|
|
} |
|
|
|
SessionRow.TOURNAMENT_NAME -> tournamentName = value as TournamentName? |
|
|
|
SessionPropertiesRow.TOURNAMENT_NAME -> tournamentName = value as TournamentName? |
|
|
|
SessionRow.TOURNAMENT_TYPE -> tournamentType = (value as TournamentType?)?.ordinal |
|
|
|
SessionPropertiesRow.TOURNAMENT_TYPE -> tournamentType = (value as TournamentType?)?.ordinal |
|
|
|
SessionRow.TOURNAMENT_FEATURE -> { |
|
|
|
SessionPropertiesRow.TOURNAMENT_FEATURE -> { |
|
|
|
|
|
|
|
|
|
|
|
value?.let { |
|
|
|
value?.let { |
|
|
|
tournamentFeatures = RealmList() |
|
|
|
tournamentFeatures = RealmList() |
|
|
|
@ -945,30 +944,30 @@ open class Session : RealmObject(), Savable, Editable, RowRepresentable, Timed, |
|
|
|
fun charSequenceForRow(row: RowRepresentable, context: Context): String { |
|
|
|
fun charSequenceForRow(row: RowRepresentable, context: Context): String { |
|
|
|
|
|
|
|
|
|
|
|
return when (row) { |
|
|
|
return when (row) { |
|
|
|
SessionRow.BANKROLL -> bankroll?.name ?: NULL_TEXT |
|
|
|
SessionPropertiesRow.BANKROLL -> bankroll?.name ?: NULL_TEXT |
|
|
|
SessionRow.BLINDS -> getFormattedBlinds() |
|
|
|
SessionPropertiesRow.BLINDS -> getFormattedBlinds() |
|
|
|
SessionRow.BREAK_TIME -> if (this.breakDuration > 0.0) this.breakDuration.toMinutes() else NULL_TEXT |
|
|
|
SessionPropertiesRow.BREAK_TIME -> if (this.breakDuration > 0.0) this.breakDuration.toMinutes() else NULL_TEXT |
|
|
|
SessionRow.BUY_IN -> this.result?.buyin?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
SessionPropertiesRow.BUY_IN -> this.result?.buyin?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
SessionRow.CASHED_OUT, SessionRow.PRIZE -> this.result?.cashout?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
SessionPropertiesRow.CASHED_OUT, SessionPropertiesRow.PRIZE -> this.result?.cashout?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
SessionRow.NET_RESULT -> this.result?.netResult?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
SessionPropertiesRow.NET_RESULT -> this.result?.netResult?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
SessionRow.COMMENT -> if (this.comment.isNotEmpty()) this.comment else NULL_TEXT |
|
|
|
SessionPropertiesRow.COMMENT -> if (this.comment.isNotEmpty()) this.comment else NULL_TEXT |
|
|
|
SessionRow.END_DATE -> this.endDate?.shortDateTime() ?: NULL_TEXT |
|
|
|
SessionPropertiesRow.END_DATE -> this.endDate?.shortDateTime() ?: NULL_TEXT |
|
|
|
SessionRow.GAME -> getFormattedGame() |
|
|
|
SessionPropertiesRow.GAME -> getFormattedGame() |
|
|
|
SessionRow.INITIAL_BUY_IN -> tournamentEntryFee?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
SessionPropertiesRow.INITIAL_BUY_IN -> tournamentEntryFee?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
SessionRow.LOCATION -> location?.name ?: NULL_TEXT |
|
|
|
SessionPropertiesRow.LOCATION -> location?.name ?: NULL_TEXT |
|
|
|
SessionRow.PLAYERS -> tournamentNumberOfPlayers?.toString() ?: NULL_TEXT |
|
|
|
SessionPropertiesRow.PLAYERS -> tournamentNumberOfPlayers?.toString() ?: NULL_TEXT |
|
|
|
SessionRow.POSITION -> result?.tournamentFinalPosition?.toString() ?: NULL_TEXT |
|
|
|
SessionPropertiesRow.POSITION -> result?.tournamentFinalPosition?.toString() ?: NULL_TEXT |
|
|
|
SessionRow.START_DATE -> this.startDate?.shortDateTime() ?: NULL_TEXT |
|
|
|
SessionPropertiesRow.START_DATE -> this.startDate?.shortDateTime() ?: NULL_TEXT |
|
|
|
SessionRow.TABLE_SIZE -> this.tableSize?.let { TableSize(it).localizedTitle(context) } ?: NULL_TEXT |
|
|
|
SessionPropertiesRow.TABLE_SIZE -> this.tableSize?.let { TableSize(it).localizedTitle(context) } ?: NULL_TEXT |
|
|
|
SessionRow.TIPS -> result?.tips?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
SessionPropertiesRow.TIPS -> result?.tips?.toCurrency(currency) ?: NULL_TEXT |
|
|
|
SessionRow.TOURNAMENT_TYPE -> { |
|
|
|
SessionPropertiesRow.TOURNAMENT_TYPE -> { |
|
|
|
this.tournamentType?.let { |
|
|
|
this.tournamentType?.let { |
|
|
|
TournamentType.values()[it].localizedTitle(context) |
|
|
|
TournamentType.values()[it].localizedTitle(context) |
|
|
|
} ?: run { |
|
|
|
} ?: run { |
|
|
|
NULL_TEXT |
|
|
|
NULL_TEXT |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
SessionRow.TOURNAMENT_FEATURE -> { |
|
|
|
SessionPropertiesRow.TOURNAMENT_FEATURE -> { |
|
|
|
if (tournamentFeatures.size > 2) { |
|
|
|
if (tournamentFeatures.size > 2) { |
|
|
|
"${tournamentFeatures.subList(0, 2).joinToString { |
|
|
|
"${tournamentFeatures.subList(0, 2).joinToString { |
|
|
|
it.name |
|
|
|
it.name |
|
|
|
@ -981,8 +980,8 @@ open class Session : RealmObject(), Savable, Editable, RowRepresentable, Timed, |
|
|
|
NULL_TEXT |
|
|
|
NULL_TEXT |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
SessionRow.TOURNAMENT_NAME -> tournamentName?.name ?: NULL_TEXT |
|
|
|
SessionPropertiesRow.TOURNAMENT_NAME -> tournamentName?.name ?: NULL_TEXT |
|
|
|
SessionRow.HANDS -> this.handHistories?.size.toString() |
|
|
|
SessionPropertiesRow.HANDS -> this.handHistories?.size.toString() |
|
|
|
is CustomField -> { |
|
|
|
is CustomField -> { |
|
|
|
customFieldEntries.find { it.customField?.id == row.id }?.let { customFieldEntry -> |
|
|
|
customFieldEntries.find { it.customField?.id == row.id }?.let { customFieldEntry -> |
|
|
|
return customFieldEntry.getFormattedValue(currency) |
|
|
|
return customFieldEntry.getFormattedValue(currency) |
|
|
|
|