|
|
|
@ -512,7 +512,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun startOrContinue() { |
|
|
|
fun startOrContinue() { |
|
|
|
realm.executeTransaction { |
|
|
|
realm.executeTransaction { |
|
|
|
when (getState()) { |
|
|
|
when (val state = getState()) { |
|
|
|
SessionState.PENDING, SessionState.PLANNED -> { |
|
|
|
SessionState.PENDING, SessionState.PLANNED -> { |
|
|
|
this.startDate = Date() |
|
|
|
this.startDate = Date() |
|
|
|
this.defineDefaultTournamentBuyinIfNecessary() |
|
|
|
this.defineDefaultTournamentBuyinIfNecessary() |
|
|
|
@ -527,7 +527,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
this.pauseDate = null |
|
|
|
this.pauseDate = null |
|
|
|
} |
|
|
|
} |
|
|
|
else -> { |
|
|
|
else -> { |
|
|
|
throw PAIllegalStateException("unmanaged session state") |
|
|
|
throw PAIllegalStateException("unmanaged session state: $state") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -544,11 +544,11 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun pause() { |
|
|
|
fun pause() { |
|
|
|
realm.executeTransaction { |
|
|
|
realm.executeTransaction { |
|
|
|
when (getState()) { |
|
|
|
when (val state = getState()) { |
|
|
|
SessionState.STARTED -> { |
|
|
|
SessionState.STARTED -> { |
|
|
|
this.pauseDate = Date() |
|
|
|
this.pauseDate = Date() |
|
|
|
} |
|
|
|
} |
|
|
|
else -> throw PAIllegalStateException("Pausing a session in an unmanaged state") |
|
|
|
else -> throw PAIllegalStateException("Pausing a session in an unmanaged state: $state") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -558,11 +558,11 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun stop() { |
|
|
|
fun stop() { |
|
|
|
realm.executeTransaction { |
|
|
|
realm.executeTransaction { |
|
|
|
when (getState()) { |
|
|
|
when (val state = getState()) { |
|
|
|
SessionState.STARTED, SessionState.PAUSED -> { |
|
|
|
SessionState.STARTED, SessionState.PAUSED -> { |
|
|
|
this.end() |
|
|
|
this.end() |
|
|
|
} |
|
|
|
} |
|
|
|
else -> throw Exception("Stopping session in unmanaged state") |
|
|
|
else -> throw Exception("Stopping session in unmanaged state: $state") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|