Various fixes and improvements

hh
Laurent 5 years ago
parent be479ed0b5
commit 3279abcaff
  1. 9
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  2. 25
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  3. 4
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/StreetCardsRow.kt
  4. 2
      app/src/main/res/drawable/rounded_board_background.xml

@ -173,7 +173,7 @@ class HandHistoryAdapter(
delegate?.onRowSelected(this.currentPosition, row, tag)
setEditTextBackground(editText = editText, isEnabled = true, isFocused = true)
setViewBackground(view = editText, isEnabled = true, isFocused = true)
}
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
@ -213,19 +213,19 @@ class HandHistoryAdapter(
}
// Background
setEditTextBackground(editText, isEnabled, isFocused)
setViewBackground(editText, isEnabled, isFocused)
}
}
private fun setEditTextBackground(editText: EditText, isEnabled: Boolean, isFocused: Boolean) {
private fun setViewBackground(view: View, isEnabled: Boolean, isFocused: Boolean) {
val background = when {
!isEnabled -> R.drawable.rounded_kaki_darkest_rect // disabled
isFocused -> R.drawable.rounded_kaki_medium_rect // focused
else -> R.drawable.rounded_kaki_darker_rect // default
}
editText.background = itemView.context.getDrawable(background)
view.background = itemView.context.getDrawable(background)
}
protected fun configureTextView(tag: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
@ -347,6 +347,7 @@ class HandHistoryAdapter(
// Listener
layout.setOnClickListener {
delegate?.onRowSelected(this.currentPosition, row, layout.tag as Int)
setViewBackground(layout, true, true)
}
}

@ -403,22 +403,21 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
}
}
if (row is HandHistoryRow) {
if (this.model.hasSelection()) {
this.model.amountValidated() // validates any edited amount before possibly clearing action
refreshRowAtIndexAndCurrent(this.model.currentSelection.index)
}
when (row) {
is HandHistoryRow -> {
// this.model.selectionLiveData.value?.index?.let { oldIndex ->
// refreshRowAtIndexAndCurrent(oldIndex)
// }
if (this.model.hasSelection()) {
this.model.amountValidated() // validates any edited amount before possibly clearing action
refreshRowAtIndexAndCurrent(this.model.currentSelection.index)
}
val newSelection = HHSelection(position, tag)
this.model.setSelection(newSelection)
val newSelection = HHSelection(position, tag)
this.model.setSelection(newSelection)
// this.model.selectionLiveData.value = HHSelection(position, tag)
}
is StreetCardsRow -> {
}
}
}
@ -528,7 +527,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
override fun clearCards() {
this.model.clearCards()
this.handHistoryAdapter.notifyItemChanged(this.model.currentSelection.index)
this.handHistoryAdapter.notifyDataSetChanged() // multiple rows can be impacted
}
override fun cardSelectionEnded() {

@ -33,6 +33,10 @@ class StreetCardsRow(var street: Street, var handHistory: HandHistory) : CardsRo
}
}
override fun clear() {
this.cardHolder?.cards?.removeAll { it.street == street }
}
override fun isFieldNeedsInput(tag: Int, handHistory: HandHistory): Boolean {
val street = Street.values()[tag]
return this.cardCount < street.totalBoardCards || this.handHistory.cards.elementAtOrNull(street.totalBoardCards - 1)?.suit == null

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/kaki"/>
<solid android:color="@color/kaki_darker"/>
<!-- <stroke android:width="3dp" android:color="#B1BCBE" />-->
<corners android:radius="6dp"/>
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />

Loading…
Cancel
Save