|
|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
package net.pokeranalytics.android.ui.fragment |
|
|
|
|
package net.pokeranalytics.android.ui.fragment.report |
|
|
|
|
|
|
|
|
|
import android.os.Bundle |
|
|
|
|
import android.view.LayoutInflater |
|
|
|
|
@ -16,27 +16,30 @@ import kotlinx.coroutines.Dispatchers |
|
|
|
|
import kotlinx.coroutines.GlobalScope |
|
|
|
|
import kotlinx.coroutines.launch |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.calculus.* |
|
|
|
|
import net.pokeranalytics.android.calculus.AggregationType |
|
|
|
|
import net.pokeranalytics.android.calculus.Calculator |
|
|
|
|
import net.pokeranalytics.android.calculus.Report |
|
|
|
|
import net.pokeranalytics.android.calculus.Stat |
|
|
|
|
import net.pokeranalytics.android.model.combined |
|
|
|
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
|
|
|
|
import net.pokeranalytics.android.ui.extensions.ChipGroupExtension |
|
|
|
|
import net.pokeranalytics.android.ui.extensions.hideWithAnimation |
|
|
|
|
import net.pokeranalytics.android.ui.extensions.px |
|
|
|
|
import net.pokeranalytics.android.ui.extensions.showWithAnimation |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.GraphFragment |
|
|
|
|
import timber.log.Timber |
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class StatisticDetailsFragment : PokerAnalyticsFragment() { |
|
|
|
|
class ProgressReportFragment : AbstractReportFragment() { |
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create new instance |
|
|
|
|
* Creates new instance |
|
|
|
|
*/ |
|
|
|
|
fun newInstance(): StatisticDetailsFragment { |
|
|
|
|
val fragment = StatisticDetailsFragment() |
|
|
|
|
fun newInstance(): ProgressReportFragment { |
|
|
|
|
val fragment = ProgressReportFragment() |
|
|
|
|
val bundle = Bundle() |
|
|
|
|
fragment.arguments = bundle |
|
|
|
|
return fragment |
|
|
|
|
@ -44,9 +47,7 @@ class StatisticDetailsFragment : PokerAnalyticsFragment() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private lateinit var parentActivity: PokerAnalyticsActivity |
|
|
|
|
private lateinit var computableGroup: ComputableGroup |
|
|
|
|
private lateinit var graphFragment: GraphFragment |
|
|
|
|
private lateinit var selectedReport: Report |
|
|
|
|
|
|
|
|
|
private var title: String? = null |
|
|
|
|
private var reports: MutableMap<AggregationType, Report> = hashMapOf() |
|
|
|
|
@ -54,6 +55,7 @@ class StatisticDetailsFragment : PokerAnalyticsFragment() { |
|
|
|
|
private var displayAggregationChoices: Boolean = true |
|
|
|
|
|
|
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
|
|
|
|
super.onCreateView(inflater, container, savedInstanceState) |
|
|
|
|
return inflater.inflate(R.layout.fragment_statistic_details, container, false) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -65,9 +67,8 @@ class StatisticDetailsFragment : PokerAnalyticsFragment() { |
|
|
|
|
/** |
|
|
|
|
* Set data |
|
|
|
|
*/ |
|
|
|
|
fun setData(stat: Stat, computableGroup: ComputableGroup, report: Report, displayAggregationChoices: Boolean, title: String? = null) { |
|
|
|
|
fun setData(stat: Stat, report: Report, displayAggregationChoices: Boolean, title: String? = null) { |
|
|
|
|
this.stat = stat |
|
|
|
|
this.computableGroup = computableGroup |
|
|
|
|
this.selectedReport = report |
|
|
|
|
this.displayAggregationChoices = displayAggregationChoices |
|
|
|
|
this.title = title |
|
|
|
|
@ -91,7 +92,6 @@ class StatisticDetailsFragment : PokerAnalyticsFragment() { |
|
|
|
|
parentActivity.supportActionBar?.setDisplayHomeAsUpEnabled(true) |
|
|
|
|
setHasOptionsMenu(true) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val fragmentManager = parentActivity.supportFragmentManager |
|
|
|
|
val fragmentTransaction = fragmentManager.beginTransaction() |
|
|
|
|
graphFragment = GraphFragment() |
|
|
|
|
@ -168,7 +168,9 @@ class StatisticDetailsFragment : PokerAnalyticsFragment() { |
|
|
|
|
|
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
|
|
|
|
|
val report = Calculator.computeStatsWithEvolutionByAggregationType(realm, stat, computableGroup, aggregationType) |
|
|
|
|
val group = selectedReport.results.first().group |
|
|
|
|
|
|
|
|
|
val report = Calculator.computeStatsWithEvolutionByAggregationType(realm, stat, group, aggregationType) |
|
|
|
|
reports[aggregationType] = report |
|
|
|
|
|
|
|
|
|
realm.close() |