diff --git a/app/src/main/java/net/pokeranalytics/android/calculus/Calculator.kt b/app/src/main/java/net/pokeranalytics/android/calculus/Calculator.kt index c28b04b1..41e6986f 100644 --- a/app/src/main/java/net/pokeranalytics/android/calculus/Calculator.kt +++ b/app/src/main/java/net/pokeranalytics/android/calculus/Calculator.kt @@ -3,7 +3,9 @@ package net.pokeranalytics.android.calculus import net.pokeranalytics.android.calculus.Stat.* import net.pokeranalytics.android.model.realm.SessionSet - +/** + * The class performing stats computation + */ class Calculator { class Options { diff --git a/app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt b/app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt index b9749c35..0b46b20c 100644 --- a/app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt +++ b/app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt @@ -4,11 +4,10 @@ import net.pokeranalytics.android.R import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowViewType -interface AnyStat { - -} - -enum class Stat : AnyStat, RowRepresentable { +/** + * An enum representing all the types of Session statistics + */ +enum class Stat : RowRepresentable { NETRESULT, HOURLY_RATE, @@ -79,11 +78,9 @@ enum class Stat : AnyStat, RowRepresentable { override val viewType: Int = RowViewType.TITLE_VALUE.ordinal } -enum class CashSessionStat : AnyStat { - NETBB, - AVERAGEBB -} - +/** + * ComputedStat contains a [stat] and their associated [value] + */ class ComputedStat(stat: Stat, value: Double) { constructor(stat: Stat, value: Double, previousValue: Double?) : this(stat, value) { @@ -92,23 +89,31 @@ class ComputedStat(stat: Stat, value: Double) { } } - // The statistic type + /** + * The statistic type + */ var stat: Stat = stat - // The stat value + /** + * The stat value + */ var value: Double = value - // The variation of the stat + /** + * The variation of the stat + */ var variation: Double? = null - // The data points leading to the current stat value -// var points: List = mutableListOf() - - // Formats the value of the stat to be suitable for display + /** + * Formats the value of the stat to be suitable for display + */ fun format() : StatFormat { return StatFormat() } + /** + * Returns a StatFormat instance for an evolution value located at the specified [index] + */ fun evolutionValueFormat(index: Int) : StatFormat { return StatFormat() } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/adapter/components/RowRepresentableAdapter.kt b/app/src/main/java/net/pokeranalytics/android/ui/adapter/components/RowRepresentableAdapter.kt index 429d6ae9..3def2642 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/adapter/components/RowRepresentableAdapter.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/adapter/components/RowRepresentableAdapter.kt @@ -3,22 +3,37 @@ package net.pokeranalytics.android.ui.adapter.components import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView -import net.pokeranalytics.android.ui.view.DynamicHolder +import net.pokeranalytics.android.ui.view.BindableHolder import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowViewType +/** + * An interface used to provide RowRepresentableAdapter content and value in the form of rows + */ interface RowRepresentableDataSource { + /** + * Returns a list of rows + */ fun adapterRows(): ArrayList + /** + * Returns a boolean for a specific row + */ fun boolForRow(row: RowRepresentable): Boolean { return false } + /** + * Returns a string for a specific row + */ fun stringForRow(row: RowRepresentable): String { return "" } + /** + * Returns an action icon identifier for a specific row + */ fun actionIconForRow(row: RowRepresentable): Int? { return 0 } @@ -34,14 +49,25 @@ interface RowRepresentableDataSource { } +/** + * A delegate used to propagate UI actions + */ interface RowRepresentableDelegate { fun onRowSelected(row: RowRepresentable) {} fun onActionSelected(row: RowRepresentable) {} } +/** + * An adapter capable of displaying a list of RowRepresentables + * @param rowRepresentableDataSource the datasource providing rows + * @param rowRepresentableDelegate the delegate, notified of UI actions + */ class RowRepresentableAdapter(var rowRepresentableDataSource: RowRepresentableDataSource, var rowRepresentableDelegate: RowRepresentableDelegate? = null) : RecyclerView.Adapter() { + /** + * The list of rows to display + */ private var rows: ArrayList = ArrayList() init { @@ -72,7 +98,7 @@ class RowRepresentableAdapter(var rowRepresentableDataSource: RowRepresentableDa rowRepresentableDelegate?.onActionSelected(dynamicRow) } - (holder as DynamicHolder).bind(dynamicRow, this.rowRepresentableDataSource, listener, actionListener) + (holder as BindableHolder).bind(dynamicRow, this.rowRepresentableDataSource, listener, actionListener) } /** diff --git a/app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt b/app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt index 02d34b2f..b5f8e226 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt @@ -8,7 +8,10 @@ import kotlinx.android.synthetic.main.row_title_value_action.view.* import net.pokeranalytics.android.R import net.pokeranalytics.android.ui.adapter.components.RowRepresentableDataSource -interface DynamicHolder { +/** + * An interface used to factor the configuration of RecyclerView.ViewHolder + */ +interface BindableHolder { fun bind(row: RowRepresentable, rowRepresentableDataSource: RowRepresentableDataSource? = null, listener: View.OnClickListener, actionListener: View.OnClickListener? = null) {} @@ -22,13 +25,13 @@ enum class RowViewType { TITLE_VALUE_ACTION; inner class FakeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), - DynamicHolder { + BindableHolder { override fun bind(row: RowRepresentable, rowRepresentableDataSource: RowRepresentableDataSource?, listener: View.OnClickListener, actionListener: View.OnClickListener?) { } } inner class TitleViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), - DynamicHolder { + BindableHolder { override fun bind(row: RowRepresentable, rowRepresentableDataSource: RowRepresentableDataSource?, listener: View.OnClickListener, actionListener: View.OnClickListener?) { itemView.title.text = row.localizedTitle(itemView.context) itemView.container.setOnClickListener(listener) @@ -36,7 +39,7 @@ enum class RowViewType { } inner class TitleValueViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), - DynamicHolder { + BindableHolder { override fun bind(row: RowRepresentable, rowRepresentableDataSource: RowRepresentableDataSource?, listener: View.OnClickListener, actionListener: View.OnClickListener?) { itemView.title.text = row.localizedTitle(itemView.context) @@ -48,7 +51,7 @@ enum class RowViewType { } inner class TitleValueActionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), - DynamicHolder { + BindableHolder { override fun bind(row: RowRepresentable, rowRepresentableDataSource: RowRepresentableDataSource?, listener: View.OnClickListener, actionListener: View.OnClickListener?) { itemView.title.text = row.localizedTitle(itemView.context) rowRepresentableDataSource?.let { rowDelegate ->