Fixes crashes

split
Laurent 5 years ago
parent 2652309e0b
commit d377072158
  1. 16
      app/src/main/java/net/pokeranalytics/android/ui/view/LegendView.kt
  2. 3
      app/src/main/res/layout/fragment_report_details.xml

@ -58,10 +58,8 @@ open class LegendView : FrameLayout {
protected lateinit var stat1Name: TextView protected lateinit var stat1Name: TextView
protected lateinit var stat2Name: TextView protected lateinit var stat2Name: TextView
protected lateinit var counter: TextView
protected lateinit var stat1Value: TextView protected lateinit var stat1Value: TextView
protected lateinit var stat2Value: TextView protected lateinit var stat2Value: TextView
protected lateinit var title: TextView
/** /**
* Init * Init
@ -74,10 +72,8 @@ open class LegendView : FrameLayout {
this.stat1Name = legendLayout.findViewById(R.id.stat1Name) this.stat1Name = legendLayout.findViewById(R.id.stat1Name)
this.stat2Name = legendLayout.findViewById(R.id.stat2Name) this.stat2Name = legendLayout.findViewById(R.id.stat2Name)
this.counter = legendLayout.findViewById(R.id.counter)
this.stat1Value = legendLayout.findViewById(R.id.stat1Value) this.stat1Value = legendLayout.findViewById(R.id.stat1Value)
this.stat2Value = legendLayout.findViewById(R.id.stat2Value) this.stat2Value = legendLayout.findViewById(R.id.stat2Value)
this.title = legendLayout.findViewById(R.id.title)
} }
@ -90,7 +86,9 @@ open class LegendView : FrameLayout {
Graph.Style.BAR -> { Graph.Style.BAR -> {
this.stat1Name.text = stat.localizedTitle(context) this.stat1Name.text = stat.localizedTitle(context)
this.stat2Name.text = context.getString(R.string.sessions) this.stat2Name.text = context.getString(R.string.sessions)
this.counter.isVisible = false
val count = legendLayout.findViewById<TextView>(R.id.counter)
count.isVisible = false
} }
Graph.Style.LINE -> { Graph.Style.LINE -> {
if (stat.graphSignificantIndividualValue) { if (stat.graphSignificantIndividualValue) {
@ -103,8 +101,9 @@ open class LegendView : FrameLayout {
counter?.let { counter?.let {
val counterText = "$it ${context.getString(R.string.points)}" val counterText = "$it ${context.getString(R.string.points)}"
this.counter.text = counterText val count = legendLayout.findViewById<TextView>(R.id.counter)
this.counter.isVisible = stat.graphShouldShowNumberOfSessions count.text = counterText
count.isVisible = stat.graphShouldShowNumberOfSessions
} }
} }
else -> { else -> {
@ -120,7 +119,8 @@ open class LegendView : FrameLayout {
if (content is DefaultLegendValues) { if (content is DefaultLegendValues) {
this.title.text = content.title.capitalize() val title = legendLayout.findViewById<TextView>(R.id.title)
title.text = content.title.capitalize()
this.stat1Value.setTextFormat(content.leftFormat, context) this.stat1Value.setTextFormat(content.leftFormat, context)

@ -29,19 +29,16 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<com.google.android.material.tabs.TabItem <com.google.android.material.tabs.TabItem
android:id="@+id/tabBar"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/bars" /> android:text="@string/bars" />
<com.google.android.material.tabs.TabItem <com.google.android.material.tabs.TabItem
android:id="@+id/tabLine"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/lines" /> android:text="@string/lines" />
<com.google.android.material.tabs.TabItem <com.google.android.material.tabs.TabItem
android:id="@+id/tabTable"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/table" /> android:text="@string/table" />

Loading…
Cancel
Save