Fixes crash when setting empty value on net result

feature/top10
Laurent 7 years ago
parent ae0d8d3e40
commit 5125926f82
  1. 23
      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 -> {
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.updateRowRepresentation()
}
@ -776,7 +782,13 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
}
SessionRow.NET_RESULT -> {
this.result?.let { result ->
result.netResult = (value as String).toDouble()
if (value == null) {
result.netResult = null
} else {
result.netResult = (value as String).toDouble()
}
}
}
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.TIPS -> {
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
}
SessionRow.TOURNAMENT_NAME -> tournamentName = value as TournamentName?

Loading…
Cancel
Save