parent
8fe25094de
commit
3c952a13c6
@ -0,0 +1,50 @@ |
||||
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_bottom_sheet_grid_title.view.* |
||||
import net.pokeranalytics.android.R |
||||
|
||||
class LimitTypesAdapter(private var tableSizes: ArrayList<String>) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { |
||||
|
||||
companion object { |
||||
const val ROW_LIMIT: Int = 100 |
||||
} |
||||
|
||||
var onClickOnItem: ((position: Int) -> Unit)? = null |
||||
|
||||
inner class CellSessionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { |
||||
|
||||
fun bind(tableSize: String) { |
||||
itemView.title.text = tableSize |
||||
itemView.container.setOnClickListener { |
||||
onClickOnItem?.invoke(adapterPosition) |
||||
} |
||||
} |
||||
} |
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { |
||||
when (viewType) { |
||||
ROW_LIMIT -> return CellSessionViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.row_bottom_sheet_title, parent, false)) |
||||
else -> throw IllegalStateException("Need to implement type $viewType in HistoryAdapter") |
||||
} |
||||
} |
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { |
||||
when (getItemViewType(position)) { |
||||
ROW_LIMIT -> (holder as LimitTypesAdapter.CellSessionViewHolder).bind(tableSizes[position]) |
||||
} |
||||
} |
||||
|
||||
override fun getItemCount(): Int { |
||||
return tableSizes.size |
||||
} |
||||
|
||||
override fun getItemViewType(position: Int): Int { |
||||
return ROW_LIMIT |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -1,19 +1,25 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="horizontal"> |
||||
|
||||
<androidx.recyclerview.widget.RecyclerView |
||||
android:id="@+id/reyclerView1" |
||||
android:id="@+id/recyclerView1" |
||||
android:layout_width="80dp" |
||||
android:layout_height="wrap_content" |
||||
android:minHeight="200dp" /> |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" /> |
||||
|
||||
<androidx.recyclerview.widget.RecyclerView |
||||
android:id="@+id/reyclerView2" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:minHeight="200dp" /> |
||||
android:id="@+id/recyclerView2" |
||||
android:layout_width="0dp" |
||||
android:layout_height="0dp" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toEndOf="@+id/recyclerView1" |
||||
app:layout_constraintTop_toTopOf="parent" /> |
||||
|
||||
</LinearLayout> |
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
Loading…
Reference in new issue