Removes right label for average

od
Laurent 6 years ago
parent 43beb91bdf
commit ec66cf5a74
  1. 15
      app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt
  2. 6
      app/src/main/java/net/pokeranalytics/android/model/realm/ComputableResult.kt
  3. 3
      app/src/main/java/net/pokeranalytics/android/ui/fragment/GraphFragment.kt
  4. 10
      app/src/main/java/net/pokeranalytics/android/ui/graph/GraphUnderlyingEntry.kt
  5. 2
      app/src/main/java/net/pokeranalytics/android/ui/view/LegendView.kt

@ -86,7 +86,7 @@ enum class Stat(override var uniqueIdentifier: Int) : IntIdentifiable, RowRepres
return netBB / numberOfHands * 100
}
fun riskOfRuin(hourlyRate: Double, hourlyStandardDeviation: Double, bankrollValue: Double) : Double? {
fun riskOfRuin(hourlyRate: Double, hourlyStandardDeviation: Double, bankrollValue: Double): Double? {
if (bankrollValue <= 0.0) {
return null
@ -243,13 +243,24 @@ enum class Stat(override var uniqueIdentifier: Int) : IntIdentifiable, RowRepres
}
}
val legendHideRightValue: Boolean
get() {
return when (this) {
AVERAGE, NUMBER_OF_SETS, NUMBER_OF_GAMES, WIN_RATIO,
HOURLY_DURATION, AVERAGE_HOURLY_DURATION -> true
else -> false
}
}
/**
* Returns if the stat has a significant value to display in a progress graph
*/
val graphSignificantIndividualValue: Boolean
get() {
return when (this) {
WIN_RATIO, NUMBER_OF_SETS, NUMBER_OF_GAMES, STANDARD_DEVIATION, HOURLY_DURATION -> false
AVERAGE, WIN_RATIO, NUMBER_OF_SETS, NUMBER_OF_GAMES,
STANDARD_DEVIATION, HOURLY_DURATION -> false
else -> true
}
}

@ -20,14 +20,10 @@ open class ComputableResult() : RealmObject(), Filterable {
var bbPer100Hands: BB = 0.0
// var sessionSet: SessionSet? = null
var session: Session? = null
fun updateWith(session: Session) {
// this.sessionSet = session.sessionSet
val rate = session.bankroll?.currency?.rate ?: 1.0
session.result?.let { result ->
@ -50,7 +46,7 @@ open class ComputableResult() : RealmObject(), Filterable {
IS_POSITIVE("isPositive"),
RATED_BUYIN("ratedBuyin"),
ESTIMATED_HANDS("estimatedHands"),
BB_PER100HANDS("bbPer100Hands")
// BB_PER100HANDS("bbPer100Hands")
}
companion object {

@ -21,6 +21,7 @@ import net.pokeranalytics.android.ui.graph.GraphUnderlyingEntry
import net.pokeranalytics.android.ui.graph.setStyle
import net.pokeranalytics.android.ui.view.LegendView
import net.pokeranalytics.android.ui.view.MultiLineLegendView
import net.pokeranalytics.android.util.extensions.findById
import timber.log.Timber
@ -182,7 +183,7 @@ class GraphFragment : RealmFragment(), OnChartValueSelectedListener {
val statEntry = when (entry.data) {
is ObjectIdentifier -> {
val identifier = entry.data as ObjectIdentifier
getRealm().where(identifier.clazz).equalTo("id", identifier.id).findAll().firstOrNull()
getRealm().findById(identifier.clazz, identifier.id)
}
is GraphUnderlyingEntry -> entry.data
else -> null

@ -3,7 +3,6 @@ package net.pokeranalytics.android.ui.graph
import android.content.Context
import com.github.mikephil.charting.data.Entry
import net.pokeranalytics.android.calculus.Stat
import net.pokeranalytics.android.model.interfaces.Identifiable
import net.pokeranalytics.android.ui.fragment.GraphFragment
import net.pokeranalytics.android.ui.view.DefaultLegendValues
import net.pokeranalytics.android.ui.view.LegendContent
@ -23,17 +22,14 @@ interface GraphUnderlyingEntry {
): LegendContent {
val leftName = stat.localizedTitle(context)
return when (stat) {
Stat.NUMBER_OF_SETS, Stat.NUMBER_OF_GAMES, Stat.WIN_RATIO, Stat.HOURLY_DURATION, Stat.AVERAGE_HOURLY_DURATION -> {
val totalStatValue = stat.format(entry.y.toDouble(), currency = null)
return if (stat.legendHideRightValue) {
DefaultLegendValues(this.entryTitle(context), totalStatValue, leftName = leftName)
}
else -> {
} else {
val entryValue = this.formattedValue(stat)
val totalStatValue = stat.format(entry.y.toDouble(), currency = null)
DefaultLegendValues(this.entryTitle(context), entryValue, totalStatValue, leftName = leftName)
}
}
}

@ -108,9 +108,11 @@ open class LegendView : FrameLayout {
this.title.text = content.title.capitalize()
this.stat1Value.setTextFormat(content.leftFormat, context)
content.rightFormat?.let {
this.stat2Value.setTextFormat(it, context)
}
content.leftName?.let { name ->
this.stat1Name.text = name
}

Loading…
Cancel
Save