From 581efbf84f352439561801c91d977fd7551b6f94 Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 13 Apr 2020 13:25:02 +0200 Subject: [PATCH] Cleanup --- .../modules/handhistory/HandHistoryAdapter.kt | 17 ++++++++++------- .../modules/handhistory/HandHistoryFragment.kt | 3 +-- .../handhistory/model/HandHistoryViewModel.kt | 3 ++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt index 6f4d3e8f..cf89cace 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt @@ -39,6 +39,7 @@ import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.holder.RowViewHolder import net.pokeranalytics.android.ui.view.rowrepresentable.ViewIdentifier import net.pokeranalytics.android.util.extensions.formatted +import timber.log.Timber enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable { @@ -166,13 +167,18 @@ class HandHistoryAdapter( fun editTextSelected(editText: EditText) { -// editText.setBackgroundColor(color(selected)) val row = dataSource.rowRepresentableForPosition(this.currentPosition) ?: throw PAIllegalStateException("Row Representable not found at index: $currentPosition") - delegate?.onRowSelected(this.currentPosition, row, editText.tag as Int) + val tag = editText.tag as Int - setEditTextBackground(editText, true, true) + delegate?.onRowSelected(this.currentPosition, row, tag) + +// val text = dataSource.charSequenceForRow(row, itemView.context, tag) +// editText.hint = text +// editText.text = null + + setEditTextBackground(editText = editText, isEnabled = true, isFocused = true) } override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { @@ -435,10 +441,6 @@ class HandHistoryAdapter( itemView.action_container.background = background } -// actionReadRow.action?.let { type -> -// itemView.actionText.setTextColor(itemView.context.getColor(type.color)) -// } - itemView.amountText.text = actionReadRow.amount?.formatted } @@ -466,6 +468,7 @@ class HandHistoryAdapter( amountEditText.setOnTouchListener { _, event -> + Timber.d("=== event.action = ${event.action}") if (event.action == MotionEvent.ACTION_UP) { // Both are required, otherwise requestFocus() fails amountEditText.isFocusable = true diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt index e2490371..04dd2998 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt @@ -358,7 +358,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL override fun onRowDeselected(position: Int, row: RowRepresentable) { this.model.clearSelection() - this.model.currentAmount = null } override fun onRowValueChanged(value: Any?, row: RowRepresentable) { @@ -391,7 +390,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL this.handHistoryAdapter.notifyDataSetChanged() } is ComputedAction -> { - this.model.currentAmount = value as String + this.model.amountChanged(value as String) } is StraddleRowRepresentable -> { this.model.changeStraddleSelection(value as LinkedHashSet) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt index 3f274dd0..f0f29939 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt @@ -93,6 +93,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra fun clearSelection() { this.selectionLiveData.value = null + this.currentAmount = null } fun hasSelection(): Boolean { @@ -120,7 +121,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra /*** * The current amount edited by the user */ - var currentAmount: String? = null + private var currentAmount: String? = null /*** * The action index