|
|
|
@ -24,9 +24,11 @@ class GraphActivity : BaseActivity(), ViewModelHolder { |
|
|
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const val styleKey = "style" |
|
|
|
|
|
|
|
|
|
|
|
private var lineDataSets: List<LineDataSet>? = null |
|
|
|
private var lineDataSets: List<LineDataSet>? = null |
|
|
|
private var barDataSets: List<BarDataSet>? = null |
|
|
|
private var barDataSets: List<BarDataSet>? = null |
|
|
|
private var style: Graph.Style? = null |
|
|
|
// private var style: Graph.Style? = null |
|
|
|
private var activityTitle: String? = null |
|
|
|
private var activityTitle: String? = null |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
@ -34,10 +36,11 @@ class GraphActivity : BaseActivity(), ViewModelHolder { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun newLineInstance(context: Context, lineDataSets: List<LineDataSet>, title: String? = null) { |
|
|
|
fun newLineInstance(context: Context, lineDataSets: List<LineDataSet>, title: String? = null) { |
|
|
|
this.lineDataSets = lineDataSets |
|
|
|
this.lineDataSets = lineDataSets |
|
|
|
this.style = Graph.Style.LINE |
|
|
|
// this.style = Graph.Style.LINE |
|
|
|
this.activityTitle = title |
|
|
|
this.activityTitle = title |
|
|
|
|
|
|
|
|
|
|
|
val intent = Intent(context, GraphActivity::class.java) |
|
|
|
val intent = Intent(context, GraphActivity::class.java) |
|
|
|
|
|
|
|
intent.putExtra(styleKey, Graph.Style.LINE.ordinal) |
|
|
|
context.startActivity(intent) |
|
|
|
context.startActivity(intent) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -46,10 +49,11 @@ class GraphActivity : BaseActivity(), ViewModelHolder { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun newBarInstance(context: Context, barDataSets: List<BarDataSet>, title: String? = null) { |
|
|
|
fun newBarInstance(context: Context, barDataSets: List<BarDataSet>, title: String? = null) { |
|
|
|
this.barDataSets = barDataSets |
|
|
|
this.barDataSets = barDataSets |
|
|
|
this.style = Graph.Style.BAR |
|
|
|
// this.style = Graph.Style.BAR |
|
|
|
this.activityTitle = title |
|
|
|
this.activityTitle = title |
|
|
|
|
|
|
|
|
|
|
|
val intent = Intent(context, GraphActivity::class.java) |
|
|
|
val intent = Intent(context, GraphActivity::class.java) |
|
|
|
|
|
|
|
intent.putExtra(styleKey, Graph.Style.BAR.ordinal) |
|
|
|
context.startActivity(intent) |
|
|
|
context.startActivity(intent) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -93,11 +97,14 @@ class GraphActivity : BaseActivity(), ViewModelHolder { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
style?.let { |
|
|
|
val styleIndex = this.intent.getIntExtra(styleKey, -1) |
|
|
|
this.model.style = it |
|
|
|
val style = Graph.Style.values()[styleIndex] |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val style = style ?: this.model.style ?: throw PAIllegalStateException("Graph style not defined") |
|
|
|
// style?.let { |
|
|
|
|
|
|
|
// this.model.style = it |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// val style = style ?: this.model.style ?: throw PAIllegalStateException("Graph style not defined") |
|
|
|
|
|
|
|
|
|
|
|
val fragmentTransaction = supportFragmentManager.beginTransaction() |
|
|
|
val fragmentTransaction = supportFragmentManager.beginTransaction() |
|
|
|
val graphFragment = GraphFragment.newInstance(style) |
|
|
|
val graphFragment = GraphFragment.newInstance(style) |
|
|
|
|