|
|
|
|
@ -13,13 +13,26 @@ import net.pokeranalytics.android.calculus.TextFormat |
|
|
|
|
import net.pokeranalytics.android.ui.extensions.setTextFormat |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.GraphFragment |
|
|
|
|
|
|
|
|
|
interface LegendContent |
|
|
|
|
|
|
|
|
|
data class DefaultLegendValues( |
|
|
|
|
var title: String, |
|
|
|
|
var leftFormat: TextFormat, |
|
|
|
|
var rightFormat: TextFormat? = null |
|
|
|
|
) : LegendContent |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Display a row session |
|
|
|
|
*/ |
|
|
|
|
open class LegendView : FrameLayout { |
|
|
|
|
|
|
|
|
|
open class Values(var title: String, var leftFormat: TextFormat, var rightFormat: TextFormat? = null) |
|
|
|
|
class MultiLineValues(var firstTitle: String, var secondTitle: String, leftFormat: TextFormat, rightFormat: TextFormat? = null) : Values("", leftFormat, rightFormat) |
|
|
|
|
// open class Values(var title: String, var leftFormat: TextFormat, var rightFormat: TextFormat? = null) |
|
|
|
|
// class MultiLineValues( |
|
|
|
|
// var firstTitle: String, |
|
|
|
|
// var secondTitle: String, |
|
|
|
|
// leftFormat: TextFormat, |
|
|
|
|
// rightFormat: TextFormat? = null |
|
|
|
|
// ) : Values("", leftFormat, rightFormat) |
|
|
|
|
|
|
|
|
|
private lateinit var legendLayout: ConstraintLayout |
|
|
|
|
|
|
|
|
|
@ -38,7 +51,7 @@ open class LegendView : FrameLayout { |
|
|
|
|
init() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
open protected fun getResourceLayout() : Int { |
|
|
|
|
open protected fun getResourceLayout(): Int { |
|
|
|
|
return R.layout.layout_legend_default |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -55,15 +68,15 @@ open class LegendView : FrameLayout { |
|
|
|
|
/** |
|
|
|
|
* Set the stat data to the view |
|
|
|
|
*/ |
|
|
|
|
open fun prepareWithStat(stat: Stat, counter: Int? = null, legendType: GraphFragment.LegendType) { |
|
|
|
|
open fun prepareWithStat(stat: Stat, counter: Int? = null, style: GraphFragment.Style) { |
|
|
|
|
|
|
|
|
|
when (legendType) { |
|
|
|
|
GraphFragment.LegendType.DEFAULT_BAR -> { |
|
|
|
|
when (style) { |
|
|
|
|
GraphFragment.Style.BAR -> { |
|
|
|
|
this.stat1Name.text = stat.localizedTitle(context) |
|
|
|
|
this.stat2Name.text = context.getString(R.string.sessions) |
|
|
|
|
this.counter.isVisible = false |
|
|
|
|
} |
|
|
|
|
GraphFragment.LegendType.DEFAULT -> { |
|
|
|
|
GraphFragment.Style.LINE -> { |
|
|
|
|
if (stat.significantIndividualValue) { |
|
|
|
|
this.stat1Name.text = stat.localizedTitle(context) |
|
|
|
|
this.stat2Name.text = stat.cumulativeLabelResId(context) |
|
|
|
|
@ -87,15 +100,20 @@ open class LegendView : FrameLayout { |
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
open fun setItemData(values: Values) { |
|
|
|
|
open fun setItemData(content: LegendContent) { |
|
|
|
|
|
|
|
|
|
if (content is DefaultLegendValues) { |
|
|
|
|
|
|
|
|
|
this.title.text = values.title |
|
|
|
|
this.title.text = content.title |
|
|
|
|
|
|
|
|
|
this.stat1Value.setTextFormat(content.leftFormat, context) |
|
|
|
|
content.rightFormat?.let { |
|
|
|
|
this.stat2Value.setTextFormat(it, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.stat1Value.setTextFormat(values.leftFormat, context) |
|
|
|
|
values.rightFormat?.let { |
|
|
|
|
this.stat2Value.setTextFormat(it, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |