|
|
|
|
@ -4,7 +4,6 @@ import android.os.Bundle |
|
|
|
|
import android.view.LayoutInflater |
|
|
|
|
import android.view.View |
|
|
|
|
import android.view.ViewGroup |
|
|
|
|
import android.view.inputmethod.EditorInfo |
|
|
|
|
import android.widget.EditText |
|
|
|
|
import androidx.lifecycle.ViewModelProviders |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_hand_history.* |
|
|
|
|
@ -19,11 +18,11 @@ import net.pokeranalytics.android.ui.adapter.RowRepresentableDataSource |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.RealmFragment |
|
|
|
|
import net.pokeranalytics.android.ui.modules.handhistory.views.KeyboardListener |
|
|
|
|
import net.pokeranalytics.android.ui.modules.handhistory.views.NumericKey |
|
|
|
|
import net.pokeranalytics.android.ui.modules.handhistory.views.StreetCardHeader |
|
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
|
import net.pokeranalytics.android.ui.view.SmoothScrollLinearLayoutManager |
|
|
|
|
import net.pokeranalytics.android.util.extensions.findById |
|
|
|
|
import net.pokeranalytics.android.util.extensions.noGroupingFormatted |
|
|
|
|
import timber.log.Timber |
|
|
|
|
|
|
|
|
|
class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepresentableDelegate, KeyboardListener { |
|
|
|
|
@ -114,7 +113,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr |
|
|
|
|
Timber.d("Current selection is ${selection.index} / ${selection.keyboard}") |
|
|
|
|
retrieveEditTextInputConnection(selection.index) |
|
|
|
|
} ?: run { |
|
|
|
|
this.keyboard.setInputConnection(null) |
|
|
|
|
this.keyboard.setEditText(null, null) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
@ -133,12 +132,12 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr |
|
|
|
|
|
|
|
|
|
private fun retrieveEditTextInputConnection(position: Int) { |
|
|
|
|
|
|
|
|
|
val computedAction = this.rowRepresentableForPosition(position) as? ComputedAction |
|
|
|
|
|
|
|
|
|
val holder = recyclerView.findViewHolderForAdapterPosition(position) as? HandHistoryAdapter.RowHandAction |
|
|
|
|
holder?.let { |
|
|
|
|
val inputConnection = it.itemView.findViewById<EditText>(R.id.amountEditText) |
|
|
|
|
.onCreateInputConnection(EditorInfo()) |
|
|
|
|
this.keyboard.setInputConnection(inputConnection) |
|
|
|
|
Timber.d("***** inputConnection = $inputConnection") |
|
|
|
|
val amountEditText = it.itemView.findViewById<EditText>(R.id.amountEditText) |
|
|
|
|
this.keyboard.setEditText(amountEditText, computedAction?.action?.amount) |
|
|
|
|
} ?: run { |
|
|
|
|
Timber.d("no holder, or not RowHandAction") |
|
|
|
|
} |
|
|
|
|
@ -194,23 +193,24 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// if (tag == HHKeyboard.ACTION.ordinal) { |
|
|
|
|
this.model.currentSelection.value?.index?.let { oldIndex -> |
|
|
|
|
refreshCells(oldIndex) |
|
|
|
|
} |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
this.model.currentSelection.value = HHSelection(position, HHKeyboard.values()[tag]) |
|
|
|
|
|
|
|
|
|
// scrolls to selected position |
|
|
|
|
// this.recyclerView.scrollToPosition(position) |
|
|
|
|
this.recyclerView.smoothScrollToPosition(position) |
|
|
|
|
|
|
|
|
|
val keyboard = when (row) { |
|
|
|
|
is ComputedAction -> { |
|
|
|
|
when (tag) { |
|
|
|
|
HHKeyboard.ACTION.ordinal -> HHKeyboard.ACTION |
|
|
|
|
HHKeyboard.AMOUNT.ordinal -> HHKeyboard.AMOUNT |
|
|
|
|
HHKeyboard.AMOUNT.ordinal -> { |
|
|
|
|
Timber.d("amount = ${row.action.amount}, toString = ${row.action.amount?.noGroupingFormatted}") |
|
|
|
|
this.model.currentAmount = row.action.amount?.noGroupingFormatted |
|
|
|
|
HHKeyboard.AMOUNT |
|
|
|
|
} |
|
|
|
|
else -> throw PAIllegalStateException("Unmanaged tag value: $tag") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -226,6 +226,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr |
|
|
|
|
|
|
|
|
|
override fun onRowDeselected(position: Int, row: RowRepresentable) { |
|
|
|
|
this.model.currentSelection.value = null |
|
|
|
|
this.model.currentAmount = null |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onRowValueChanged(value: Any?, row: RowRepresentable) { |
|
|
|
|
@ -280,7 +281,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr |
|
|
|
|
|
|
|
|
|
override fun clearAmount() { |
|
|
|
|
this.model.clearAmount() |
|
|
|
|
this.refreshCurrentRow() |
|
|
|
|
// this.refreshCurrentRow() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun closeKeyboard() { |
|
|
|
|
@ -291,8 +292,8 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDataSource, RowRepr |
|
|
|
|
this.keyboard?.hide() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun amountKeyTyped(key: NumericKey) { |
|
|
|
|
this.model.amountKeyTyped(key) |
|
|
|
|
override fun amountChanged(amount: String?) { |
|
|
|
|
this.model.amountChanged(amount) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Table refresh |
|
|
|
|
|