Avoid crash in SendTransactionFragment.

- The crash was happening because the dialog that verifies the automatic time was being created in onResume, so if the user leaved the application while the fragment was showing and returned to it later another multiple dialogs would be created. The first one to be accepted correctly navigates the user back, but the second creates a crash because references a no longer existing fragment. The dialog creation was moved to onViewCreated instead, so that only one dialog is created.
This commit is contained in:
Severiano Jaramillo 2019-10-30 18:19:36 -06:00
parent 4c0f0e7da0
commit d14c10c672

View file

@ -221,6 +221,8 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
populatePropertiesFromQRCodeString(Invoice.toQrCode(invoice)) populatePropertiesFromQRCodeString(Invoice.toQrCode(invoice))
}, 2000) // Wait to let the other elements of the fragment initialize }, 2000) // Wait to let the other elements of the fragment initialize
} }
verifyGlobalSettingsTimeAutomatic()
} }
/** Handles the selection of items in the Asset spinner, to keep track of the selectedAssetSymbol and show the /** Handles the selection of items in the Asset spinner, to keep track of the selectedAssetSymbol and show the
@ -592,7 +594,7 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
title(R.string.title__time_sync_error) title(R.string.title__time_sync_error)
message(R.string.msg__time_sync_error) message(R.string.msg__time_sync_error)
positiveButton(android.R.string.ok) { positiveButton(android.R.string.ok) {
this@SendTransactionFragment.findNavController().navigateUp() findNavController().navigateUp()
} }
cancelable(false) cancelable(false)
cancelOnTouchOutside(false) cancelOnTouchOutside(false)
@ -639,8 +641,6 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
if (isCameraPreviewVisible) if (isCameraPreviewVisible)
startCameraPreview() startCameraPreview()
verifyGlobalSettingsTimeAutomatic()
} }
override fun onPause() { override fun onPause() {