Clean files

feature/top10
Aurelien Hubert 7 years ago
parent 49087b394b
commit 2a5f014235
  1. 49
      app/src/main/java/net/pokeranalytics/android/ui/fragment/GraphFragment.kt
  2. 73
      app/src/main/java/net/pokeranalytics/android/ui/fragment/ReportsFragment.kt

@ -14,9 +14,9 @@ import com.github.mikephil.charting.highlight.Highlight
import com.github.mikephil.charting.listener.OnChartValueSelectedListener
import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipGroup
import io.realm.Realm
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.calculus.*
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.setStyle
import net.pokeranalytics.android.ui.view.LegendView
import timber.log.Timber
import java.text.DateFormat
import java.util.*
import kotlin.coroutines.CoroutineContext
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 {
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 var stat: Stat = Stat.NETRESULT
private var reports: MutableMap<AggregationType, Report> = hashMapOf()
private lateinit var computableGroup: ComputableGroup
private lateinit var selectedReport: Report
private lateinit var legendView: LegendView
private lateinit var chartView: BarLineChartBase<*>
private var computableGroup: ComputableGroup? = null
private var selectedReport: Report? = null
private var legendView: LegendView? = null
private var chartView: BarLineChartBase<*>? = null
private var displayAggregationChoices: Boolean = true
private var aggregationTypes: List<AggregationType> = listOf()
@ -60,7 +71,11 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initUI()
loadGraph(selectedReport)
selectedReport?.let {
loadGraph(it)
}
}
// OnChartValueSelectedListener
@ -78,7 +93,7 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co
val entryValue = it.formattedValue(this.stat, 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() {
GlobalScope.launch(coroutineContext) {
@ -151,8 +167,8 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co
}
}
}
}
*/
/**
* Load graph
@ -160,8 +176,8 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co
private fun loadGraph(report: Report) {
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 colors = arrayOf(R.color.green_light).toIntArray()
@ -184,10 +200,9 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co
this.chartContainer.addView(this.chartView)
this.chartView.setStyle(false, requireContext())
this.chartView.setOnChartValueSelectedListener(this)
this.chartView.highlightValue((entries.size - 1).toFloat(), 0)
this.chartView?.setStyle(false, requireContext())
this.chartView?.setOnChartValueSelectedListener(this)
this.chartView?.highlightValue((entries.size - 1).toFloat(), 0)
}
}

@ -7,49 +7,49 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import kotlinx.android.synthetic.main.fragment_stats.*
import net.pokeranalytics.android.R
import net.pokeranalytics.android.ui.activity.ComparisonChartActivity
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.rowrepresentable.ReportRow
import timber.log.Timber
class ReportsFragment : PokerAnalyticsFragment(), StaticRowRepresentableDataSource, RowRepresentableDelegate {
companion object {
/**
* Create new instance
*/
fun newInstance(): ReportsFragment {
val fragment = ReportsFragment()
val bundle = Bundle()
fragment.arguments = bundle
return fragment
}
val rowRepresentation: List<RowRepresentable> by lazy {
val rows = ArrayList<RowRepresentable>()
rows.addAll(ReportRow.getRows())
rows
}
}
companion object {
/**
* Create new instance
*/
fun newInstance(): ReportsFragment {
val fragment = ReportsFragment()
val bundle = Bundle()
fragment.arguments = bundle
return fragment
}
val rowRepresentation: List<RowRepresentable> by lazy {
val rows = ArrayList<RowRepresentable>()
rows.addAll(ReportRow.getRows())
rows
}
}
private lateinit var reportsAdapter: RowRepresentableAdapter
// Life Cycle
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_reports, container, false)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_reports, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initData()
initUI()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initData()
initUI()
}
// Rows
@ -59,17 +59,23 @@ class ReportsFragment : PokerAnalyticsFragment(), StaticRowRepresentableDataSour
override fun onRowSelected(position: Int, row: RowRepresentable, fromAction: Boolean) {
super.onRowSelected(position, row, fromAction)
ComparisonChartActivity.newInstance(requireContext())
Timber.d("row: $row")
when (row) {
ReportRow.DAY_OF_WEEKS -> {
//TODO: Open ComparisonChartActivity with correct data
//TODO: Calcul report before or after
}
}
}
// Business
/**
* Init data
*/
private fun initData() {
}
/**
* Init data
*/
private fun initData() {
}
/**
* Init UI
@ -87,4 +93,5 @@ class ReportsFragment : PokerAnalyticsFragment(), StaticRowRepresentableDataSour
}
}
}
Loading…
Cancel
Save