Merge remote-tracking branch 'origin/dev' into dev

feature/top10
Razmig Sarkissian 7 years ago
commit 0e6028f085
  1. 11
      app/src/main/java/net/pokeranalytics/android/calculus/Report.kt
  2. 22
      app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt
  3. 7
      app/src/main/java/net/pokeranalytics/android/model/realm/Currency.kt
  4. 28
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  5. 3
      app/src/main/java/net/pokeranalytics/android/model/realm/SessionSet.kt
  6. 10
      app/src/main/java/net/pokeranalytics/android/ui/fragment/GraphFragment.kt
  7. 0
      app/src/main/java/net/pokeranalytics/android/ui/graph/AxisFormatter.kt
  8. 18
      app/src/main/java/net/pokeranalytics/android/ui/view/LegendView.kt
  9. 9
      app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt

@ -69,17 +69,16 @@ class Report(var options: Calculator.Options) {
return BarDataSet(entries, statToUse?.name) return BarDataSet(entries, statToUse?.name)
} }
fun multiLineEntries(context: Context): List<List<Entry>> { fun multiLineEntries(context: Context): List<LineDataSet> {
val entries = mutableListOf<List<Entry>>() val dataSets = mutableListOf<LineDataSet>()
options.displayedStats.forEach { stat -> options.displayedStats.forEach { stat ->
this._results.forEach { result -> this._results.forEach { result ->
val dataSet = result.singleLineEntries(stat, context) dataSets.add(result.singleLineEntries(stat, context))
// entries.add(entryList)
} }
} }
return entries return dataSets
} }
} }
@ -424,7 +423,7 @@ class ComputedResults(group: ComputableGroup, shouldManageMultiGroupProgressValu
override val entryTitle: String = this.group.name override val entryTitle: String = this.group.name
override fun formattedValue(stat: Stat, context: Context): TextFormat { override fun formattedValue(stat: Stat): TextFormat {
this.computedStat(stat)?.let { this.computedStat(stat)?.let {
return it.format() return it.format()
} ?: run { } ?: run {

@ -1,10 +1,12 @@
package net.pokeranalytics.android.calculus package net.pokeranalytics.android.calculus
import android.content.Context import android.content.Context
import com.github.mikephil.charting.data.Entry
import net.pokeranalytics.android.R import net.pokeranalytics.android.R
import net.pokeranalytics.android.exceptions.FormattingException import net.pokeranalytics.android.exceptions.FormattingException
import net.pokeranalytics.android.model.interfaces.Timed import net.pokeranalytics.android.model.interfaces.Timed
import net.pokeranalytics.android.ui.graph.AxisFormatting import net.pokeranalytics.android.ui.graph.AxisFormatting
import net.pokeranalytics.android.ui.view.LegendView
import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType import net.pokeranalytics.android.ui.view.RowViewType
import net.pokeranalytics.android.util.NULL_TEXT import net.pokeranalytics.android.util.NULL_TEXT
@ -25,7 +27,23 @@ class ObjectIdentifier(var id: String, var clazz: Class<out Timed>) {
interface StatEntry { interface StatEntry {
val entryTitle: String val entryTitle: String
fun formattedValue(stat: Stat, context: Context): TextFormat fun formattedValue(stat: Stat): TextFormat
fun legendValues(stat: Stat, entry: Entry) : LegendView.Values {
return when (stat) {
Stat.NUMBER_OF_SETS, Stat.NUMBER_OF_GAMES -> {
val totalStatValue = stat.format(entry.y.toDouble(), currency = null)
LegendView.Values(this.entryTitle, totalStatValue)
}
else -> {
val entryValue = this.formattedValue(stat)
val totalStatValue = stat.format(entry.y.toDouble(), currency = null)
LegendView.Values(this.entryTitle, entryValue, totalStatValue)
}
}
}
} }
@ -239,7 +257,7 @@ enum class Stat : RowRepresentable {
val significantIndividualValue: Boolean val significantIndividualValue: Boolean
get() { get() {
return when (this) { return when (this) {
WIN_RATIO, NUMBER_OF_SETS, NUMBER_OF_GAMES -> false WIN_RATIO, NUMBER_OF_SETS, NUMBER_OF_GAMES, STANDARD_DEVIATION -> false
else -> true else -> true
} }
} }

@ -3,6 +3,7 @@ package net.pokeranalytics.android.model.realm
import io.realm.RealmObject import io.realm.RealmObject
import io.realm.annotations.Ignore import io.realm.annotations.Ignore
import io.realm.annotations.PrimaryKey import io.realm.annotations.PrimaryKey
import net.pokeranalytics.android.util.UserDefaults
import java.util.* import java.util.*
open class Currency : RealmObject() { open class Currency : RealmObject() {
@ -42,4 +43,10 @@ open class Currency : RealmObject() {
} }
} }
fun hasMainCurrencyCode() : Boolean {
this.code?.let { return it == UserDefaults.currency.currencyCode }
return false
}
} }

@ -1,6 +1,7 @@
package net.pokeranalytics.android.model.realm package net.pokeranalytics.android.model.realm
import android.content.Context import android.content.Context
import com.github.mikephil.charting.data.Entry
import io.realm.Realm import io.realm.Realm
import io.realm.RealmList import io.realm.RealmList
import io.realm.RealmObject import io.realm.RealmObject
@ -26,6 +27,7 @@ import net.pokeranalytics.android.model.interfaces.*
import net.pokeranalytics.android.model.utils.SessionSetManager import net.pokeranalytics.android.model.utils.SessionSetManager
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource
import net.pokeranalytics.android.ui.adapter.UnmanagedRowRepresentableException import net.pokeranalytics.android.ui.adapter.UnmanagedRowRepresentableException
import net.pokeranalytics.android.ui.view.LegendView
import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor
import net.pokeranalytics.android.ui.view.RowViewType import net.pokeranalytics.android.ui.view.RowViewType
@ -916,7 +918,7 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
return DateFormat.getDateInstance(DateFormat.SHORT).format(this.startDate) return DateFormat.getDateInstance(DateFormat.SHORT).format(this.startDate)
} }
override fun formattedValue(stat: Stat, context: Context): TextFormat { override fun formattedValue(stat: Stat): TextFormat {
this.result?.let { result -> this.result?.let { result ->
@ -956,6 +958,30 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
} }
override fun legendValues(stat: Stat, entry: Entry) : LegendView.Values {
return when (stat) {
Stat.STANDARD_DEVIATION -> {
val left = this.formattedValue(Stat.NET_RESULT)
val hasMainCurrencyCode = this.bankroll?.currency?.hasMainCurrencyCode() ?: false
var right: TextFormat? = null
if (!hasMainCurrencyCode) {
this.computableResult?.ratedNet?.let { ratedNet ->
right = Stat.NET_RESULT.format(ratedNet)
}
}
return LegendView.Values(this.entryTitle, left, right)
} else -> {
return super.legendValues(stat, entry)
}
}
}
// Timed // Timed
override val objectIdentifier: ObjectIdentifier override val objectIdentifier: ObjectIdentifier

@ -1,6 +1,5 @@
package net.pokeranalytics.android.model.realm package net.pokeranalytics.android.model.realm
import android.content.Context
import io.realm.Realm import io.realm.Realm
import io.realm.RealmObject import io.realm.RealmObject
import io.realm.RealmResults import io.realm.RealmResults
@ -118,7 +117,7 @@ open class SessionSet() : RealmObject(), Timed, Filterable {
return DateFormat.getDateInstance(DateFormat.SHORT).format(this.startDate) return DateFormat.getDateInstance(DateFormat.SHORT).format(this.startDate)
} }
override fun formattedValue(stat: Stat, context: Context) : TextFormat { override fun formattedValue(stat: Stat) : TextFormat {
return when (stat) { return when (stat) {
Stat.NET_RESULT, Stat.AVERAGE -> stat.format(this.ratedNet, currency = null) Stat.NET_RESULT, Stat.AVERAGE -> stat.format(this.ratedNet, currency = null)
Stat.DURATION, Stat.AVERAGE_DURATION -> stat.format(this.netDuration.toDouble(), currency = null) Stat.DURATION, Stat.AVERAGE_DURATION -> stat.format(this.netDuration.toDouble(), currency = null)

@ -153,11 +153,13 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener {
} }
statEntry?.let { statEntry?.let {
val formattedDate = it.entryTitle this.legendView.setItemData(it.legendValues(stat, entry))
val entryValue = it.formattedValue(this.stat, requireContext())
val totalStatValue = this.stat.format(entry.y.toDouble(), currency = null)
this.legendView.setItemData(this.stat, formattedDate, entryValue, totalStatValue) // val formattedDate = it.entryTitle
// val entryValue = it.formattedValue(this.stat, requireContext())
// val totalStatValue = this.stat.format(entry.y.toDouble(), currency = null)
//
// this.legendView.setItemData(this.stat, formattedDate, entryValue, totalStatValue)
} }
} }

@ -17,6 +17,8 @@ import net.pokeranalytics.android.ui.extensions.setTextFormat
*/ */
class LegendView : FrameLayout { class LegendView : FrameLayout {
class Values(var title: String, var leftFormat: TextFormat, var rightFormat: TextFormat? = null)
private lateinit var legendLayout: ConstraintLayout private lateinit var legendLayout: ConstraintLayout
/** /**
@ -66,17 +68,19 @@ class LegendView : FrameLayout {
/** /**
* *
*/ */
fun setItemData(stat: Stat, title: String, statFormat1: TextFormat, statFormat2: TextFormat) { fun setItemData(values: Values) {
this.title.text = title this.title.text = values.title
if (stat.significantIndividualValue) { this.stat1Value.setTextFormat(values.leftFormat, context)
this.stat1Value.setTextFormat(statFormat1, context) values.rightFormat?.let {
this.stat2Value.setTextFormat(statFormat2, context) this.stat2Value.setTextFormat(it, context)
} else {
this.stat1Value.setTextFormat(statFormat2, context)
} }
val showRightStat = values.rightFormat != null
this.stat2Name.isVisible = showRightStat
this.stat2Value.isVisible = showRightStat
} }
} }

@ -89,9 +89,9 @@ enum class RowViewType(private var layoutRes: Int) {
return when (this) { return when (this) {
// Row View Holder // Row View Holder
HEADER_TITLE, HEADER_TITLE_VALUE, HEADER_TITLE_AMOUNT, HEADER_TITLE_AMOUNT_BIG, HEADER_TITLE, HEADER_TITLE_VALUE, HEADER_TITLE_AMOUNT, HEADER_TITLE_AMOUNT_BIG, LOCATION_TITLE,
LOCATION_TITLE, INFO, INFO, TITLE, TITLE_ARROW, TITLE_ICON_ARROW, TITLE_VALUE, TITLE_VALUE_ARROW, TITLE_GRID,
TITLE, TITLE_ARROW, TITLE_ICON_ARROW, TITLE_VALUE, TITLE_VALUE_ARROW, TITLE_GRID, TITLE_SWITCH, TITLE_CHECK, TITLE_VALUE_CHECK, TITLE_SWITCH, TITLE_CHECK, TITLE_VALUE_CHECK,
DATA, BOTTOM_SHEET_DATA, LOADER -> RowViewHolder(layout) DATA, BOTTOM_SHEET_DATA, LOADER -> RowViewHolder(layout)
// Row Session // Row Session
@ -297,8 +297,6 @@ enum class RowViewType(private var layoutRes: Int) {
} }
} }
// Listener // Listener
val listener = View.OnClickListener { val listener = View.OnClickListener {
adapter.delegate?.onRowSelected(position, row) adapter.delegate?.onRowSelected(position, row)
@ -307,7 +305,6 @@ enum class RowViewType(private var layoutRes: Int) {
} }
} }
/** /**
* Display a stat * Display a stat
*/ */

Loading…
Cancel
Save