Improves keyboard layout

hh
Laurent 6 years ago
parent 61e77a55c6
commit 2aa63f8400
  1. 20
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  2. 8
      app/src/main/res/layout/view_hand_keyboard_action.xml
  3. 2
      app/src/main/res/layout/view_hand_keyboard_amount.xml
  4. 3
      app/src/main/res/layout/view_hand_keyboard_card.xml

@ -130,7 +130,9 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
keyboard?.let { keyboard?.let {
// this.animateKeyboard(true) // this.animateKeyboard(true)
this.showKeyboard(it) this.showKeyboard(it) {
this.scrollToPosition(selection.index)
}
// this.keyboard.show(it) // this.keyboard.show(it)
} ?: run { } ?: run {
this.animateKeyboard(false) this.animateKeyboard(false)
@ -139,6 +141,8 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
} ?: run { } ?: run {
this.animateKeyboard(false) this.animateKeyboard(false)
} }
} }
val observer = Observer<MutableList<RowRepresentable>> { val observer = Observer<MutableList<RowRepresentable>> {
@ -254,8 +258,6 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
refreshRowAtIndexAndCurrent(oldIndex) refreshRowAtIndexAndCurrent(oldIndex)
} }
this.scrollToPosition(position)
this.model.selectionLiveData.value = HHSelection(position, tag) this.model.selectionLiveData.value = HHSelection(position, tag)
} }
@ -437,18 +439,18 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
} }
private fun showKeyboard(keyboard: HHKeyboard) { private fun showKeyboard(keyboard: HHKeyboard, endHandler: (() -> (Unit))? = null) {
val lp = this.kbTopGuideline.layoutParams as ConstraintLayout.LayoutParams val lp = this.kbTopGuideline.layoutParams as ConstraintLayout.LayoutParams
if (lp.guideEnd == 0) { if (lp.guideEnd == 0) {
this.animateKeyboard(true) this.animateKeyboard(true, endHandler)
} }
this.keyboard.show(keyboard) this.keyboard.show(keyboard)
} }
private fun animateKeyboard(show: Boolean) { private fun animateKeyboard(show: Boolean, endHandler: (() -> (Unit))? = null) {
val height = 300.0f.px val height = 310.0f.px
val start = if (show) 0.0f else height val start = if (show) 0.0f else height
val end = if (show) height else 0.0f val end = if (show) height else 0.0f
@ -464,6 +466,10 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
lp.guideEnd = (it.animatedValue as Float).toInt() lp.guideEnd = (it.animatedValue as Float).toInt()
// update layout params // update layout params
this.kbTopGuideline.layoutParams = lp this.kbTopGuideline.layoutParams = lp
if (lp.guideEnd == end.toInt()) {
endHandler?.invoke()
}
} }
valueAnimator.start() valueAnimator.start()
} }

@ -7,12 +7,13 @@
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout <LinearLayout
android:id="@+id/toolbar"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/positionRecyclerView"> app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/closeButton" android:id="@+id/closeButton"
@ -31,14 +32,15 @@
android:layout_weight="1" android:layout_weight="1"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/recyclerView" app:layout_constraintTop_toBottomOf="@id/toolbar"
tools:layout_height="44dp" tools:layout_height="44dp"
/> />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView" android:id="@+id/recyclerView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="200dp" android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/positionRecyclerView"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"

@ -55,7 +55,7 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView" android:id="@+id/recyclerView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="240dp" android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"

@ -5,12 +5,13 @@
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout <LinearLayout
android:id="@+id/toolbar"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/valueRecyclerView"> app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/closeButton" android:id="@+id/closeButton"

Loading…
Cancel
Save