Improve Session

feature/top10
Aurelien Hubert 7 years ago
parent 3f8cc90a08
commit 7ab7b11c2a
  1. 28
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  2. 1
      app/src/main/java/net/pokeranalytics/android/ui/adapter/LimitTypesAdapter.kt
  3. 1
      app/src/main/res/layout/fragment_session.xml

@ -18,6 +18,7 @@ import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.SessionRow
import net.pokeranalytics.android.util.data.sessionDao
import net.pokeranalytics.android.util.getDuration
import net.pokeranalytics.android.util.round
import net.pokeranalytics.android.util.short
import net.pokeranalytics.android.util.toCurrency
import java.util.*
@ -149,6 +150,13 @@ open class Session : RealmObject(), SessionInterface, RowRepresentableDataSource
return startDate.getDuration(context, enDate)
}
/**
* Return the formatted blinds
*/
fun getBlinds() : String {
return if (cgSmallBlind == null) "--" else "$${cgSmallBlind?.round()}/${cgBigBlind?.round()}"
}
/**
* Delete the object from realm
* TODO: Cascade delete?
@ -255,7 +263,8 @@ open class Session : RealmObject(), SessionInterface, RowRepresentableDataSource
override fun stringForRow(row: RowRepresentable): String {
return when (row) {
SessionRow.BUY_IN -> buyin.toCurrency()
SessionRow.BLINDS -> if (cgSmallBlind != null && cgBigBlind != null) "$cgSmallBlind / $cgBigBlind" else "--"
SessionRow.CASHED_OUT -> result?.cashout?.toCurrency() ?: "--"
SessionRow.BLINDS -> getBlinds()
SessionRow.GAME -> game?.title ?: "--"
SessionRow.LOCATION -> location?.title ?: "--"
SessionRow.BANKROLL -> bankroll?.title ?: "--"
@ -305,6 +314,9 @@ open class Session : RealmObject(), SessionInterface, RowRepresentableDataSource
)
)
}
SessionRow.CASHED_OUT -> {
data.add(BottomSheetData(result?.cashout, inputType = InputType.TYPE_CLASS_NUMBER))
}
SessionRow.TIPS -> {
// Disable the buttons with value = 0, add current value & set the 2 edit texts
// TODO: manage tips
@ -345,10 +357,14 @@ open class Session : RealmObject(), SessionInterface, RowRepresentableDataSource
override fun updateValue(value: Any?, row: RowRepresentable) {
realm.beginTransaction()
when (row) {
SessionRow.BUY_IN -> {
val localResult = if (result != null) result as Result else realm.createObject(Result::class.java)
localResult.buyin = value as Double
localResult.buyin = value as Double?
result = localResult
}
SessionRow.CASHED_OUT -> {
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
}
SessionRow.TABLE_SIZE -> tableSize = value as Int?
@ -367,6 +383,12 @@ open class Session : RealmObject(), SessionInterface, RowRepresentableDataSource
} catch (e: Exception) {
null
}
cgBigBlind?.let {
if (cgSmallBlind == null || cgSmallBlind == 0.0) {
cgSmallBlind = it / 2.0
}
}
}
//TODO: Update
SessionRow.START_DATE -> if (value is Date?) {

@ -21,6 +21,7 @@ class LimitTypesAdapter(private var tableSizes: ArrayList<String>) : RecyclerVie
itemView.title.text = tableSize
itemView.container.setOnClickListener {
onClickOnItem?.invoke(adapterPosition)
}
}
}

@ -69,6 +69,7 @@
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/appCompatTextView"
style="@style/PokerAnalyticsTheme.TextView.RowTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

Loading…
Cancel
Save