commit
96c1c3316c
@ -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,62 +0,0 @@ |
|||||||
package net.pokeranalytics.android.ui.fragment.components.bottomsheet |
|
||||||
|
|
||||||
import android.os.Bundle |
|
||||||
import android.view.LayoutInflater |
|
||||||
import android.view.View |
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager |
|
||||||
import kotlinx.android.synthetic.main.bottom_sheet_double_list.* |
|
||||||
import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.* |
|
||||||
import net.pokeranalytics.android.R |
|
||||||
import net.pokeranalytics.android.model.realm.Game |
|
||||||
import net.pokeranalytics.android.ui.adapter.components.LiveDataAdapter |
|
||||||
import net.pokeranalytics.android.ui.adapter.components.LiveDataDataSource |
|
||||||
import net.pokeranalytics.android.ui.adapter.components.LiveDataDelegate |
|
||||||
|
|
||||||
|
|
||||||
class BottomSheetDoubleListFragment : BottomSheetFragment(), LiveDataDelegate { |
|
||||||
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
||||||
super.onViewCreated(view, savedInstanceState) |
|
||||||
initData() |
|
||||||
initUI() |
|
||||||
} |
|
||||||
|
|
||||||
override fun data(position: Int): LiveDataDataSource { |
|
||||||
//TODO: Change that |
|
||||||
return Game() |
|
||||||
} |
|
||||||
|
|
||||||
override fun onRowSelected(position: Int) { |
|
||||||
} |
|
||||||
|
|
||||||
override fun size(): Int { |
|
||||||
return 1 |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Init data |
|
||||||
*/ |
|
||||||
private fun initData() { |
|
||||||
val data = getData() |
|
||||||
//game = if (data is Game) data else Game() |
|
||||||
//game.title = "Test" |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Init UI |
|
||||||
*/ |
|
||||||
private fun initUI() { |
|
||||||
LayoutInflater.from(requireContext()).inflate(R.layout.bottom_sheet_double_list, view?.bottomSheetContainer, true) |
|
||||||
|
|
||||||
val viewManager = LinearLayoutManager(requireContext()) |
|
||||||
val dataAdapter = LiveDataAdapter(this, R.layout.row_bottom_sheet_title) |
|
||||||
|
|
||||||
reyclerView1.apply { |
|
||||||
setHasFixedSize(true) |
|
||||||
layoutManager = viewManager |
|
||||||
adapter = dataAdapter |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -0,0 +1,103 @@ |
|||||||
|
package net.pokeranalytics.android.ui.fragment.components.bottomsheet |
||||||
|
|
||||||
|
import android.os.Bundle |
||||||
|
import android.view.LayoutInflater |
||||||
|
import android.view.View |
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager |
||||||
|
import io.realm.RealmResults |
||||||
|
import kotlinx.android.synthetic.main.bottom_sheet_game_list.* |
||||||
|
import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.* |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.model.realm.Game |
||||||
|
import net.pokeranalytics.android.ui.adapter.LimitTypesAdapter |
||||||
|
import net.pokeranalytics.android.ui.adapter.components.LiveDataAdapter |
||||||
|
import net.pokeranalytics.android.ui.adapter.components.LiveDataDataSource |
||||||
|
import net.pokeranalytics.android.ui.adapter.components.LiveDataDelegate |
||||||
|
import timber.log.Timber |
||||||
|
|
||||||
|
|
||||||
|
class BottomSheetListGameFragment : BottomSheetFragment(), LiveDataDelegate { |
||||||
|
|
||||||
|
private var realmData: RealmResults<*>? = null |
||||||
|
private lateinit var dataAdapter: LiveDataAdapter |
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||||
|
super.onViewCreated(view, savedInstanceState) |
||||||
|
initData() |
||||||
|
initUI() |
||||||
|
} |
||||||
|
|
||||||
|
override fun onResume() { |
||||||
|
super.onResume() |
||||||
|
dataAdapter.notifyDataSetChanged() |
||||||
|
} |
||||||
|
|
||||||
|
override fun data(position: Int): LiveDataDataSource { |
||||||
|
realmData?.let { |
||||||
|
return it[position] as LiveDataDataSource |
||||||
|
} |
||||||
|
//TODO: Change that |
||||||
|
return Game() |
||||||
|
} |
||||||
|
|
||||||
|
override fun onRowSelected(position: Int) { |
||||||
|
realmData?.let { |
||||||
|
val selectedData = it[position] |
||||||
|
selectedData?.let {data -> |
||||||
|
bottomSheetDelegate.setValue(data, row) |
||||||
|
dismiss() |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun size(): Int { |
||||||
|
|
||||||
|
Timber.d("Games: ${realmData?.size}") |
||||||
|
|
||||||
|
return realmData?.size ?: 0 |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Init data |
||||||
|
*/ |
||||||
|
private fun initData() { |
||||||
|
val bottomSheetData = getData() |
||||||
|
if (bottomSheetData.isNotEmpty() && bottomSheetData.size >= 2 && bottomSheetData[1].data != null) { |
||||||
|
this.realmData = bottomSheetData[1].data as RealmResults<*> |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Init UI |
||||||
|
*/ |
||||||
|
private fun initUI() { |
||||||
|
|
||||||
|
LayoutInflater.from(requireContext()).inflate(R.layout.bottom_sheet_game_list, view?.bottomSheetContainer, true) |
||||||
|
|
||||||
|
val limits = ArrayList<String>() |
||||||
|
limits.addAll(resources.getStringArray(R.array.limit_short_name)) |
||||||
|
|
||||||
|
|
||||||
|
val viewManager1 = LinearLayoutManager(requireContext()) |
||||||
|
val gameDataAdapter1 = LimitTypesAdapter(limits) |
||||||
|
|
||||||
|
recyclerView1.apply { |
||||||
|
setHasFixedSize(true) |
||||||
|
layoutManager = viewManager1 |
||||||
|
adapter = gameDataAdapter1 |
||||||
|
isNestedScrollingEnabled = false |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
val viewManager2 = LinearLayoutManager(requireContext()) |
||||||
|
dataAdapter = LiveDataAdapter(this, R.layout.row_bottom_sheet_title) |
||||||
|
|
||||||
|
recyclerView2.apply { |
||||||
|
setHasFixedSize(true) |
||||||
|
layoutManager = viewManager2 |
||||||
|
adapter = dataAdapter |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -1,19 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
||||||
android:layout_width="match_parent" |
|
||||||
android:layout_height="match_parent" |
|
||||||
android:orientation="horizontal"> |
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView |
|
||||||
android:id="@+id/reyclerView1" |
|
||||||
android:layout_width="80dp" |
|
||||||
android:layout_height="wrap_content" |
|
||||||
android:minHeight="200dp" /> |
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView |
|
||||||
android:id="@+id/reyclerView2" |
|
||||||
android:layout_width="match_parent" |
|
||||||
android:layout_height="wrap_content" |
|
||||||
android:minHeight="200dp" /> |
|
||||||
|
|
||||||
</LinearLayout> |
|
||||||
@ -0,0 +1,25 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<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="wrap_content" |
||||||
|
android:orientation="horizontal"> |
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView |
||||||
|
android:id="@+id/recyclerView1" |
||||||
|
android:layout_width="80dp" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
app:layout_constraintBottom_toBottomOf="parent" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toTopOf="parent" /> |
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView |
||||||
|
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" /> |
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout> |
||||||
@ -0,0 +1,44 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<resources> |
||||||
|
<array name="blind_structure"> |
||||||
|
<item>2</item> |
||||||
|
<item>4</item> |
||||||
|
<item>6</item> |
||||||
|
<item>10</item> |
||||||
|
<item>20</item> |
||||||
|
<item>40</item> |
||||||
|
<item>50</item> |
||||||
|
<item>60</item> |
||||||
|
<item>80</item> |
||||||
|
<item>100</item> |
||||||
|
<item>150</item> |
||||||
|
<item>200</item> |
||||||
|
<item>250</item> |
||||||
|
<item>300</item> |
||||||
|
<item>400</item> |
||||||
|
<item>500</item> |
||||||
|
<item>600</item> |
||||||
|
<item>800</item> |
||||||
|
<item>1000</item> |
||||||
|
<item>1200</item> |
||||||
|
<item>1600</item> |
||||||
|
<item>2000</item> |
||||||
|
<item>2500</item> |
||||||
|
<item>3000</item> |
||||||
|
<item>4000</item> |
||||||
|
<item>5000</item> |
||||||
|
<item>6000</item> |
||||||
|
<item>8000</item> |
||||||
|
<item>10000</item> |
||||||
|
<item>12000</item> |
||||||
|
<item>15000</item> |
||||||
|
<item>20000</item> |
||||||
|
<item>25000</item> |
||||||
|
<item>30000</item> |
||||||
|
<item>40000</item> |
||||||
|
<item>50000</item> |
||||||
|
<item>60000</item> |
||||||
|
<item>80000</item> |
||||||
|
<item>100000</item> |
||||||
|
</array> |
||||||
|
</resources> |
||||||
@ -0,0 +1,17 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<resources> |
||||||
|
<string-array name="limit_name"> |
||||||
|
<item>No Limit</item> |
||||||
|
<item>Pot Limit</item> |
||||||
|
<item>Fixed Limit</item> |
||||||
|
<item>Spread Limit</item> |
||||||
|
<item>Mixed Limit</item> |
||||||
|
</string-array> |
||||||
|
<string-array name="limit_short_name"> |
||||||
|
<item>NL</item> |
||||||
|
<item>PL</item> |
||||||
|
<item>FL</item> |
||||||
|
<item>SL</item> |
||||||
|
<item>ML</item> |
||||||
|
</string-array> |
||||||
|
</resources> |
||||||
@ -0,0 +1,21 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<resources> |
||||||
|
<string-array name="game_name"> |
||||||
|
<item>Hold\'em</item> |
||||||
|
<item>Omaha</item> |
||||||
|
<item>Omaha Hi-Low</item> |
||||||
|
<item>Seven Card Stud</item> |
||||||
|
<item>Seven Card Stud Hi-Low</item> |
||||||
|
<item>H.O.R.S.E.</item> |
||||||
|
<item>Seven Card Razz</item> |
||||||
|
</string-array> |
||||||
|
<string-array name="game_short_name"> |
||||||
|
<item>HE</item> |
||||||
|
<item>OH</item> |
||||||
|
<item>OH8</item> |
||||||
|
<item>7S</item> |
||||||
|
<item>Stud8</item> |
||||||
|
<item>HORSE</item> |
||||||
|
<item>Razz</item> |
||||||
|
</string-array> |
||||||
|
</resources> |
||||||
Loading…
Reference in new issue