Fixes crash occuring when restarting a finished session

feature/top10
Laurent 7 years ago
parent 5464cb4a30
commit 80aeb42c28
  1. 8
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt

@ -321,8 +321,8 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
val computableResult = realm.createObject(ComputableResult::class.java) val computableResult = realm.createObject(ComputableResult::class.java)
computableResult.session = this computableResult.session = this
} // if a ComputableResult exists and the session is not completed, delete it } // if a ComputableResult exists and the session is not completed, delete it
else if (this.startDate == null || this.endDate == null) { else if ((this.startDate == null || this.endDate == null) && this.computableResult != null && this.computableResult.isValid) {
this.computableResult?.deleteFromRealm() this.computableResult.deleteFromRealm()
} }
// Update the ComputableResult // Update the ComputableResult
@ -441,9 +441,9 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
*/ */
fun restart() { fun restart() {
realm.executeTransaction { realm.executeTransaction {
// this.timeFrame?.paused = false
this.pauseDate = null this.pauseDate = null
this.startDate = Date() // timeFrame?.setDate(Date(), null) this.startDate = Date()
this.endDate = null
this.breakDuration = 0L this.breakDuration = 0L
} }
} }

Loading…
Cancel
Save