Fixes crash when setting empty value on net result

feature/top10
Laurent 7 years ago
parent ae0d8d3e40
commit 5125926f82
  1. 21
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt

@ -759,7 +759,13 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
} }
SessionRow.BUY_IN -> { SessionRow.BUY_IN -> {
val localResult = if (this.result != null) this.result as Result else realm.createObject(Result::class.java) val localResult = if (this.result != null) this.result as Result else realm.createObject(Result::class.java)
localResult.buyin = value as Double?
if (value == null) {
localResult.buyin = null
} else {
localResult.buyin = (value as String).toDouble()
}
this.result = localResult this.result = localResult
this.updateRowRepresentation() this.updateRowRepresentation()
} }
@ -776,8 +782,14 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
} }
SessionRow.NET_RESULT -> { SessionRow.NET_RESULT -> {
this.result?.let { result -> this.result?.let { result ->
if (value == null) {
result.netResult = null
} else {
result.netResult = (value as String).toDouble() result.netResult = (value as String).toDouble()
} }
}
} }
SessionRow.COMMENT -> comment = value as String? ?: "" SessionRow.COMMENT -> comment = value as String? ?: ""
@ -819,7 +831,12 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
SessionRow.TABLE_SIZE -> tableSize = value as Int? SessionRow.TABLE_SIZE -> tableSize = value as Int?
SessionRow.TIPS -> { SessionRow.TIPS -> {
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)
localResult.tips = value as Double? if (value == null) {
localResult.tips = null
} else {
localResult.tips = (value as String).toDouble()
}
result = localResult result = localResult
} }
SessionRow.TOURNAMENT_NAME -> tournamentName = value as TournamentName? SessionRow.TOURNAMENT_NAME -> tournamentName = value as TournamentName?

Loading…
Cancel
Save