Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AND-8958 dialog double showing #419

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
Loading