diff --git a/app/src/main/java/net/pokeranalytics/android/ui/view/LegendView.kt b/app/src/main/java/net/pokeranalytics/android/ui/view/LegendView.kt index 14d18c8a..04bc12f9 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/view/LegendView.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/view/LegendView.kt @@ -4,9 +4,9 @@ import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.widget.FrameLayout +import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.isVisible -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 @@ -35,7 +35,7 @@ open class LegendView : FrameLayout { // rightFormat: TextFormat? = null // ) : Values("", leftFormat, rightFormat) - private lateinit var legendLayout: ConstraintLayout + protected lateinit var legendLayout: ConstraintLayout /** * Constructors @@ -56,14 +56,29 @@ open class LegendView : FrameLayout { return R.layout.layout_legend_default } + protected lateinit var stat1Name: TextView + protected lateinit var stat2Name: TextView + protected lateinit var counter: TextView + protected lateinit var stat1Value: TextView + protected lateinit var stat2Value: TextView + protected lateinit var title: TextView + /** * Init */ - private fun init() { + protected open fun init() { val layoutInflater = LayoutInflater.from(context) legendLayout = layoutInflater.inflate(this.getResourceLayout(), this, false) as ConstraintLayout val layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT) addView(legendLayout, layoutParams) + + this.stat1Name = legendLayout.findViewById(R.id.stat1Name) + this.stat2Name = legendLayout.findViewById(R.id.stat2Name) + this.counter = legendLayout.findViewById(R.id.counter) + this.stat1Value = legendLayout.findViewById(R.id.stat1Value) + this.stat2Value = legendLayout.findViewById(R.id.stat2Value) + this.title = legendLayout.findViewById(R.id.title) + } /** diff --git a/app/src/main/java/net/pokeranalytics/android/ui/view/MultiLineLegendView.kt b/app/src/main/java/net/pokeranalytics/android/ui/view/MultiLineLegendView.kt index 42016bb6..0c678dae 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/view/MultiLineLegendView.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/view/MultiLineLegendView.kt @@ -2,16 +2,12 @@ package net.pokeranalytics.android.ui.view import android.content.Context import android.graphics.drawable.GradientDrawable -import kotlinx.android.synthetic.main.layout_legend_color.view.* -import kotlinx.android.synthetic.main.layout_legend_default.view.stat1Name -import kotlinx.android.synthetic.main.layout_legend_default.view.stat1Value -import kotlinx.android.synthetic.main.layout_legend_default.view.stat2Name -import kotlinx.android.synthetic.main.layout_legend_default.view.stat2Value +import android.view.View import net.pokeranalytics.android.R import net.pokeranalytics.android.calculus.Stat -import net.pokeranalytics.android.util.TextFormat import net.pokeranalytics.android.ui.extensions.setTextFormat import net.pokeranalytics.android.ui.fragment.GraphFragment +import net.pokeranalytics.android.util.TextFormat data class MultilineLegendValues( var firstTitle: String, @@ -22,6 +18,13 @@ data class MultilineLegendValues( class MultiLineLegendView(context: Context) : LegendView(context = context) { + private lateinit var coloredCircle: View + + override fun init() { + super.init() + this.coloredCircle = legendLayout.findViewById(R.id.coloredCircle) + } + override fun getResourceLayout(): Int { return R.layout.layout_legend_color }