diff --git a/app/src/main/java/net/pokeranalytics/android/ui/fragment/GraphFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/fragment/GraphFragment.kt index 40484a78..a9b845d4 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/fragment/GraphFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/fragment/GraphFragment.kt @@ -55,14 +55,24 @@ class GraphFragment : RealmFragment(), OnChartValueSelectedListener { return this.graphDataProvider.stat } - private var _defaultStyle: Graph.Style? = null - /*** * Uses forced style first, or the style set */ private val style: Graph.Style get() { - return this.graphDataProvider.style ?: this._defaultStyle ?: throw PAIllegalStateException("Graph style undefined") + val style = this.graphDataProvider.style + if (style != null) { + return style + } + + this.arguments?.let { bundle -> + if (bundle.containsKey(BundleKey.STYLE.value)) { + val styleIndex = bundle.getInt(BundleKey.STYLE.value) + return Graph.Style.values()[styleIndex] + } else { + throw PAIllegalStateException("Style not defined for $this") + } + } ?: throw PAIllegalStateException("Style and bundle not defined for $this") } private lateinit var legendView: LegendView @@ -93,13 +103,6 @@ class GraphFragment : RealmFragment(), OnChartValueSelectedListener { } private fun initData() { - - this.arguments?.let { bundle -> - if (bundle.containsKey(BundleKey.STYLE.value)) { - this._defaultStyle = Graph.Style.values()[bundle.getInt(BundleKey.STYLE.value)] - } - } - this.graphDataProvider = (requireActivity() as ViewModelHolder).model as GraphDataProvider }