Skip to content

Commit

Permalink
AND-8958 fix double dialog showing (use onDismiss callback)
Browse files Browse the repository at this point in the history
  • Loading branch information
kozarezvlad committed Nov 11, 2024
1 parent dd18eab commit 7b8ee9d
Showing 1 changed file with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,36 @@ class DefaultSessionViewDelegate(
Log.view { "createAndShowState" }
// Under the hood dialog dismiss could work async and new dialog could be created
// before old one is dismissed, that leads to 2 dialogs on screen.
// Trying to use delay after dismiss previous dialog to avoid this
// Create new one in onDismiss callback
postUI {
readingDialog?.dismissInternal()
}
postUI(DIALOG_CREATION_DELAY) {
with(createReadingDialog(activity, iconScanRes)) {
Log.view { "createReadingDialog readingDialog $this" }
showHowTo(enableHowTo)
setInitialMessage(message)
setScanImage(sdkConfig.scanTagImage)
show(state)
if (readingDialog != null) {
readingDialog?.setOnDismissListener {
Log.view { "old readingDialog onDismiss callback" }
createAndConfigureDialog(state, enableHowTo, message, iconScanRes)
}
readingDialog?.dismissInternal()
} else {
Log.view { "createAndConfigDialog" }
createAndConfigureDialog(state, enableHowTo, message, iconScanRes)
}
}
}

private fun createAndConfigureDialog(
state: SessionViewDelegateState,
enableHowTo: Boolean,
message: ViewDelegateMessage? = null,
iconScanRes: Int? = null,
) {
with(createReadingDialog(activity, iconScanRes)) {
Log.view { "createReadingDialog readingDialog $this" }
showHowTo(enableHowTo)
setInitialMessage(message)
setScanImage(sdkConfig.scanTagImage)
show(state)
}
}

private fun createReadingDialog(activity: Activity, iconScanRes: Int? = null): NfcSessionDialog {
Log.view { "createReadingDialog" }
return NfcSessionDialog(
Expand Down Expand Up @@ -231,7 +246,6 @@ class DefaultSessionViewDelegate(
}

companion object {
private const val DIALOG_CREATION_DELAY = 200L
private const val DIALOG_NFC_DELAY = 800L
}
}

0 comments on commit 7b8ee9d

Please sign in to comment.