Improve session management

feature/top10
Aurelien Hubert 7 years ago
parent 4aeb654104
commit 0f269ea0bb
  1. 16
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  2. 12
      app/src/main/java/net/pokeranalytics/android/ui/view/SessionRowView.kt

@ -313,6 +313,8 @@ open class Session : RealmObject(), SessionInterface, Savable,
resId = R.string.hour_rate_without_pauses, value = result?.net.toString() resId = R.string.hour_rate_without_pauses, value = result?.net.toString()
) )
) )
if (type == TYPE_GAME) {
rows.add( rows.add(
HeaderRowRepresentable( HeaderRowRepresentable(
RowViewType.HEADER_TITLE_VALUE, RowViewType.HEADER_TITLE_VALUE,
@ -320,8 +322,8 @@ open class Session : RealmObject(), SessionInterface, Savable,
) )
) )
} }
else -> {
} }
else -> {}
} }
// Rows // Rows
@ -387,8 +389,14 @@ open class Session : RealmObject(), SessionInterface, Savable,
} }
SessionRow.BUY_IN -> { SessionRow.BUY_IN -> {
// Add first & second buttons values, current value & set the 2 edit texts // Add first & second buttons values, current value & set the 2 edit texts
if (cgBigBlind != null) {
data.add(RowRepresentableEditDescriptor(100.0 * (cgBigBlind ?: 0.0))) data.add(RowRepresentableEditDescriptor(100.0 * (cgBigBlind ?: 0.0)))
data.add(RowRepresentableEditDescriptor(200.0 * (cgBigBlind ?: 0.0))) data.add(RowRepresentableEditDescriptor(200.0 * (cgBigBlind ?: 0.0)))
} else if (tournamentEntryFee != null) {
data.add(RowRepresentableEditDescriptor((tournamentEntryFee ?: 0.0) * 1.0))
data.add(RowRepresentableEditDescriptor((tournamentEntryFee ?: 0.0) * 2.0))
}
data.add(RowRepresentableEditDescriptor(buyin)) data.add(RowRepresentableEditDescriptor(buyin))
data.add( data.add(
RowRepresentableEditDescriptor( RowRepresentableEditDescriptor(
@ -525,13 +533,15 @@ open class Session : RealmObject(), SessionInterface, Savable,
} }
SessionRow.INITIAL_BUY_IN -> tournamentEntryFee = if (value == null) null else (value as String).toDouble() SessionRow.INITIAL_BUY_IN -> tournamentEntryFee = if (value == null) null else (value as String).toDouble()
SessionRow.LOCATION -> location = value as Location? SessionRow.LOCATION -> location = value as Location?
SessionRow.PLAYERS -> ""//TODO SessionRow.PLAYERS -> {
}//TODO
SessionRow.POSITION -> { SessionRow.POSITION -> {
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.tournamentFinalPosition = if (value == null) null else (value as String).toInt() localResult.tournamentFinalPosition = if (value == null) null else (value as String).toInt()
result = localResult result = localResult
} }
SessionRow.PRIZE -> ""//TODO SessionRow.PRIZE -> {
}//TODO
SessionRow.START_DATE -> if (value is Date?) { SessionRow.START_DATE -> if (value is Date?) {
if (value == null) { if (value == null) {
timeFrame = null timeFrame = null

@ -14,6 +14,7 @@ import net.pokeranalytics.android.model.extensions.getState
import net.pokeranalytics.android.model.realm.Session import net.pokeranalytics.android.model.realm.Session
import net.pokeranalytics.android.util.getDayNumber import net.pokeranalytics.android.util.getDayNumber
import net.pokeranalytics.android.util.getShortDayName import net.pokeranalytics.android.util.getShortDayName
import net.pokeranalytics.android.util.toCurrency
/** /**
* Display a row session * Display a row session
@ -61,7 +62,17 @@ class SessionRowView : FrameLayout {
rowHistorySession.dateNumber.text = session.creationDate.getDayNumber() rowHistorySession.dateNumber.text = session.creationDate.getDayNumber()
// Title / Game type // Title / Game type
var title = "" var title = ""
if (session.type == Session.TYPE_TOURNAMENT) {
if (session.tournamentEntryFee != null) {
title += session.tournamentEntryFee?.toCurrency()
}
session.game?.let {
title += (if (title.isNotEmpty()) " " else "") + session.getGameTitle()
}
} else if (session.type == Session.TYPE_GAME) {
if (session.cgSmallBlind != null && session.cgBigBlind != null) { if (session.cgSmallBlind != null && session.cgBigBlind != null) {
title += session.getBlinds() title += session.getBlinds()
} }
@ -69,6 +80,7 @@ class SessionRowView : FrameLayout {
title += (if (title.isNotEmpty()) " " else "") + session.getGameTitle() title += (if (title.isNotEmpty()) " " else "") + session.getGameTitle()
} }
title += if (title.isEmpty()) "--" else "" title += if (title.isEmpty()) "--" else ""
}
rowHistorySession.sessionTitle.text = title rowHistorySession.sessionTitle.text = title

Loading…
Cancel
Save