|
|
|
@ -14,9 +14,9 @@ import com.github.mikephil.charting.highlight.Highlight |
|
|
|
import com.github.mikephil.charting.listener.OnChartValueSelectedListener |
|
|
|
import com.github.mikephil.charting.listener.OnChartValueSelectedListener |
|
|
|
import com.google.android.material.chip.Chip |
|
|
|
import com.google.android.material.chip.Chip |
|
|
|
import com.google.android.material.chip.ChipGroup |
|
|
|
import com.google.android.material.chip.ChipGroup |
|
|
|
import io.realm.Realm |
|
|
|
|
|
|
|
import kotlinx.android.synthetic.main.fragment_graph.* |
|
|
|
import kotlinx.android.synthetic.main.fragment_graph.* |
|
|
|
import kotlinx.coroutines.* |
|
|
|
import kotlinx.coroutines.CoroutineScope |
|
|
|
|
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.calculus.* |
|
|
|
import net.pokeranalytics.android.calculus.* |
|
|
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
|
|
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
|
|
|
@ -26,9 +26,7 @@ import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
|
|
|
import net.pokeranalytics.android.ui.graph.PALineDataSet |
|
|
|
import net.pokeranalytics.android.ui.graph.PALineDataSet |
|
|
|
import net.pokeranalytics.android.ui.graph.setStyle |
|
|
|
import net.pokeranalytics.android.ui.graph.setStyle |
|
|
|
import net.pokeranalytics.android.ui.view.LegendView |
|
|
|
import net.pokeranalytics.android.ui.view.LegendView |
|
|
|
import timber.log.Timber |
|
|
|
|
|
|
|
import java.text.DateFormat |
|
|
|
import java.text.DateFormat |
|
|
|
import java.util.* |
|
|
|
|
|
|
|
import kotlin.coroutines.CoroutineContext |
|
|
|
import kotlin.coroutines.CoroutineContext |
|
|
|
|
|
|
|
|
|
|
|
class GraphParameters(var stat: Stat, var computableGroup: ComputableGroup, var report: Report) { |
|
|
|
class GraphParameters(var stat: Stat, var computableGroup: ComputableGroup, var report: Report) { |
|
|
|
@ -37,15 +35,28 @@ class GraphParameters(var stat: Stat, var computableGroup: ComputableGroup, var |
|
|
|
|
|
|
|
|
|
|
|
class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, CoroutineScope { |
|
|
|
class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, CoroutineScope { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Create new instance |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun newInstance(): GraphFragment { |
|
|
|
|
|
|
|
val fragment = GraphFragment() |
|
|
|
|
|
|
|
val bundle = Bundle() |
|
|
|
|
|
|
|
fragment.arguments = bundle |
|
|
|
|
|
|
|
return fragment |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private lateinit var parentActivity: PokerAnalyticsActivity |
|
|
|
private lateinit var parentActivity: PokerAnalyticsActivity |
|
|
|
|
|
|
|
|
|
|
|
private var stat: Stat = Stat.NETRESULT |
|
|
|
private var stat: Stat = Stat.NETRESULT |
|
|
|
private var reports: MutableMap<AggregationType, Report> = hashMapOf() |
|
|
|
private var reports: MutableMap<AggregationType, Report> = hashMapOf() |
|
|
|
|
|
|
|
|
|
|
|
private lateinit var computableGroup: ComputableGroup |
|
|
|
private var computableGroup: ComputableGroup? = null |
|
|
|
private lateinit var selectedReport: Report |
|
|
|
private var selectedReport: Report? = null |
|
|
|
private lateinit var legendView: LegendView |
|
|
|
private var legendView: LegendView? = null |
|
|
|
private lateinit var chartView: BarLineChartBase<*> |
|
|
|
private var chartView: BarLineChartBase<*>? = null |
|
|
|
|
|
|
|
|
|
|
|
private var displayAggregationChoices: Boolean = true |
|
|
|
private var displayAggregationChoices: Boolean = true |
|
|
|
private var aggregationTypes: List<AggregationType> = listOf() |
|
|
|
private var aggregationTypes: List<AggregationType> = listOf() |
|
|
|
@ -60,7 +71,11 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co |
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
initUI() |
|
|
|
initUI() |
|
|
|
loadGraph(selectedReport) |
|
|
|
|
|
|
|
|
|
|
|
selectedReport?.let { |
|
|
|
|
|
|
|
loadGraph(it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// OnChartValueSelectedListener |
|
|
|
// OnChartValueSelectedListener |
|
|
|
@ -78,7 +93,7 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co |
|
|
|
val entryValue = it.formattedValue(this.stat, requireContext()) |
|
|
|
val entryValue = it.formattedValue(this.stat, requireContext()) |
|
|
|
val totalStatValue = this.stat.format(e.y.toDouble(), currency = null, context = requireContext()) |
|
|
|
val totalStatValue = this.stat.format(e.y.toDouble(), currency = null, context = requireContext()) |
|
|
|
|
|
|
|
|
|
|
|
this.legendView.setItemData(this.stat, formattedDate, entryValue, totalStatValue) |
|
|
|
this.legendView?.setItemData(this.stat, formattedDate, entryValue, totalStatValue) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -122,6 +137,7 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
private fun launchStatComputation() { |
|
|
|
private fun launchStatComputation() { |
|
|
|
|
|
|
|
|
|
|
|
GlobalScope.launch(coroutineContext) { |
|
|
|
GlobalScope.launch(coroutineContext) { |
|
|
|
@ -151,8 +167,8 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Load graph |
|
|
|
* Load graph |
|
|
|
@ -161,7 +177,7 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co |
|
|
|
|
|
|
|
|
|
|
|
report.results.firstOrNull()?.defaultStatEntries(stat)?.let { entries -> |
|
|
|
report.results.firstOrNull()?.defaultStatEntries(stat)?.let { entries -> |
|
|
|
|
|
|
|
|
|
|
|
this.legendView.prepareWithStat(this.stat, entries.size) |
|
|
|
this.legendView?.prepareWithStat(this.stat, entries.size) |
|
|
|
|
|
|
|
|
|
|
|
val dataSet = PALineDataSet(entries, this.stat.name, requireContext()) |
|
|
|
val dataSet = PALineDataSet(entries, this.stat.name, requireContext()) |
|
|
|
val colors = arrayOf(R.color.green_light).toIntArray() |
|
|
|
val colors = arrayOf(R.color.green_light).toIntArray() |
|
|
|
@ -184,10 +200,9 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co |
|
|
|
|
|
|
|
|
|
|
|
this.chartContainer.addView(this.chartView) |
|
|
|
this.chartContainer.addView(this.chartView) |
|
|
|
|
|
|
|
|
|
|
|
this.chartView.setStyle(false, requireContext()) |
|
|
|
this.chartView?.setStyle(false, requireContext()) |
|
|
|
this.chartView.setOnChartValueSelectedListener(this) |
|
|
|
this.chartView?.setOnChartValueSelectedListener(this) |
|
|
|
|
|
|
|
this.chartView?.highlightValue((entries.size - 1).toFloat(), 0) |
|
|
|
this.chartView.highlightValue((entries.size - 1).toFloat(), 0) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|