Makes the position shorcuts work

hh
Laurent 6 years ago
parent d24ae60dd5
commit a5fb83fbe1
  1. 14
      app/src/main/java/net/pokeranalytics/android/model/handhistory/HHBuilder.kt
  2. 1
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  3. 6
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/PositionAdapter.kt
  4. 27
      app/src/main/res/layout/row_cell.xml

@ -179,6 +179,8 @@ class HHBuilder {
val dropedIndex = dropNextActionsIfNecessary(index)
this.addRequiredPlayerActions()
// Automatically sets action for the previous empty actions
val modifiedActions = mutableListOf<ComputedAction>()
getPreviousEmptyActions(index).forEach {
@ -195,6 +197,13 @@ class HHBuilder {
return modifiedActions.map { this.currentRowRepresentables.indexOf(it) }
}
/***
* Adds, if necessary, new ComputedAction for players that needs to act
*/
private fun addRequiredPlayerActions() {
// TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
private fun getPreviousEmptyActions(index: Int) : List<ComputedAction> {
val street = this.actionForIndex(index).action.street
return this.sortedActions.take(index).filter { it.action.street == street && it.action.type == null }
@ -428,7 +437,10 @@ class HHBuilder {
var i = actionIndexForSelection + 1
while (true) {
if (this.sortedActions[i].position == position) return i
val computedAction = this.actionForIndex(i)
if (computedAction.position == position) {
return this.rowRepresentables().indexOf(computedAction)
}
i++
if (i > this.sortedActions.size) throw PAIllegalStateException("algo sucks")
}

@ -303,6 +303,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr
val rowRepresentableIndex = this.model.nextActionIndexForPosition(position)
this.rowRepresentableForPosition(rowRepresentableIndex)?.let {
onRowSelected(rowRepresentableIndex, it, HHKeyboard.ACTION.ordinal)
this.handHistoryAdapter.notifyItemChanged(rowRepresentableIndex)
} ?: throw PAIllegalStateException("Rowrepresentable not fouind at index $rowRepresentableIndex")
}

@ -1,7 +1,9 @@
package net.pokeranalytics.android.ui.modules.handhistory.views
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import net.pokeranalytics.android.R
import net.pokeranalytics.android.model.handhistory.Position
import net.pokeranalytics.android.ui.adapter.BindableHolder
import net.pokeranalytics.android.ui.adapter.RecyclerAdapter
@ -9,6 +11,7 @@ import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType
import net.pokeranalytics.android.ui.view.holder.RowViewHolder
import timber.log.Timber
class PositionAdapter(var keyboardListener: KeyboardListener) :
@ -26,7 +29,8 @@ class PositionAdapter(var keyboardListener: KeyboardListener) :
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return RowViewType.values()[viewType].viewHolder(parent)
val layout = LayoutInflater.from(parent.context).inflate(R.layout.row_cell, parent, false)
return RowViewHolder(layout)
}
override fun getItemCount(): Int {

@ -0,0 +1,27 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="wrap_content"
android:layout_height="44dp"
android:background="@color/kaki_light"
android:foreground="?selectableItemBackground"
android:layout_marginStart="8dp"
android:padding="8dp">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:lines="1"
android:maxLines="1"
style="@style/PokerAnalyticsTheme.TextView.RowTitle"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Data Type Title" />
</androidx.constraintlayout.widget.ConstraintLayout>
Loading…
Cancel
Save