|
|
|
|
@ -16,10 +16,7 @@ import net.pokeranalytics.android.model.extensions.getState |
|
|
|
|
import net.pokeranalytics.android.model.interfaces.Savable |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource |
|
|
|
|
import net.pokeranalytics.android.ui.view.* |
|
|
|
|
import net.pokeranalytics.android.util.getDuration |
|
|
|
|
import net.pokeranalytics.android.util.round |
|
|
|
|
import net.pokeranalytics.android.util.shortDateTime |
|
|
|
|
import net.pokeranalytics.android.util.toCurrency |
|
|
|
|
import net.pokeranalytics.android.util.* |
|
|
|
|
import java.util.* |
|
|
|
|
import kotlin.collections.ArrayList |
|
|
|
|
|
|
|
|
|
@ -131,6 +128,7 @@ open class Session : RealmObject(), SessionInterface, Savable, |
|
|
|
|
} |
|
|
|
|
SessionState.PAUSED -> { |
|
|
|
|
this.timeFrame?.paused = false |
|
|
|
|
this.timeFrame?.pauseDate = null |
|
|
|
|
} |
|
|
|
|
else -> { |
|
|
|
|
} |
|
|
|
|
@ -146,6 +144,7 @@ open class Session : RealmObject(), SessionInterface, Savable, |
|
|
|
|
when (getState()) { |
|
|
|
|
SessionState.STARTED -> { |
|
|
|
|
this.timeFrame?.paused = true |
|
|
|
|
this.timeFrame?.pauseDate = Date() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -159,12 +158,25 @@ open class Session : RealmObject(), SessionInterface, Savable, |
|
|
|
|
when (getState()) { |
|
|
|
|
SessionState.STARTED, SessionState.PAUSED -> { |
|
|
|
|
this.timeFrame?.paused = false |
|
|
|
|
this.timeFrame?.pauseDate = null |
|
|
|
|
this.timeFrame?.setDate(null, Date()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Restart a session |
|
|
|
|
*/ |
|
|
|
|
fun restartSession() { |
|
|
|
|
realm.executeTransaction { |
|
|
|
|
this.timeFrame?.paused = false |
|
|
|
|
this.timeFrame?.pauseDate = null |
|
|
|
|
this.timeFrame?.setDate(Date(), null) |
|
|
|
|
this.timeFrame?.breakDuration = 0L |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return the duration of the current session |
|
|
|
|
*/ |
|
|
|
|
@ -339,16 +351,16 @@ open class Session : RealmObject(), SessionInterface, Savable, |
|
|
|
|
return when (row) { |
|
|
|
|
SessionRow.BANKROLL -> bankroll?.name ?: "--" |
|
|
|
|
SessionRow.BLINDS -> getBlinds() |
|
|
|
|
SessionRow.BREAK_TIME -> timeFrame?.breakDuration?.toMinutes() ?: "--" |
|
|
|
|
SessionRow.BUY_IN -> buyin.toCurrency() |
|
|
|
|
SessionRow.CASHED_OUT -> result?.cashout?.toCurrency() ?: "--" |
|
|
|
|
SessionRow.CASHED_OUT, SessionRow.PRIZE -> result?.cashout?.toCurrency() ?: "--" |
|
|
|
|
SessionRow.COMMENT -> if (comment.isNotEmpty()) comment else "--" |
|
|
|
|
SessionRow.END_DATE -> if (timeFrame != null) timeFrame?.endDate?.shortDateTime() ?: "--" else "--" |
|
|
|
|
SessionRow.GAME -> getGameTitle() |
|
|
|
|
SessionRow.INITIAL_BUY_IN -> tournamentEntryFee?.toCurrency() ?: "--" |
|
|
|
|
SessionRow.LOCATION -> location?.name ?: "--" |
|
|
|
|
SessionRow.PLAYERS -> "TODO" |
|
|
|
|
SessionRow.PLAYERS -> tournamentNumberOfPlayers?.toString() ?: "--" |
|
|
|
|
SessionRow.POSITION -> result?.tournamentFinalPosition?.toString() ?: "--" |
|
|
|
|
SessionRow.PRIZE -> "TODO" |
|
|
|
|
SessionRow.START_DATE -> if (timeFrame != null) timeFrame?.startDate?.shortDateTime() ?: "--" else "--" |
|
|
|
|
SessionRow.TABLE_SIZE -> this.tableSize?.let { TableSize(it).localizedTitle(context) } ?: "--" |
|
|
|
|
SessionRow.TIPS -> result?.tips?.toCurrency() ?: "--" |
|
|
|
|
@ -387,6 +399,12 @@ open class Session : RealmObject(), SessionInterface, Savable, |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
SessionRow.BREAK_TIME -> { |
|
|
|
|
data.add( |
|
|
|
|
RowRepresentableEditDescriptor("", |
|
|
|
|
hint = R.string.in_minutes, inputType = InputType.TYPE_CLASS_NUMBER) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
SessionRow.BUY_IN -> { |
|
|
|
|
// Add first & second buttons values, current value & set the 2 edit texts |
|
|
|
|
if (cgBigBlind != null) { |
|
|
|
|
@ -395,6 +413,9 @@ open class Session : RealmObject(), SessionInterface, Savable, |
|
|
|
|
} else if (tournamentEntryFee != null) { |
|
|
|
|
data.add(RowRepresentableEditDescriptor((tournamentEntryFee ?: 0.0) * 1.0)) |
|
|
|
|
data.add(RowRepresentableEditDescriptor((tournamentEntryFee ?: 0.0) * 2.0)) |
|
|
|
|
} else { |
|
|
|
|
data.add(RowRepresentableEditDescriptor(0)) |
|
|
|
|
data.add(RowRepresentableEditDescriptor(0)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
data.add(RowRepresentableEditDescriptor(buyin)) |
|
|
|
|
@ -411,7 +432,7 @@ open class Session : RealmObject(), SessionInterface, Savable, |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
SessionRow.CASHED_OUT -> { |
|
|
|
|
SessionRow.CASHED_OUT, SessionRow.PRIZE -> { |
|
|
|
|
data.add( |
|
|
|
|
RowRepresentableEditDescriptor(result?.cashout?.round(), inputType = InputType.TYPE_CLASS_NUMBER) |
|
|
|
|
) |
|
|
|
|
@ -433,10 +454,9 @@ open class Session : RealmObject(), SessionInterface, Savable, |
|
|
|
|
// Add current location and locations list |
|
|
|
|
data.add(RowRepresentableEditDescriptor(location, data = LiveData.LOCATION.items(realm))) |
|
|
|
|
} |
|
|
|
|
//TODO |
|
|
|
|
SessionRow.PLAYERS -> { |
|
|
|
|
data.add( |
|
|
|
|
RowRepresentableEditDescriptor("", inputType = InputType.TYPE_CLASS_NUMBER) |
|
|
|
|
RowRepresentableEditDescriptor(tournamentNumberOfPlayers?.toString(), inputType = InputType.TYPE_CLASS_NUMBER) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
SessionRow.POSITION -> { |
|
|
|
|
@ -447,12 +467,6 @@ open class Session : RealmObject(), SessionInterface, Savable, |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
//TODO |
|
|
|
|
SessionRow.PRIZE -> { |
|
|
|
|
data.add( |
|
|
|
|
RowRepresentableEditDescriptor("", inputType = InputType.TYPE_CLASS_NUMBER) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
SessionRow.TABLE_SIZE -> { |
|
|
|
|
data.add(RowRepresentableEditDescriptor(tableSize)) |
|
|
|
|
} |
|
|
|
|
@ -499,12 +513,18 @@ open class Session : RealmObject(), SessionInterface, Savable, |
|
|
|
|
cgSmallBlind = null |
|
|
|
|
cgBigBlind = null |
|
|
|
|
} |
|
|
|
|
SessionRow.BREAK_TIME -> { |
|
|
|
|
val timeFrameToUpdate = |
|
|
|
|
if (timeFrame != null) timeFrame as TimeFrame else realm.createObject(TimeFrame::class.java) |
|
|
|
|
timeFrameToUpdate.breakDuration = if (value != null) (value as String).toLong() * 60 * 1000 else 0 |
|
|
|
|
timeFrame = timeFrameToUpdate |
|
|
|
|
} |
|
|
|
|
SessionRow.BUY_IN -> { |
|
|
|
|
val localResult = if (result != null) result as Result else realm.createObject(Result::class.java) |
|
|
|
|
localResult.buyin = value as Double? |
|
|
|
|
result = localResult |
|
|
|
|
} |
|
|
|
|
SessionRow.CASHED_OUT -> { |
|
|
|
|
SessionRow.CASHED_OUT, SessionRow.PRIZE -> { |
|
|
|
|
val localResult = if (result != null) result as Result else realm.createObject(Result::class.java) |
|
|
|
|
localResult.cashout = if (value == null) null else (value as String).toDouble() |
|
|
|
|
result = localResult |
|
|
|
|
@ -533,15 +553,12 @@ open class Session : RealmObject(), SessionInterface, Savable, |
|
|
|
|
} |
|
|
|
|
SessionRow.INITIAL_BUY_IN -> tournamentEntryFee = if (value == null) null else (value as String).toDouble() |
|
|
|
|
SessionRow.LOCATION -> location = value as Location? |
|
|
|
|
SessionRow.PLAYERS -> { |
|
|
|
|
}//TODO |
|
|
|
|
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.PRIZE -> { |
|
|
|
|
}//TODO |
|
|
|
|
SessionRow.START_DATE -> if (value is Date?) { |
|
|
|
|
if (value == null) { |
|
|
|
|
timeFrame = null |
|
|
|
|
|