|
|
|
@ -5,6 +5,7 @@ import android.view.View |
|
|
|
import android.view.ViewGroup |
|
|
|
import android.view.ViewGroup |
|
|
|
import androidx.appcompat.widget.AppCompatImageView |
|
|
|
import androidx.appcompat.widget.AppCompatImageView |
|
|
|
import androidx.appcompat.widget.AppCompatTextView |
|
|
|
import androidx.appcompat.widget.AppCompatTextView |
|
|
|
|
|
|
|
import androidx.appcompat.widget.SwitchCompat |
|
|
|
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_history_session.view.* |
|
|
|
import kotlinx.android.synthetic.main.row_history_session.view.* |
|
|
|
@ -15,6 +16,7 @@ import net.pokeranalytics.android.calculus.Stat |
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter |
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.HeaderRowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.HeaderRowRepresentable |
|
|
|
|
|
|
|
import timber.log.Timber |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* An interface used to factor the configuration of RecyclerView.ViewHolder |
|
|
|
* An interface used to factor the configuration of RecyclerView.ViewHolder |
|
|
|
@ -64,9 +66,7 @@ enum class RowViewType(private var layoutRes: Int) { |
|
|
|
return when (this) { |
|
|
|
return when (this) { |
|
|
|
|
|
|
|
|
|
|
|
// Header Row View Holder |
|
|
|
// Header Row View Holder |
|
|
|
HEADER_TITLE, HEADER_TITLE_VALUE, HEADER_TITLE_AMOUNT, HEADER_TITLE_AMOUNT_BIG -> { |
|
|
|
HEADER_TITLE, HEADER_TITLE_VALUE, HEADER_TITLE_AMOUNT, HEADER_TITLE_AMOUNT_BIG -> HeaderViewHolder(layout) |
|
|
|
HeaderViewHolder(layout) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Row View Holder |
|
|
|
// Row View Holder |
|
|
|
TITLE, TITLE_VALUE, TITLE_ARROW, TITLE_GRID, TITLE_SWITCH, DATA, BOTTOM_SHEET_DATA -> RowViewHolder(layout) |
|
|
|
TITLE, TITLE_VALUE, TITLE_ARROW, TITLE_GRID, TITLE_SWITCH, DATA, BOTTOM_SHEET_DATA -> RowViewHolder(layout) |
|
|
|
@ -141,9 +141,22 @@ enum class RowViewType(private var layoutRes: Int) { |
|
|
|
it.text = adapter.dataSource.stringForRow(row, itemView.context) |
|
|
|
it.text = adapter.dataSource.stringForRow(row, itemView.context) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Switch |
|
|
|
|
|
|
|
itemView.findViewById<SwitchCompat?>(R.id.switchView)?.let { |
|
|
|
|
|
|
|
it.isChecked = adapter.dataSource.boolForRow(row) |
|
|
|
|
|
|
|
it.setOnCheckedChangeListener { _, isChecked -> |
|
|
|
|
|
|
|
Timber.d("Manage switch: $isChecked") |
|
|
|
|
|
|
|
adapter.delegate?.onRowValueChanged(isChecked, row) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Listener |
|
|
|
// Listener |
|
|
|
val listener = View.OnClickListener { |
|
|
|
val listener = View.OnClickListener { |
|
|
|
adapter.delegate?.onRowSelected(position, row) |
|
|
|
itemView.findViewById<SwitchCompat?>(R.id.switchView)?.let { |
|
|
|
|
|
|
|
it.isChecked = !it.isChecked |
|
|
|
|
|
|
|
} ?: run { |
|
|
|
|
|
|
|
adapter.delegate?.onRowSelected(position, row) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
itemView.findViewById<View?>(R.id.container)?.let { |
|
|
|
itemView.findViewById<View?>(R.id.container)?.let { |
|
|
|
@ -216,7 +229,6 @@ enum class RowViewType(private var layoutRes: Int) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Display a separator |
|
|
|
* Display a separator |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|