|
|
|
|
@ -52,8 +52,19 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable |
|
|
|
|
private var sessionTypeCondition: QueryCondition? = null |
|
|
|
|
private var rowRepresentables: ArrayList<RowRepresentable> = ArrayList() |
|
|
|
|
|
|
|
|
|
//private var stat: Stat = Stat.NET_RESULT |
|
|
|
|
//private var entries: List<Entry> = ArrayList() |
|
|
|
|
/** |
|
|
|
|
* Set data |
|
|
|
|
*/ |
|
|
|
|
fun setData(computedResults: ComputedResults?, sessionTypeCondition: QueryCondition?, title: String?) { |
|
|
|
|
|
|
|
|
|
this.computedResults = computedResults |
|
|
|
|
this.sessionTypeCondition = sessionTypeCondition |
|
|
|
|
this.title = title |
|
|
|
|
|
|
|
|
|
displayData() |
|
|
|
|
launchStatComputation() |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { |
|
|
|
|
return inflater.inflate(R.layout.fragment_calendar_details, container, false) |
|
|
|
|
@ -64,21 +75,6 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable |
|
|
|
|
initUI() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun adapterRows(): List<RowRepresentable>? { |
|
|
|
|
return rowRepresentables |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
|
|
|
|
when (row) { |
|
|
|
|
is GraphRow -> { |
|
|
|
|
//TODO: Open graph details |
|
|
|
|
row.report.results.firstOrNull()?.group?.let { computableGroup -> |
|
|
|
|
StatisticDetailsActivity.newInstance(requireContext(), row.stat, computableGroup, row.report, false) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Init UI |
|
|
|
|
*/ |
|
|
|
|
@ -93,6 +89,16 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable |
|
|
|
|
parentActivity.supportActionBar?.setDisplayHomeAsUpEnabled(true) |
|
|
|
|
setHasOptionsMenu(true) |
|
|
|
|
|
|
|
|
|
var tabIndexToSelect = 0 |
|
|
|
|
sessionTypeCondition?.let { |
|
|
|
|
tabIndexToSelect = when (it) { |
|
|
|
|
QueryCondition.IsCash -> 1 |
|
|
|
|
QueryCondition.IsTournament -> 2 |
|
|
|
|
else -> 0 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
tabs.getTabAt(tabIndexToSelect)?.select() |
|
|
|
|
|
|
|
|
|
tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { |
|
|
|
|
override fun onTabSelected(tab: TabLayout.Tab) { |
|
|
|
|
@ -121,6 +127,7 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable |
|
|
|
|
adapter = statsAdapter |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -132,16 +139,24 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable |
|
|
|
|
toolbar.title = it |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sessionTypeCondition?.let { |
|
|
|
|
when (it) { |
|
|
|
|
QueryCondition.IsCash -> tabs.getTabAt(1)?.select() |
|
|
|
|
QueryCondition.IsTournament -> tabs.getTabAt(2)?.select() |
|
|
|
|
else -> tabs.getTabAt(0)?.select() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// StaticRowRepresentableDataSource |
|
|
|
|
|
|
|
|
|
override fun adapterRows(): List<RowRepresentable>? { |
|
|
|
|
return rowRepresentables |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) { |
|
|
|
|
when (row) { |
|
|
|
|
is GraphRow -> { |
|
|
|
|
row.report.results.firstOrNull()?.group?.let { computableGroup -> |
|
|
|
|
StatisticDetailsActivity.newInstance(requireContext(), row.stat, computableGroup, row.report, false, row.title) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Launch stat computation |
|
|
|
|
*/ |
|
|
|
|
@ -187,7 +202,7 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable |
|
|
|
|
rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.NET_RESULT), it.computedStat(Stat.HOURLY_RATE))) |
|
|
|
|
rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.LOCATIONS_PLAYED), it.computedStat(Stat.LONGEST_STREAKS))) |
|
|
|
|
rowRepresentables.add(CustomizableRowRepresentable(RowViewType.HEADER_TITLE, resId = R.string.distribution)) |
|
|
|
|
rowRepresentables.add(GraphRow(report, Stat.STANDARD_DEVIATION)) |
|
|
|
|
rowRepresentables.add(GraphRow(report, Stat.STANDARD_DEVIATION, requireContext().getString(R.string.distribution))) |
|
|
|
|
rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.WIN_RATIO), it.computedStat(Stat.MAXIMUM_NETRESULT))) |
|
|
|
|
rowRepresentables.add(CustomizableRowRepresentable(RowViewType.HEADER_TITLE, resId = R.string.volume)) |
|
|
|
|
rowRepresentables.add(GraphRow(report, Stat.HOURLY_DURATION)) |
|
|
|
|
@ -207,18 +222,4 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Set data |
|
|
|
|
*/ |
|
|
|
|
fun setData(computedResults: ComputedResults?, sessionTypeCondition: QueryCondition?, title: String?) { |
|
|
|
|
|
|
|
|
|
this.computedResults = computedResults |
|
|
|
|
this.sessionTypeCondition = sessionTypeCondition |
|
|
|
|
this.title = title |
|
|
|
|
|
|
|
|
|
displayData() |
|
|
|
|
launchStatComputation() |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |