parent
cf70562735
commit
47c297ebfd
@ -1,79 +0,0 @@ |
|||||||
package net.pokeranalytics.android.ui.adapter |
|
||||||
|
|
||||||
import android.view.LayoutInflater |
|
||||||
import android.view.View |
|
||||||
import android.view.ViewGroup |
|
||||||
import androidx.recyclerview.widget.RecyclerView |
|
||||||
import kotlinx.android.synthetic.main.row_data_cell.view.* |
|
||||||
import kotlinx.android.synthetic.main.row_history_session.view.* |
|
||||||
import net.pokeranalytics.android.R |
|
||||||
|
|
||||||
class SettingsAdapter() : RecyclerView.Adapter<RecyclerView.ViewHolder>() { |
|
||||||
|
|
||||||
companion object { |
|
||||||
const val ROW_DATA: Int = 100 |
|
||||||
enum class DataType { |
|
||||||
BANKROLL { |
|
||||||
override fun localizedName(): String { |
|
||||||
return "Bankroll" |
|
||||||
} |
|
||||||
}, |
|
||||||
GAME { |
|
||||||
override fun localizedName(): String { |
|
||||||
return "Game" |
|
||||||
} |
|
||||||
}, |
|
||||||
LOCATION { |
|
||||||
override fun localizedName(): String { |
|
||||||
return "Location" |
|
||||||
} |
|
||||||
}, |
|
||||||
TOURNAMENT_TYPE { |
|
||||||
override fun localizedName(): String { |
|
||||||
return "Tournament Type" |
|
||||||
} |
|
||||||
}, |
|
||||||
TRANSACTION_TYPE { |
|
||||||
override fun localizedName(): String { |
|
||||||
return "Transaction" |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
abstract fun localizedName(): String |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
var onClickOnData: ((position: Int, dataType: DataType) -> Unit)? = null |
|
||||||
|
|
||||||
inner class RowDataViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { |
|
||||||
fun bind(dataType: DataType) { |
|
||||||
itemView.dataRow.setData(dataType.localizedName()) |
|
||||||
itemView.dataRow.setOnClickListener { |
|
||||||
onClickOnData?.invoke(adapterPosition, dataType) |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { |
|
||||||
when (viewType) { |
|
||||||
ROW_DATA -> return RowDataViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.row_data_cell, parent, false)) |
|
||||||
else -> throw IllegalStateException("Need to implement type $viewType in Settings Adapter") |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { |
|
||||||
when (getItemViewType(position)) { |
|
||||||
ROW_DATA -> (holder as SettingsAdapter.RowDataViewHolder).bind(enumValues<DataType>()[position]) |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
override fun getItemCount(): Int { |
|
||||||
return enumValues<DataType>().count() |
|
||||||
} |
|
||||||
|
|
||||||
override fun getItemViewType(position: Int): Int { |
|
||||||
return ROW_DATA |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
||||||
@ -1,55 +0,0 @@ |
|||||||
package net.pokeranalytics.android.ui.view |
|
||||||
|
|
||||||
import android.widget.FrameLayout |
|
||||||
import android.content.Context |
|
||||||
import android.util.AttributeSet |
|
||||||
import android.view.LayoutInflater |
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout |
|
||||||
import kotlinx.android.synthetic.main.row_data_cell.view.* |
|
||||||
import kotlinx.android.synthetic.main.row_data_content_view.view.* |
|
||||||
import net.pokeranalytics.android.R |
|
||||||
|
|
||||||
|
|
||||||
class DataRowView : FrameLayout { |
|
||||||
|
|
||||||
private lateinit var rowDataCell: ConstraintLayout |
|
||||||
|
|
||||||
/** |
|
||||||
* Constructors |
|
||||||
*/ |
|
||||||
constructor(context: Context) : super(context) { |
|
||||||
init() |
|
||||||
} |
|
||||||
|
|
||||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { |
|
||||||
init() |
|
||||||
} |
|
||||||
|
|
||||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { |
|
||||||
init() |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Init |
|
||||||
* |
|
||||||
* @param attrs |
|
||||||
*/ |
|
||||||
private fun init() { |
|
||||||
val layoutInflater = LayoutInflater.from(context) |
|
||||||
rowDataCell = layoutInflater.inflate(R.layout.row_data_content_view, this, false) as ConstraintLayout |
|
||||||
val layoutParams = FrameLayout.LayoutParams( |
|
||||||
FrameLayout.LayoutParams.MATCH_PARENT, |
|
||||||
FrameLayout.LayoutParams.WRAP_CONTENT |
|
||||||
) |
|
||||||
|
|
||||||
addView(rowDataCell, layoutParams) |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Set the session data to the view |
|
||||||
*/ |
|
||||||
fun setData(title: String) { |
|
||||||
rowDataCell.rowTitle.text = title |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,12 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<FrameLayout |
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android" |
|
||||||
android:layout_width="match_parent" |
|
||||||
android:layout_height="wrap_content"> |
|
||||||
|
|
||||||
<net.pokeranalytics.android.ui.view.DataRowView |
|
||||||
android:id="@+id/dataRow" |
|
||||||
android:layout_width="match_parent" |
|
||||||
android:layout_height="wrap_content" /> |
|
||||||
|
|
||||||
</FrameLayout> |
|
||||||
Loading…
Reference in new issue