parent
9a5f343626
commit
250c41cde5
@ -0,0 +1,37 @@ |
||||
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.calculus.TextFormat |
||||
import net.pokeranalytics.android.ui.fragment.GraphFragment |
||||
import net.pokeranalytics.android.ui.view.LegendView |
||||
|
||||
interface GraphUnderlyingEntry { |
||||
|
||||
val entryTitle: String |
||||
fun formattedValue(stat: Stat): TextFormat |
||||
|
||||
fun legendValues( |
||||
stat: Stat, |
||||
entry: Entry, |
||||
legendType: GraphFragment.LegendType, |
||||
groupName: String, |
||||
context: Context |
||||
): LegendView.Values { |
||||
|
||||
return when (stat) { |
||||
Stat.NUMBER_OF_SETS, Stat.NUMBER_OF_GAMES, Stat.WIN_RATIO -> { |
||||
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) |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,32 @@ |
||||
package net.pokeranalytics.android.ui.view |
||||
|
||||
import android.content.Context |
||||
import kotlinx.android.synthetic.main.layout_legend_default.view.* |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.calculus.Stat |
||||
import net.pokeranalytics.android.ui.extensions.setTextFormat |
||||
import net.pokeranalytics.android.ui.fragment.GraphFragment |
||||
|
||||
class MultiLineLegendView(context: Context) : LegendView(context = context) { |
||||
|
||||
override fun getResourceLayout(): Int { |
||||
return R.layout.layout_legend_color |
||||
} |
||||
|
||||
override fun prepareWithStat(stat: Stat, counter: Int?, legendType: GraphFragment.LegendType) { |
||||
} |
||||
|
||||
override fun setItemData(values: Values) { |
||||
|
||||
if (values is MultiLineValues) { |
||||
|
||||
this.stat1Name.text = values.firstTitle |
||||
this.stat2Name.text = values.secondTitle |
||||
|
||||
this.stat1Value.setTextFormat(values.leftFormat, context) |
||||
this.stat2Value.text = values.title |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue