From 6c6cf9a60f8e3527562f46ae959a049d4a619dbb Mon Sep 17 00:00:00 2001 From: Laurent Date: Sun, 28 Feb 2021 14:16:18 +0100 Subject: [PATCH] Adds more logging when a crash occurs --- .../handhistory/editor/EditorFragment.kt | 21 +++++++++++++------ .../handhistory/model/EditorViewModel.kt | 5 +++-- 2 files changed, 18 insertions(+), 8 deletions(-) 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 c51ab369..ad5e63a4 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 @@ -33,6 +33,7 @@ import net.pokeranalytics.android.ui.modules.handhistory.model.* import net.pokeranalytics.android.ui.modules.handhistory.views.KeyboardListener import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.SmoothScrollLinearLayoutManager +import net.pokeranalytics.android.util.CrashLogging import net.pokeranalytics.android.util.extensions.findById import timber.log.Timber @@ -160,14 +161,22 @@ class EditorFragment : RealmFragment(), RowRepresentableDelegate, KeyboardListen // At first, the selection is defined before the holder is bound, // so we retrieve the editText inputConnection once the recycler view has been rendered this.binding.recyclerView.viewTreeObserver.addOnGlobalLayoutListener { - when (this.model.currentKeyboard) { - HHKeyboard.AMOUNT -> { - val selection = this.model.currentSelection - retrieveEditTextInputConnection(selection) - } - else -> { + + try { + when (this.model.currentKeyboard) { + HHKeyboard.AMOUNT -> { + val selection = this.model.currentSelection + retrieveEditTextInputConnection(selection) + } + else -> { + } } + } catch (e: Exception) { + val actions = this.model.actionListLogs + CrashLogging.log(actions) + throw e } + } initKeyboardDefaultHeight() diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/EditorViewModel.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/EditorViewModel.kt index 84824b06..caaccc23 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/EditorViewModel.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/EditorViewModel.kt @@ -557,8 +557,7 @@ class EditorViewModel : ViewModel(), RowRepresentableDataSource, CardCentralizer else -> {} } } catch (e: Exception) { - val actions = this.sortedActions.joinToString("\n") { it.logRepresentation } - CrashLogging.log(actions) + CrashLogging.log(this.actionListLogs) throw e } @@ -1058,4 +1057,6 @@ class EditorViewModel : ViewModel(), RowRepresentableDataSource, CardCentralizer this.createRowRepresentation() } + val actionListLogs: String = this.sortedActions.joinToString("\n") { it.logRepresentation } + } \ No newline at end of file