|
|
|
@ -17,22 +17,24 @@ import com.github.mikephil.charting.data.BarData |
|
|
|
import com.github.mikephil.charting.data.BarDataSet |
|
|
|
import com.github.mikephil.charting.data.BarDataSet |
|
|
|
import com.github.mikephil.charting.data.LineData |
|
|
|
import com.github.mikephil.charting.data.LineData |
|
|
|
import com.github.mikephil.charting.data.LineDataSet |
|
|
|
import com.github.mikephil.charting.data.LineDataSet |
|
|
|
|
|
|
|
import com.google.android.material.chip.Chip |
|
|
|
|
|
|
|
import com.google.android.material.chip.ChipGroup |
|
|
|
import kotlinx.android.synthetic.main.row_feed_session.view.* |
|
|
|
import kotlinx.android.synthetic.main.row_feed_session.view.* |
|
|
|
import kotlinx.android.synthetic.main.row_transaction.view.* |
|
|
|
import kotlinx.android.synthetic.main.row_transaction.view.* |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.calculus.ComputedStat |
|
|
|
import net.pokeranalytics.android.calculus.ComputedStat |
|
|
|
import net.pokeranalytics.android.calculus.Stat |
|
|
|
import net.pokeranalytics.android.calculus.Stat |
|
|
|
import net.pokeranalytics.android.calculus.bankroll.BankrollReport |
|
|
|
import net.pokeranalytics.android.calculus.bankroll.BankrollReport |
|
|
|
|
|
|
|
import net.pokeranalytics.android.model.realm.CustomField |
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
import net.pokeranalytics.android.model.realm.Transaction |
|
|
|
import net.pokeranalytics.android.model.realm.Transaction |
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter |
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.extensions.ChipGroupExtension |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.extensions.px |
|
|
|
import net.pokeranalytics.android.ui.extensions.setTextFormat |
|
|
|
import net.pokeranalytics.android.ui.extensions.setTextFormat |
|
|
|
import net.pokeranalytics.android.ui.graph.AxisFormatting |
|
|
|
import net.pokeranalytics.android.ui.graph.AxisFormatting |
|
|
|
import net.pokeranalytics.android.ui.graph.setStyle |
|
|
|
import net.pokeranalytics.android.ui.graph.setStyle |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.* |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.GraphRow |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.StatDoubleRow |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.StatRow |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* An interface used to factor the configuration of RecyclerView.ViewHolder |
|
|
|
* An interface used to factor the configuration of RecyclerView.ViewHolder |
|
|
|
@ -79,6 +81,7 @@ enum class RowViewType(private var layoutRes: Int) { |
|
|
|
STATS_DOUBLE(R.layout.row_stats_double), |
|
|
|
STATS_DOUBLE(R.layout.row_stats_double), |
|
|
|
GRAPH(R.layout.row_graph), |
|
|
|
GRAPH(R.layout.row_graph), |
|
|
|
LEGEND_DEFAULT(R.layout.row_legend_default), |
|
|
|
LEGEND_DEFAULT(R.layout.row_legend_default), |
|
|
|
|
|
|
|
LIST(R.layout.row_list), |
|
|
|
|
|
|
|
|
|
|
|
// Separator |
|
|
|
// Separator |
|
|
|
SEPARATOR(R.layout.row_separator); |
|
|
|
SEPARATOR(R.layout.row_separator); |
|
|
|
@ -110,6 +113,9 @@ enum class RowViewType(private var layoutRes: Int) { |
|
|
|
// Row Follow Us |
|
|
|
// Row Follow Us |
|
|
|
ROW_FOLLOW_US -> RowFollowUsViewHolder(layout) |
|
|
|
ROW_FOLLOW_US -> RowFollowUsViewHolder(layout) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Row List - ChipGroup |
|
|
|
|
|
|
|
LIST -> ListViewHolder(layout) |
|
|
|
|
|
|
|
|
|
|
|
// Row Stats |
|
|
|
// Row Stats |
|
|
|
STATS -> StatsTitleValueViewHolder(layout) |
|
|
|
STATS -> StatsTitleValueViewHolder(layout) |
|
|
|
STATS_DOUBLE -> StatsDoubleViewHolder(layout) |
|
|
|
STATS_DOUBLE -> StatsDoubleViewHolder(layout) |
|
|
|
@ -393,6 +399,45 @@ enum class RowViewType(private var layoutRes: Int) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Display a list of chips |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
inner class ListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), |
|
|
|
|
|
|
|
BindableHolder { |
|
|
|
|
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (row is CustomFieldRow) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
itemView.findViewById<ChipGroup>(R.id.chipGroup)?.let { chipGroup -> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CustomField.Type.values().forEach { type -> |
|
|
|
|
|
|
|
val chip = Chip(itemView.context) |
|
|
|
|
|
|
|
chip.id = type.ordinal |
|
|
|
|
|
|
|
chip.text = itemView.context.getString(type.resId) |
|
|
|
|
|
|
|
chip.chipStartPadding = 8f.px |
|
|
|
|
|
|
|
chip.chipEndPadding = 8f.px |
|
|
|
|
|
|
|
chip.isChecked = adapter.dataSource.intForRow(row) == type.ordinal |
|
|
|
|
|
|
|
chipGroup.addView(chip) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
chipGroup.setOnCheckedChangeListener(object : ChipGroupExtension.SingleSelectionOnCheckedListener() { |
|
|
|
|
|
|
|
override fun onCheckedChanged(group: ChipGroup, checkedId: Int) { |
|
|
|
|
|
|
|
super.onCheckedChanged(group, checkedId) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings |
|
|
|
|
|
|
|
if (checkedId < 0) { // when unchecked, checkedId returns -1, causing a crash |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adapter.delegate?.onRowValueChanged(CustomField.Type.values()[checkedId], row) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Display a button in a row |
|
|
|
* Display a button in a row |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|