|
|
|
@ -716,107 +716,110 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun updateValue(value: Any?, row: RowRepresentable) { |
|
|
|
override fun updateValue(value: Any?, row: RowRepresentable) { |
|
|
|
realm.beginTransaction() |
|
|
|
|
|
|
|
when (row) { |
|
|
|
|
|
|
|
SessionRow.BANKROLL -> bankroll = value as Bankroll? |
|
|
|
|
|
|
|
SessionRow.BLINDS -> if (value is ArrayList<*>) { |
|
|
|
|
|
|
|
cgSmallBlind = try { |
|
|
|
|
|
|
|
(value[0] as String? ?: "0").toDouble() |
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cgBigBlind = try { |
|
|
|
|
|
|
|
(value[1] as String? ?: "0").toDouble() |
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cgBigBlind?.let { |
|
|
|
|
|
|
|
if (cgSmallBlind == null || cgSmallBlind == 0.0) { |
|
|
|
|
|
|
|
cgSmallBlind = it / 2.0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (value == null) { |
|
|
|
|
|
|
|
cgSmallBlind = null |
|
|
|
|
|
|
|
cgBigBlind = null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.BREAK_TIME -> { |
|
|
|
|
|
|
|
this.breakDuration = if (value != null) (value as String).toLong() * 60 * 1000 else 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.BUY_IN -> { |
|
|
|
|
|
|
|
val localResult = if (this.result != null) this.result as Result else realm.createObject(Result::class.java) |
|
|
|
|
|
|
|
localResult.buyin = value as Double? |
|
|
|
|
|
|
|
this.result = localResult |
|
|
|
|
|
|
|
this.updateRowRepresentation() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.CASHED_OUT, SessionRow.PRIZE -> { |
|
|
|
|
|
|
|
val localResult = if (this.result != null) this.result as Result else realm.createObject(Result::class.java) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (value == null) { |
|
|
|
|
|
|
|
localResult.cashout = null |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
localResult.cashout = (value as String).toDouble() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.result = localResult |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.NET_RESULT -> { |
|
|
|
|
|
|
|
this.result?.let { result -> |
|
|
|
|
|
|
|
result.netResult = (value as String).toDouble() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.COMMENT -> comment = value as String? ?: "" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SessionRow.END_DATE -> if (value is Date?) { |
|
|
|
realm.executeTransaction { |
|
|
|
this.endDate = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
when (row) { |
|
|
|
SessionRow.GAME -> { |
|
|
|
SessionRow.BANKROLL -> bankroll = value as Bankroll? |
|
|
|
if (value is ArrayList<*>) { |
|
|
|
SessionRow.BLINDS -> if (value is ArrayList<*>) { |
|
|
|
limit = try { |
|
|
|
cgSmallBlind = try { |
|
|
|
(value[0] as Int?) |
|
|
|
(value[0] as String? ?: "0").toDouble() |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
null |
|
|
|
null |
|
|
|
} |
|
|
|
} |
|
|
|
game = try { |
|
|
|
|
|
|
|
(value[1] as Game?) |
|
|
|
cgBigBlind = try { |
|
|
|
|
|
|
|
(value[1] as String? ?: "0").toDouble() |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
null |
|
|
|
null |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (value is Game) { |
|
|
|
|
|
|
|
game = value |
|
|
|
cgBigBlind?.let { |
|
|
|
|
|
|
|
if (cgSmallBlind == null || cgSmallBlind == 0.0) { |
|
|
|
|
|
|
|
cgSmallBlind = it / 2.0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} else if (value == null) { |
|
|
|
} else if (value == null) { |
|
|
|
limit = null |
|
|
|
cgSmallBlind = null |
|
|
|
game = null |
|
|
|
cgBigBlind = null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.BREAK_TIME -> { |
|
|
|
|
|
|
|
this.breakDuration = if (value != null) (value as String).toLong() * 60 * 1000 else 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.BUY_IN -> { |
|
|
|
|
|
|
|
val localResult = if (this.result != null) this.result as Result else realm.createObject(Result::class.java) |
|
|
|
|
|
|
|
localResult.buyin = value as Double? |
|
|
|
|
|
|
|
this.result = localResult |
|
|
|
|
|
|
|
this.updateRowRepresentation() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.CASHED_OUT, SessionRow.PRIZE -> { |
|
|
|
|
|
|
|
val localResult = if (this.result != null) this.result as Result else realm.createObject(Result::class.java) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (value == null) { |
|
|
|
|
|
|
|
localResult.cashout = null |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
localResult.cashout = (value as String).toDouble() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.result = localResult |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.NET_RESULT -> { |
|
|
|
|
|
|
|
this.result?.let { result -> |
|
|
|
|
|
|
|
result.netResult = (value as String).toDouble() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.COMMENT -> comment = value as String? ?: "" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SessionRow.END_DATE -> if (value is Date?) { |
|
|
|
|
|
|
|
this.endDate = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.GAME -> { |
|
|
|
|
|
|
|
if (value is ArrayList<*>) { |
|
|
|
|
|
|
|
limit = try { |
|
|
|
|
|
|
|
(value[0] as Int?) |
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
game = try { |
|
|
|
|
|
|
|
(value[1] as Game?) |
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (value is Game) { |
|
|
|
|
|
|
|
game = value |
|
|
|
|
|
|
|
} else if (value == null) { |
|
|
|
|
|
|
|
limit = null |
|
|
|
|
|
|
|
game = null |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.INITIAL_BUY_IN -> tournamentEntryFee = if (value == null) null else (value as String).toDouble() |
|
|
|
|
|
|
|
SessionRow.LOCATION -> location = value as Location? |
|
|
|
|
|
|
|
SessionRow.PLAYERS -> tournamentNumberOfPlayers = if (value != null) (value as String).toInt() else null |
|
|
|
|
|
|
|
SessionRow.POSITION -> { |
|
|
|
|
|
|
|
val localResult = if (result != null) result as Result else realm.createObject(Result::class.java) |
|
|
|
|
|
|
|
localResult.tournamentFinalPosition = if (value == null) null else (value as String).toInt() |
|
|
|
|
|
|
|
result = localResult |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.START_DATE -> if (value is Date) { |
|
|
|
|
|
|
|
this.startDate = value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.TABLE_SIZE -> tableSize = value as Int? |
|
|
|
|
|
|
|
SessionRow.TIPS -> { |
|
|
|
|
|
|
|
val localResult = if (result != null) result as Result else realm.createObject(Result::class.java) |
|
|
|
|
|
|
|
localResult.tips = value as Double? |
|
|
|
|
|
|
|
result = localResult |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.TOURNAMENT_NAME -> tournamentName = value as TournamentName? |
|
|
|
|
|
|
|
SessionRow.TOURNAMENT_TYPE -> tournamentType = value as Int? |
|
|
|
|
|
|
|
SessionRow.TOURNAMENT_FEATURE -> value?.let { |
|
|
|
|
|
|
|
tournamentFeatures = RealmList() |
|
|
|
|
|
|
|
tournamentFeatures.addAll((it as ArrayList<TournamentFeature>)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.INITIAL_BUY_IN -> tournamentEntryFee = if (value == null) null else (value as String).toDouble() |
|
|
|
|
|
|
|
SessionRow.LOCATION -> location = value as Location? |
|
|
|
|
|
|
|
SessionRow.PLAYERS -> tournamentNumberOfPlayers = if (value != null) (value as String).toInt() else null |
|
|
|
|
|
|
|
SessionRow.POSITION -> { |
|
|
|
|
|
|
|
val localResult = if (result != null) result as Result else realm.createObject(Result::class.java) |
|
|
|
|
|
|
|
localResult.tournamentFinalPosition = if (value == null) null else (value as String).toInt() |
|
|
|
|
|
|
|
result = localResult |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.START_DATE -> if (value is Date) { |
|
|
|
|
|
|
|
this.startDate = value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.TABLE_SIZE -> tableSize = value as Int? |
|
|
|
|
|
|
|
SessionRow.TIPS -> { |
|
|
|
|
|
|
|
val localResult = if (result != null) result as Result else realm.createObject(Result::class.java) |
|
|
|
|
|
|
|
localResult.tips = value as Double? |
|
|
|
|
|
|
|
result = localResult |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SessionRow.TOURNAMENT_NAME -> tournamentName = value as TournamentName? |
|
|
|
|
|
|
|
SessionRow.TOURNAMENT_TYPE -> tournamentType = value as Int? |
|
|
|
|
|
|
|
SessionRow.TOURNAMENT_FEATURE -> value?.let { |
|
|
|
|
|
|
|
tournamentFeatures = RealmList() |
|
|
|
|
|
|
|
tournamentFeatures.addAll((it as ArrayList<TournamentFeature>)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
realm.commitTransaction() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|