|
|
|
|
@ -17,6 +17,7 @@ import com.google.android.material.chip.ChipGroup |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_evograph.* |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.calculus.GraphType |
|
|
|
|
import net.pokeranalytics.android.calculus.ObjectIdentifier |
|
|
|
|
import net.pokeranalytics.android.calculus.Stat |
|
|
|
|
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment |
|
|
|
|
@ -25,16 +26,11 @@ import net.pokeranalytics.android.ui.view.LegendView |
|
|
|
|
import net.pokeranalytics.android.util.extensions.ChipGroupExtension |
|
|
|
|
import net.pokeranalytics.android.util.extensions.px |
|
|
|
|
import net.pokeranalytics.android.util.extensions.toast |
|
|
|
|
|
|
|
|
|
interface GraphDataSource { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
import java.text.DateFormat |
|
|
|
|
|
|
|
|
|
class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener { |
|
|
|
|
|
|
|
|
|
private lateinit var parentActivity: PokerAnalyticsActivity |
|
|
|
|
lateinit var dataSource: GraphDataSource |
|
|
|
|
|
|
|
|
|
lateinit var stat: Stat |
|
|
|
|
lateinit var entries: List<Entry> |
|
|
|
|
@ -69,7 +65,7 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener { |
|
|
|
|
|
|
|
|
|
this.legendView = LegendView(requireContext()) |
|
|
|
|
this.legendContainer.addView(this.legendView) |
|
|
|
|
this.legendView.prepareWithStat(this.stat) |
|
|
|
|
this.legendView.prepareWithStat(this.stat, this.entries.size) |
|
|
|
|
|
|
|
|
|
// Avoid a bug during setting the title |
|
|
|
|
toolbar.title = "" |
|
|
|
|
@ -133,23 +129,16 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener { |
|
|
|
|
e?.let { entry -> |
|
|
|
|
h?.let { highlight -> |
|
|
|
|
|
|
|
|
|
val id = entry.data as String |
|
|
|
|
val item = getRealm().where(this.stat.underlyingClass).equalTo("id", id).findAll().firstOrNull() |
|
|
|
|
val identifier = entry.data as ObjectIdentifier |
|
|
|
|
val item = getRealm().where(identifier.clazz).equalTo("id", identifier.id).findAll().firstOrNull() |
|
|
|
|
item?.let { |
|
|
|
|
|
|
|
|
|
val date = it.startDate() |
|
|
|
|
|
|
|
|
|
val entryStatName = this.stat.localizedTitle(requireContext()) |
|
|
|
|
val formattedDate = DateFormat.getDateInstance(DateFormat.SHORT).format(it.startDate()) |
|
|
|
|
val entryValue = it.formattedValue(this.stat, requireContext()) |
|
|
|
|
|
|
|
|
|
val totalStatName = this.stat.cumulativeLabelResId(requireContext()) |
|
|
|
|
val totalStatValue = this.stat.format(e.y.toDouble(), null, requireContext()) |
|
|
|
|
|
|
|
|
|
this.legendView.setItemData(this.stat, formattedDate, entryValue, totalStatValue) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// this.text.text = "" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|