Fixes a couple of crash

hh
Laurent 5 years ago
parent 1907b97d59
commit 05e7910e34
  1. 34
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  2. 2
      app/src/main/res/values/strings.xml

@ -60,6 +60,8 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
*/
private var menu: Menu? = null
private var replayerItem: MenuItem? = null
val isEditing: Boolean
get() {
return this.model.isEdited
@ -117,12 +119,14 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
val hhCopy = getRealm().copyFromRealm(handHistory)
this.model.setHandHistory(hhCopy)
this.setEditing(false)
this.replayerItem?.isEnabled = true
} ?: run {
val configurationId = this.arguments?.getString(BundleKey.CONFIGURATION_ID.value)
val attached = this.arguments?.getBoolean(BundleKey.ATTACHED.value) ?: false
this.model.createNewHandHistory(getRealm(), configurationId, attached)
this.setEditing(true)
this.replayerItem?.isEnabled = false
}
}
@ -207,7 +211,13 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
*/
private fun updateMenuUI() {
val titleResId = if (this.model.isEdited) R.string.save else R.string.edit
this.menu?.findItem(R.id.edit_save)?.setTitle(titleResId)
this.menu?.let { menu ->
menu.findItem(R.id.edit_save)?.setTitle(titleResId)
this.replayerItem = menu.findItem(R.id.replayer)
this.replayerItem?.isEnabled = this.model.handHistory.isManaged
Timber.d("this.replayerItem = ${this.replayerItem}")
}
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
@ -307,6 +317,7 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
if (!this.model.isEdited) {
this.save()
this.replayerItem?.isEnabled = true
}
this.handHistoryAdapter.notifyDataSetChanged()
@ -628,15 +639,20 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
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
if (lp.guideEnd == end.toInt()) {
endHandler?.invoke()
this.kbTopGuideline?.let { topGuideline ->
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
if (lp.guideEnd == end.toInt()) {
endHandler?.invoke()
}
}
}
valueAnimator.start()
}

@ -803,6 +803,6 @@
<string name="video_available">Video available!</string>
<string name="video_retrieval_message">Your video has been generated at the following path</string>
<string name="open_file_with">Open file with</string>
<string name="video_export_started">Your video is currently exported, we\'ll send you a notification when it\'s available. Expect approximately one minute!</string>
<string name="video_export_started">We\'ll send you a notification when your video is available. Expect approximately one minute!</string>
</resources>

Loading…
Cancel
Save