|
|
|
|
@ -1,7 +1,10 @@ |
|
|
|
|
package net.pokeranalytics.android.ui.modules.handhistory |
|
|
|
|
|
|
|
|
|
import android.animation.ValueAnimator |
|
|
|
|
import android.os.Bundle |
|
|
|
|
import android.view.* |
|
|
|
|
import android.view.animation.AccelerateDecelerateInterpolator |
|
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout |
|
|
|
|
import androidx.lifecycle.Observer |
|
|
|
|
import androidx.lifecycle.ViewModelProviders |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_hand_history.* |
|
|
|
|
@ -14,6 +17,7 @@ import net.pokeranalytics.android.model.realm.handhistory.Action |
|
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.Card |
|
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.HandHistory |
|
|
|
|
import net.pokeranalytics.android.ui.adapter.RowRepresentableDelegate |
|
|
|
|
import net.pokeranalytics.android.ui.extensions.px |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.RealmFragment |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetFragment |
|
|
|
|
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetType |
|
|
|
|
@ -125,13 +129,15 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
keyboard?.let { |
|
|
|
|
this.keyboard.show(it) |
|
|
|
|
// this.animateKeyboard(true) |
|
|
|
|
this.showKeyboard(it) |
|
|
|
|
// this.keyboard.show(it) |
|
|
|
|
} ?: run { |
|
|
|
|
this.keyboard.hide() |
|
|
|
|
this.animateKeyboard(false) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} ?: run { |
|
|
|
|
this.keyboard.hide() |
|
|
|
|
this.animateKeyboard(false) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -152,6 +158,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
initKeyboard() |
|
|
|
|
this.keyboard.keyboardListener = this |
|
|
|
|
this.keyboard.setCardCentralizer(this.model) |
|
|
|
|
} |
|
|
|
|
@ -206,30 +213,15 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
this.findNextActionToEdit(0) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun closeEdition() { |
|
|
|
|
this.model.isEdited = false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun findNextActionToEdit(index: Int? = null, userInitiated: Boolean = false) { |
|
|
|
|
|
|
|
|
|
val startIndex = index ?: this.model.currentSelection.index |
|
|
|
|
val minTag = if (index != null) null else this.model.currentSelection.tag |
|
|
|
|
|
|
|
|
|
this.model.findSelectionForEdition(startIndex, minTag, userInitiated)?.let { selection -> |
|
|
|
|
|
|
|
|
|
this.scrollToPosition(selection.index) |
|
|
|
|
|
|
|
|
|
// this.model.currentKeyboard?.let { keyboard -> |
|
|
|
|
// when (keyboard) { |
|
|
|
|
// HHKeyboard.ACTION -> { |
|
|
|
|
// configureActionKeyboard() |
|
|
|
|
// } else -> {} |
|
|
|
|
// } |
|
|
|
|
// this.keyboard.show(keyboard) |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
} ?: run { |
|
|
|
|
this.keyboard.hide() |
|
|
|
|
this.animateKeyboard(false) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// The whole data set is refreshed because of a weird EditText bug where |
|
|
|
|
@ -249,7 +241,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
when (row.bottomSheetType) { |
|
|
|
|
when (row.bottomSheetType) { // Comment, number of players |
|
|
|
|
BottomSheetType.NONE -> {} |
|
|
|
|
else -> { |
|
|
|
|
val editDescriptors = listOf(RowRepresentableEditDescriptor(this.model.handHistory.comment, R.string.comment)) |
|
|
|
|
@ -404,7 +396,8 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
val currentIndex = this.model.currentSelection.index |
|
|
|
|
this.model.selectionLiveData.value = null |
|
|
|
|
this.handHistoryAdapter.notifyItemChanged(currentIndex) |
|
|
|
|
this.keyboard?.hide() |
|
|
|
|
this.animateKeyboard(false) |
|
|
|
|
// this.hideKeyboard() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun positionSelected(position: Position) { |
|
|
|
|
@ -443,4 +436,42 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun showKeyboard(keyboard: HHKeyboard) { |
|
|
|
|
|
|
|
|
|
val lp = this.kbTopGuideline.layoutParams as ConstraintLayout.LayoutParams |
|
|
|
|
if (lp.guideEnd == 0) { |
|
|
|
|
this.animateKeyboard(true) |
|
|
|
|
} |
|
|
|
|
this.keyboard.show(keyboard) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun animateKeyboard(show: Boolean) { |
|
|
|
|
|
|
|
|
|
val height = 300.0f.px |
|
|
|
|
val start = if (show) 0.0f else height |
|
|
|
|
val end = if (show) height else 0.0f |
|
|
|
|
|
|
|
|
|
// val end = (this.kbTopGuideline.layoutParams as ConstraintLayout.LayoutParams).guideEnd |
|
|
|
|
val valueAnimator = ValueAnimator.ofFloat(start, end) |
|
|
|
|
valueAnimator.duration = 150L |
|
|
|
|
// set duration |
|
|
|
|
valueAnimator.interpolator = AccelerateDecelerateInterpolator() |
|
|
|
|
// set interpolator and updateListener to get the animated value |
|
|
|
|
valueAnimator.addUpdateListener { |
|
|
|
|
val lp = this.kbTopGuideline.layoutParams as ConstraintLayout.LayoutParams |
|
|
|
|
// get the float value |
|
|
|
|
lp.guideEnd = (it.animatedValue as Float).toInt() |
|
|
|
|
// update layout params |
|
|
|
|
this.kbTopGuideline.layoutParams = lp |
|
|
|
|
} |
|
|
|
|
valueAnimator.start() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun initKeyboard() { |
|
|
|
|
val lp = this.kbTopGuideline.layoutParams as ConstraintLayout.LayoutParams |
|
|
|
|
lp.guideEnd = 0 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |