|
|
|
@ -7,17 +7,8 @@ import androidx.appcompat.widget.AppCompatImageView |
|
|
|
import androidx.appcompat.widget.AppCompatTextView |
|
|
|
import androidx.appcompat.widget.AppCompatTextView |
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout |
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
import kotlinx.android.synthetic.main.row_bottom_sheet_grid_title.view.* |
|
|
|
|
|
|
|
import kotlinx.android.synthetic.main.row_bottom_sheet_title.view.* |
|
|
|
|
|
|
|
import kotlinx.android.synthetic.main.row_header_title.view.* |
|
|
|
|
|
|
|
import kotlinx.android.synthetic.main.row_header_title_amount.view.* |
|
|
|
|
|
|
|
import kotlinx.android.synthetic.main.row_header_title_value.view.* |
|
|
|
|
|
|
|
import kotlinx.android.synthetic.main.row_history_session.view.* |
|
|
|
import kotlinx.android.synthetic.main.row_history_session.view.* |
|
|
|
import kotlinx.android.synthetic.main.row_stats_title_value.view.* |
|
|
|
import kotlinx.android.synthetic.main.row_stats_title_value.view.* |
|
|
|
import kotlinx.android.synthetic.main.row_title.view.* |
|
|
|
|
|
|
|
import kotlinx.android.synthetic.main.row_title_switch.view.* |
|
|
|
|
|
|
|
import kotlinx.android.synthetic.main.row_title_value.view.* |
|
|
|
|
|
|
|
import kotlinx.android.synthetic.main.row_title_value_action.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 |
|
|
|
@ -35,10 +26,12 @@ interface BindableHolder { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum class RowViewType { |
|
|
|
enum class RowViewType { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HEADER_TITLE, |
|
|
|
HEADER_TITLE_VALUE, |
|
|
|
HEADER_TITLE_VALUE, |
|
|
|
HEADER_TITLE_AMOUNT, |
|
|
|
HEADER_TITLE_AMOUNT, |
|
|
|
HEADER_TITLE_AMOUNT_BIG, |
|
|
|
HEADER_TITLE_AMOUNT_BIG, |
|
|
|
HEADER_TITLE, |
|
|
|
|
|
|
|
EDIT_TEXT, |
|
|
|
EDIT_TEXT, |
|
|
|
TITLE, |
|
|
|
TITLE, |
|
|
|
TITLE_ARROW, |
|
|
|
TITLE_ARROW, |
|
|
|
@ -49,101 +42,90 @@ enum class RowViewType { |
|
|
|
BOTTOM_SHEET_DATA, |
|
|
|
BOTTOM_SHEET_DATA, |
|
|
|
TITLE_GRID, |
|
|
|
TITLE_GRID, |
|
|
|
ROW_SESSION, |
|
|
|
ROW_SESSION, |
|
|
|
BUTTON, |
|
|
|
ROW_BUTTON, |
|
|
|
FOLLOW_US, |
|
|
|
ROW_FOLLOW_US, |
|
|
|
STAT; |
|
|
|
STAT, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SEPARATOR; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* View holder |
|
|
|
* View holder |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun viewHolder(parent: ViewGroup): RecyclerView.ViewHolder { |
|
|
|
fun viewHolder(parent: ViewGroup): RecyclerView.ViewHolder { |
|
|
|
return when (this) { |
|
|
|
return when (this) { |
|
|
|
HEADER_TITLE_VALUE -> HeaderTitleValueViewHolder( |
|
|
|
|
|
|
|
|
|
|
|
// Header Row View Holder |
|
|
|
|
|
|
|
HEADER_TITLE -> { |
|
|
|
|
|
|
|
HeaderViewHolder( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
R.layout.row_header_title_value, |
|
|
|
R.layout.row_header_title, parent, false |
|
|
|
parent, |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
HEADER_TITLE_AMOUNT -> HeaderTitleAmountViewHolder( |
|
|
|
} |
|
|
|
|
|
|
|
HEADER_TITLE_VALUE -> HeaderViewHolder( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
R.layout.row_header_title_amount, |
|
|
|
R.layout.row_header_title_value, parent, false |
|
|
|
parent, |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
HEADER_TITLE_AMOUNT_BIG -> HeaderTitleAmountViewHolder( |
|
|
|
HEADER_TITLE_AMOUNT -> HeaderViewHolder( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
R.layout.row_header_title_amount_big, |
|
|
|
R.layout.row_header_title_amount, parent, false |
|
|
|
parent, |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
TITLE -> TitleViewHolder( |
|
|
|
HEADER_TITLE_AMOUNT_BIG -> HeaderViewHolder( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
R.layout.row_title, |
|
|
|
R.layout.row_header_title_amount_big, parent, false |
|
|
|
parent, |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
TITLE_ARROW -> TitleViewHolder( |
|
|
|
|
|
|
|
|
|
|
|
// Row View Holder |
|
|
|
|
|
|
|
TITLE -> RowViewHolder( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
R.layout.row_title_arrow, |
|
|
|
R.layout.row_title, parent, false |
|
|
|
parent, |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
TITLE_VALUE -> TitleValueViewHolder( |
|
|
|
TITLE_ARROW -> RowViewHolder( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
R.layout.row_title_value, |
|
|
|
R.layout.row_title_arrow, parent, false |
|
|
|
parent, |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
TITLE_GRID -> TitleGridSessionViewHolder( |
|
|
|
TITLE_GRID -> RowViewHolder( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
R.layout.row_bottom_sheet_grid_title, |
|
|
|
R.layout.row_bottom_sheet_grid_title, parent, false |
|
|
|
parent, |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
TITLE_SWITCH -> TitleSwitchViewHolder( |
|
|
|
DATA -> RowViewHolder( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
LayoutInflater.from(parent.context).inflate(R.layout.row_title, parent, false) |
|
|
|
R.layout.row_title_switch, |
|
|
|
|
|
|
|
parent, |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
BOTTOM_SHEET_DATA -> RowViewHolder( |
|
|
|
|
|
|
|
LayoutInflater.from(parent.context).inflate(R.layout.row_bottom_sheet_title, parent, false) |
|
|
|
) |
|
|
|
) |
|
|
|
TITLE_VALUE_ACTION -> TitleValueActionViewHolder( |
|
|
|
//TODO: Manage action |
|
|
|
|
|
|
|
TITLE_VALUE_ACTION -> RowViewHolder( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
R.layout.row_title_value_action, |
|
|
|
R.layout.row_title_value_action, |
|
|
|
parent, |
|
|
|
parent, |
|
|
|
false |
|
|
|
false |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
DATA -> DataViewHolder( |
|
|
|
//TODO: Manage switch |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
TITLE_SWITCH -> RowViewHolder( |
|
|
|
R.layout.row_title, |
|
|
|
|
|
|
|
parent, |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
BOTTOM_SHEET_DATA -> BottomSheetDataViewHolder( |
|
|
|
|
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
R.layout.row_bottom_sheet_title, |
|
|
|
R.layout.row_title_switch, |
|
|
|
parent, |
|
|
|
parent, |
|
|
|
false |
|
|
|
false |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
HEADER_TITLE -> { |
|
|
|
//TODO: Update layout container to ConstraintLayout and remove separator |
|
|
|
HeaderSessionViewHolder( |
|
|
|
TITLE_VALUE -> RowViewHolder( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
R.layout.row_header_title, |
|
|
|
R.layout.row_title_value, |
|
|
|
parent, |
|
|
|
parent, |
|
|
|
false |
|
|
|
false |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Row Session |
|
|
|
ROW_SESSION -> RowSessionViewHolder( |
|
|
|
ROW_SESSION -> RowSessionViewHolder( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
R.layout.row_history_session, |
|
|
|
R.layout.row_history_session, |
|
|
|
@ -151,8 +133,10 @@ enum class RowViewType { |
|
|
|
false |
|
|
|
false |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
BUTTON -> { |
|
|
|
|
|
|
|
ButtonViewHolder( |
|
|
|
// Row Button |
|
|
|
|
|
|
|
ROW_BUTTON -> { |
|
|
|
|
|
|
|
RowButtonViewHolder( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
R.layout.row_button, |
|
|
|
R.layout.row_button, |
|
|
|
parent, |
|
|
|
parent, |
|
|
|
@ -160,8 +144,9 @@ enum class RowViewType { |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
FOLLOW_US -> { |
|
|
|
// Row Follow Us |
|
|
|
FollowUsViewHolder( |
|
|
|
ROW_FOLLOW_US -> { |
|
|
|
|
|
|
|
RowFollowUsViewHolder( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
R.layout.row_follow_us, |
|
|
|
R.layout.row_follow_us, |
|
|
|
parent, |
|
|
|
parent, |
|
|
|
@ -169,6 +154,8 @@ enum class RowViewType { |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Row Stat |
|
|
|
STAT -> StatsTitleValueViewHolder( |
|
|
|
STAT -> StatsTitleValueViewHolder( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
R.layout.row_stats_title_value, |
|
|
|
R.layout.row_stats_title_value, |
|
|
|
@ -176,75 +163,86 @@ enum class RowViewType { |
|
|
|
false |
|
|
|
false |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Separator |
|
|
|
|
|
|
|
SEPARATOR -> SeparatorViewHolder( |
|
|
|
|
|
|
|
LayoutInflater.from(parent.context).inflate( |
|
|
|
|
|
|
|
R.layout.row_separator, |
|
|
|
|
|
|
|
parent, |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
else -> throw Exception("Undefined rowViewType's holder") |
|
|
|
else -> throw Exception("Undefined rowViewType's holder") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inner class HeaderTitleValueViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), |
|
|
|
|
|
|
|
BindableHolder { |
|
|
|
|
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
|
|
|
|
itemView.rowHeaderTitleValue_title.text = row.localizedTitle(itemView.context) |
|
|
|
|
|
|
|
adapter.dataSource.let { |
|
|
|
|
|
|
|
itemView.rowHeaderTitleValue_value.text = it.stringForRow(row, itemView.context) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//val listener = View.OnClickListener { |
|
|
|
|
|
|
|
// adapter.delegate?.onRowSelected(position, row) |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
//itemView.rowHeaderTitleValue_container.setOnClickListener(listener) |
|
|
|
|
|
|
|
itemView.rowHeaderTitleValue_separator.visibility = if (row.needSeparator) View.VISIBLE else View.GONE |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inner class HeaderTitleAmountViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), |
|
|
|
/** |
|
|
|
BindableHolder { |
|
|
|
* Display a header |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
inner class HeaderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { |
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
|
|
|
|
|
|
|
|
if (row is HeaderRowRepresentable) { |
|
|
|
if (row is HeaderRowRepresentable) { |
|
|
|
|
|
|
|
|
|
|
|
if (row.resId != null) { |
|
|
|
// Title |
|
|
|
itemView.rowHeaderTitleAmount_title.text = row.localizedTitle(itemView.context) |
|
|
|
itemView.findViewById<AppCompatTextView>(R.id.title)?.let { |
|
|
|
} else if (row.title != null) { |
|
|
|
it.text = row.localizedTitle(itemView.context) |
|
|
|
itemView.rowHeaderTitleAmount_title.text = row.title |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Value |
|
|
|
|
|
|
|
itemView.findViewById<FormattedTextView?>(R.id.value)?.let { |
|
|
|
val value = try { |
|
|
|
val value = try { |
|
|
|
row.value?.toDouble() ?: 0.0 |
|
|
|
row.value?.toDouble() ?: 0.0 |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
0.0 |
|
|
|
0.0 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: Manage multiple stat type |
|
|
|
val stat = ComputedStat(Stat.NETRESULT, value) |
|
|
|
val stat = ComputedStat(Stat.NETRESULT, value) |
|
|
|
itemView.rowHeaderTitleAmount_value.textFormat = stat.format(itemView.context) |
|
|
|
it.textFormat = stat.format(itemView.context) |
|
|
|
|
|
|
|
//it.text = adapter.dataSource.stringForRow(row, itemView.context) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inner class TitleViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), |
|
|
|
/** |
|
|
|
BindableHolder { |
|
|
|
* Display a generic row (title, value, container) |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
inner class RowViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { |
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
itemView.rowTitle_title.text = row.localizedTitle(itemView.context) |
|
|
|
|
|
|
|
val listener = View.OnClickListener { |
|
|
|
// Title |
|
|
|
adapter.delegate?.onRowSelected(position, row) |
|
|
|
itemView.findViewById<AppCompatTextView?>(R.id.title)?.let { |
|
|
|
} |
|
|
|
if (row.resId != null) { |
|
|
|
itemView.rowTitle_container.setOnClickListener(listener) |
|
|
|
it.text = row.localizedTitle(itemView.context) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
it.text = row.getDisplayName() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inner class TitleValueViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), |
|
|
|
// Value |
|
|
|
BindableHolder { |
|
|
|
itemView.findViewById<AppCompatTextView?>(R.id.value)?.let { |
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
it.text = adapter.dataSource.stringForRow(row, itemView.context) |
|
|
|
itemView.rowTitleValue_title.text = row.localizedTitle(itemView.context) |
|
|
|
|
|
|
|
adapter.dataSource?.let { |
|
|
|
|
|
|
|
itemView.rowTitleValue_value.text = it.stringForRow(row, itemView.context) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Listener |
|
|
|
val listener = View.OnClickListener { |
|
|
|
val listener = View.OnClickListener { |
|
|
|
adapter.delegate?.onRowSelected(position, row) |
|
|
|
adapter.delegate?.onRowSelected(position, row) |
|
|
|
} |
|
|
|
} |
|
|
|
itemView.rowTitleValue_container.setOnClickListener(listener) |
|
|
|
|
|
|
|
itemView.rowTitleValue_separator.visibility = if (row.needSeparator) View.VISIBLE else View.GONE |
|
|
|
itemView.findViewById<View?>(R.id.container)?.let { |
|
|
|
|
|
|
|
it.setOnClickListener(listener) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inner class FollowUsViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { |
|
|
|
/** |
|
|
|
|
|
|
|
* Display a follow us row |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
inner class RowFollowUsViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { |
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
itemView.findViewById<AppCompatImageView>(R.id.icon1).setOnClickListener { |
|
|
|
itemView.findViewById<AppCompatImageView>(R.id.icon1).setOnClickListener { |
|
|
|
adapter.delegate?.onRowSelected(0, row) |
|
|
|
adapter.delegate?.onRowSelected(0, row) |
|
|
|
@ -261,6 +259,9 @@ enum class RowViewType { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Display a stat |
|
|
|
|
|
|
|
*/ |
|
|
|
inner class StatsTitleValueViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), |
|
|
|
inner class StatsTitleValueViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), |
|
|
|
BindableHolder { |
|
|
|
BindableHolder { |
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
@ -277,83 +278,10 @@ enum class RowViewType { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inner class TitleGridSessionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { |
|
|
|
/** |
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
* Display a button in a row |
|
|
|
itemView.title.text = row.localizedTitle(itemView.context) |
|
|
|
*/ |
|
|
|
val listener = View.OnClickListener { |
|
|
|
inner class RowButtonViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { |
|
|
|
adapter.delegate?.onRowSelected(position, row) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
itemView.container.setOnClickListener(listener) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inner class TitleSwitchViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), |
|
|
|
|
|
|
|
BindableHolder { |
|
|
|
|
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
|
|
|
|
itemView.rowTitleSwitch_title.text = row.localizedTitle(itemView.context) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adapter.dataSource.let { |
|
|
|
|
|
|
|
itemView.rowTitleSwitch_switch.isChecked = it.boolForRow(row) |
|
|
|
|
|
|
|
itemView.rowTitleSwitch_switch.setOnCheckedChangeListener { buttonView, isChecked -> |
|
|
|
|
|
|
|
adapter.delegate?.onRowValueChanged(isChecked, row) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val listener = View.OnClickListener { |
|
|
|
|
|
|
|
itemView.rowTitleSwitch_switch.isChecked = !itemView.rowTitleSwitch_switch.isChecked |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
itemView.rowTitleSwitch_container.setOnClickListener(listener) |
|
|
|
|
|
|
|
itemView.rowTitleSwitch_separator.visibility = if (row.needSeparator) View.VISIBLE else View.GONE |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inner class TitleValueActionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), |
|
|
|
|
|
|
|
BindableHolder { |
|
|
|
|
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
|
|
|
|
itemView.rowTitleValueAction_title.text = row.localizedTitle(itemView.context) |
|
|
|
|
|
|
|
adapter.dataSource.let { rowDelegate -> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val value = rowDelegate.stringForRow(row, itemView.context) |
|
|
|
|
|
|
|
itemView.rowTitleValueAction_value.text = value |
|
|
|
|
|
|
|
itemView.rowTitleValueAction_action.visibility = if (value == "--") View.GONE else View.VISIBLE |
|
|
|
|
|
|
|
rowDelegate.actionIconForRow(row)?.let { icon -> |
|
|
|
|
|
|
|
itemView.rowTitleValueAction_action.setImageResource(icon) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
val listener = View.OnClickListener { |
|
|
|
|
|
|
|
adapter.delegate?.onRowSelected(position, row) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
val actionListener = View.OnClickListener { |
|
|
|
|
|
|
|
adapter.delegate?.onRowSelected(position, row, true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
itemView.rowTitleValueAction_container.setOnClickListener(listener) |
|
|
|
|
|
|
|
itemView.rowTitleValueAction_action.setOnClickListener(actionListener) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inner class DataViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { |
|
|
|
|
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
|
|
|
|
itemView.rowTitle_title.text = row.getDisplayName() |
|
|
|
|
|
|
|
val listener = View.OnClickListener { |
|
|
|
|
|
|
|
adapter.delegate?.onRowSelected(position, row) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
itemView.rowTitle_container.setOnClickListener(listener) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inner class BottomSheetDataViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { |
|
|
|
|
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
|
|
|
|
itemView.rowBottomSheet_title.text = row.getDisplayName() |
|
|
|
|
|
|
|
val listener = View.OnClickListener { |
|
|
|
|
|
|
|
adapter.delegate?.onRowSelected(position, row) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
itemView.rowBottomSheet_container.setOnClickListener(listener) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inner class ButtonViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), |
|
|
|
|
|
|
|
BindableHolder { |
|
|
|
|
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
itemView.findViewById<AppCompatTextView>(R.id.title).text = row.localizedTitle(itemView.context) |
|
|
|
itemView.findViewById<AppCompatTextView>(R.id.title).text = row.localizedTitle(itemView.context) |
|
|
|
val listener = View.OnClickListener { |
|
|
|
val listener = View.OnClickListener { |
|
|
|
@ -363,26 +291,26 @@ enum class RowViewType { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inner class HeaderSessionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), |
|
|
|
/** |
|
|
|
BindableHolder { |
|
|
|
* Display a session view |
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
*/ |
|
|
|
itemView.sessionHeaderTitle.text = row.localizedTitle(itemView.context) |
|
|
|
inner class RowSessionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inner class RowSessionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), |
|
|
|
|
|
|
|
BindableHolder { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
|
|
|
|
|
|
|
|
itemView.sessionRow.setData(row as Session) |
|
|
|
itemView.sessionRow.setData(row as Session) |
|
|
|
val listener = View.OnClickListener { |
|
|
|
val listener = View.OnClickListener { |
|
|
|
adapter.delegate?.onRowSelected(position, row) |
|
|
|
adapter.delegate?.onRowSelected(position, row) |
|
|
|
} |
|
|
|
} |
|
|
|
itemView.sessionRow.setOnClickListener(listener) |
|
|
|
itemView.sessionRow.setOnClickListener(listener) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Display a separator |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
inner class SeparatorViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), BindableHolder { |
|
|
|
|
|
|
|
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |