From 5891de3677516567bc210c145a5254e606a3ce9d Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 1 Sep 2020 11:47:59 +0200 Subject: [PATCH] Fixes hand created multiple times when going back and forth between editor and replayer --- .../android/ui/modules/handhistory/editor/EditorAdapter.kt | 6 ++++-- .../android/ui/modules/handhistory/editor/EditorFragment.kt | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/editor/EditorAdapter.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/editor/EditorAdapter.kt index 8e4526d2..11e42a90 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/editor/EditorAdapter.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/editor/EditorAdapter.kt @@ -346,8 +346,10 @@ class EditorAdapter( // Listener layout.setOnClickListener { - delegate?.onRowSelected(this.currentPosition, row, layout.tag as Int) - setViewBackground(layout, true, true) + if ((dataSource as EditorViewModel).isEdited) { + delegate?.onRowSelected(this.currentPosition, row, layout.tag as Int) + setViewBackground(layout, true, true) + } } } diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/editor/EditorFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/editor/EditorFragment.kt index b3288f8b..49e5bd7f 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/editor/EditorFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/editor/EditorFragment.kt @@ -72,8 +72,7 @@ class EditorFragment : RealmFragment(), RowRepresentableDelegate, KeyboardListen companion object { fun newInstance(id: String? = null, configurationId: String? = null, attached: Boolean = false): EditorFragment { - val fragment = - EditorFragment() + val fragment = EditorFragment() val bundle = Bundle() bundle.putSerializable(BundleKey.HAND_HISTORY_ID.value, id) bundle.putSerializable(BundleKey.CONFIGURATION_ID.value, configurationId) @@ -329,6 +328,7 @@ class EditorFragment : RealmFragment(), RowRepresentableDelegate, KeyboardListen */ private fun save() { this.model.save(getRealm()) + this.arguments?.putSerializable(BundleKey.HAND_HISTORY_ID.value, this.model.handHistory.id) } /***