|
|
|
@ -19,11 +19,11 @@ import net.pokeranalytics.android.calculus.ComputedResults |
|
|
|
import net.pokeranalytics.android.calculus.Stat |
|
|
|
import net.pokeranalytics.android.calculus.Stat |
|
|
|
import net.pokeranalytics.android.model.comparison.Comparator |
|
|
|
import net.pokeranalytics.android.model.comparison.Comparator |
|
|
|
import net.pokeranalytics.android.model.filter.QueryCondition |
|
|
|
import net.pokeranalytics.android.model.filter.QueryCondition |
|
|
|
import net.pokeranalytics.android.ui.activity.CalendarDetailsActivity |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
|
|
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter |
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter |
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
|
|
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource |
|
|
|
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.extensions.toast |
|
|
|
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
|
|
|
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
import net.pokeranalytics.android.ui.view.RowViewType |
|
|
|
@ -46,6 +46,7 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable |
|
|
|
private lateinit var parentActivity: PokerAnalyticsActivity |
|
|
|
private lateinit var parentActivity: PokerAnalyticsActivity |
|
|
|
private lateinit var statsAdapter: RowRepresentableAdapter |
|
|
|
private lateinit var statsAdapter: RowRepresentableAdapter |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var title: String? = "" |
|
|
|
private var computedResults: ComputedResults? = null |
|
|
|
private var computedResults: ComputedResults? = null |
|
|
|
private var sessionTypeCondition: QueryCondition? = null |
|
|
|
private var sessionTypeCondition: QueryCondition? = null |
|
|
|
private var rowRepresentables: ArrayList<RowRepresentable> = ArrayList() |
|
|
|
private var rowRepresentables: ArrayList<RowRepresentable> = ArrayList() |
|
|
|
@ -59,9 +60,7 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable |
|
|
|
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
initData() |
|
|
|
|
|
|
|
initUI() |
|
|
|
initUI() |
|
|
|
launchStatComputation() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun adapterRows(): List<RowRepresentable>? { |
|
|
|
override fun adapterRows(): List<RowRepresentable>? { |
|
|
|
@ -69,24 +68,14 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
|
|
|
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
|
|
|
when(row) { |
|
|
|
when (row) { |
|
|
|
is GraphRow -> { |
|
|
|
is GraphRow -> { |
|
|
|
//TODO: Open graph details |
|
|
|
//TODO: Open graph details |
|
|
|
|
|
|
|
toast("Open graph details") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Init data |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun initData() { |
|
|
|
|
|
|
|
Timber.d("initData") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.computedResults = CalendarDetailsActivity.computedResults |
|
|
|
|
|
|
|
this.sessionTypeCondition = CalendarDetailsActivity.sessionTypeCondition |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Init UI |
|
|
|
* Init UI |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -101,11 +90,10 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable |
|
|
|
parentActivity.supportActionBar?.setDisplayHomeAsUpEnabled(true) |
|
|
|
parentActivity.supportActionBar?.setDisplayHomeAsUpEnabled(true) |
|
|
|
setHasOptionsMenu(true) |
|
|
|
setHasOptionsMenu(true) |
|
|
|
|
|
|
|
|
|
|
|
toolbar.title = CalendarDetailsActivity.title |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { |
|
|
|
tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { |
|
|
|
override fun onTabSelected(tab: TabLayout.Tab) { |
|
|
|
override fun onTabSelected(tab: TabLayout.Tab) { |
|
|
|
when(tab.position) { |
|
|
|
when (tab.position) { |
|
|
|
0 -> sessionTypeCondition = null |
|
|
|
0 -> sessionTypeCondition = null |
|
|
|
1 -> sessionTypeCondition = QueryCondition.CASH |
|
|
|
1 -> sessionTypeCondition = QueryCondition.CASH |
|
|
|
2 -> sessionTypeCondition = QueryCondition.TOURNAMENT |
|
|
|
2 -> sessionTypeCondition = QueryCondition.TOURNAMENT |
|
|
|
@ -120,15 +108,6 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
sessionTypeCondition?.let { |
|
|
|
|
|
|
|
when(it) { |
|
|
|
|
|
|
|
QueryCondition.CASH -> tabs.getTabAt(1)?.select() |
|
|
|
|
|
|
|
QueryCondition.TOURNAMENT -> tabs.getTabAt(2)?.select() |
|
|
|
|
|
|
|
else -> tabs.getTabAt(0)?.select() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
statsAdapter = RowRepresentableAdapter(this, this) |
|
|
|
statsAdapter = RowRepresentableAdapter(this, this) |
|
|
|
|
|
|
|
|
|
|
|
val viewManager = LinearLayoutManager(requireContext()) |
|
|
|
val viewManager = LinearLayoutManager(requireContext()) |
|
|
|
@ -142,7 +121,26 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* |
|
|
|
* Display data |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun displayData() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
title?.let { |
|
|
|
|
|
|
|
toolbar.title = it |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sessionTypeCondition?.let { |
|
|
|
|
|
|
|
when (it) { |
|
|
|
|
|
|
|
QueryCondition.CASH -> tabs.getTabAt(1)?.select() |
|
|
|
|
|
|
|
QueryCondition.TOURNAMENT -> tabs.getTabAt(2)?.select() |
|
|
|
|
|
|
|
else -> tabs.getTabAt(0)?.select() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Launch stat computation |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun launchStatComputation() { |
|
|
|
private fun launchStatComputation() { |
|
|
|
|
|
|
|
|
|
|
|
@ -166,18 +164,22 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable |
|
|
|
|
|
|
|
|
|
|
|
Timber.d("Report take: ${System.currentTimeMillis() - startDate.time}ms") |
|
|
|
Timber.d("Report take: ${System.currentTimeMillis() - startDate.time}ms") |
|
|
|
|
|
|
|
|
|
|
|
rowRepresentables.clear() |
|
|
|
report.results.firstOrNull()?.let { |
|
|
|
rowRepresentables.add(CustomizableRowRepresentable(RowViewType.HEADER_TITLE, resId = R.string.net_result)) |
|
|
|
|
|
|
|
rowRepresentables.add(GraphRow(report, Stat.NETRESULT)) |
|
|
|
rowRepresentables.clear() |
|
|
|
rowRepresentables.add(StatDoubleRow(computedResults.computedStat(Stat.NETRESULT), computedResults.computedStat(Stat.HOURLY_RATE))) |
|
|
|
rowRepresentables.add(CustomizableRowRepresentable(RowViewType.HEADER_TITLE, resId = R.string.net_result)) |
|
|
|
rowRepresentables.add(StatDoubleRow(computedResults.computedStat(Stat.LOCATIONS_PLAYED), computedResults.computedStat(Stat.LONGEST_STREAKS))) |
|
|
|
rowRepresentables.add(GraphRow(report, Stat.NETRESULT)) |
|
|
|
rowRepresentables.add(CustomizableRowRepresentable(RowViewType.HEADER_TITLE, resId = R.string.distribution)) |
|
|
|
rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.NETRESULT), it.computedStat(Stat.HOURLY_RATE))) |
|
|
|
rowRepresentables.add(GraphRow(report, Stat.NETRESULT)) |
|
|
|
rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.LOCATIONS_PLAYED), it.computedStat(Stat.LONGEST_STREAKS))) |
|
|
|
rowRepresentables.add(StatDoubleRow(computedResults.computedStat(Stat.WIN_RATIO), computedResults.computedStat(Stat.MAXIMUM_NETRESULT))) |
|
|
|
rowRepresentables.add(CustomizableRowRepresentable(RowViewType.HEADER_TITLE, resId = R.string.distribution)) |
|
|
|
rowRepresentables.add(CustomizableRowRepresentable(RowViewType.HEADER_TITLE, resId = R.string.volume)) |
|
|
|
rowRepresentables.add(GraphRow(report, Stat.NETRESULT)) |
|
|
|
rowRepresentables.add(GraphRow(report, Stat.NETRESULT)) |
|
|
|
rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.WIN_RATIO), it.computedStat(Stat.MAXIMUM_NETRESULT))) |
|
|
|
rowRepresentables.add(StatDoubleRow(computedResults.computedStat(Stat.DURATION), computedResults.computedStat(Stat.AVERAGE_DURATION))) |
|
|
|
rowRepresentables.add(CustomizableRowRepresentable(RowViewType.HEADER_TITLE, resId = R.string.volume)) |
|
|
|
rowRepresentables.add(StatDoubleRow(computedResults.computedStat(Stat.DAYS_PLAYED), computedResults.computedStat(Stat.MAXIMUM_DURATION))) |
|
|
|
rowRepresentables.add(GraphRow(report, Stat.NETRESULT)) |
|
|
|
|
|
|
|
rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.DURATION), it.computedStat(Stat.AVERAGE_DURATION))) |
|
|
|
|
|
|
|
rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.DAYS_PLAYED), it.computedStat(Stat.MAXIMUM_DURATION))) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
launch(Dispatchers.Main) { |
|
|
|
launch(Dispatchers.Main) { |
|
|
|
statsAdapter.notifyDataSetChanged() |
|
|
|
statsAdapter.notifyDataSetChanged() |
|
|
|
@ -189,10 +191,16 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set data |
|
|
|
* Set data |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun setData(computedResults: ComputedResults?, sessionTypeCondition: QueryCondition?) { |
|
|
|
fun setData(computedResults: ComputedResults?, sessionTypeCondition: QueryCondition?, title: String?) { |
|
|
|
Timber.d("Set data") |
|
|
|
Timber.d("Set data") |
|
|
|
//this.stat = stat |
|
|
|
|
|
|
|
//this.entries = entries |
|
|
|
this.computedResults = computedResults |
|
|
|
|
|
|
|
this.sessionTypeCondition = sessionTypeCondition |
|
|
|
|
|
|
|
this.title = title |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
displayData() |
|
|
|
|
|
|
|
launchStatComputation() |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |