Skip to content

Conversation

@4BooM04
Copy link
Contributor

@4BooM04 4BooM04 commented Nov 26, 2025

No description provided.

@4BooM04 4BooM04 self-assigned this Nov 26, 2025
@4BooM04 4BooM04 changed the title update snippets to new result api [EPIC-6660] update snippets to new result api Nov 26, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates code snippets to migrate from the old activity result API to a new result API pattern. The changes modernize result handling by replacing registerForActivityResultOk with registerForActivityResult and using onSuccess/onFailure extension functions for cleaner error handling.

Key Changes

  • Migrated from registerForActivityResultOk to registerForActivityResult with onSuccess/onFailure handlers
  • Added comprehensive error handling with specific error type cases (InvalidLicenseError, OperationCanceledError)
  • Updated SDK version from 8.0.0.61-STAGING-SNAPSHOT to 8.0.0.62-STAGING-SNAPSHOT

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
SinglePagePreviewActivity.kt Updated cropping result handler to use new API
MainActivity.kt (document-scanner) Updated document scanner result handler with error handling
StandaloneCropScreenSnippet.kt Updated cropping UI snippet with comprehensive error handling
Multiple snippet files Migrated all RTU UI snippets to new result API pattern
QuickStartSnippets.kt Simplified result parameter naming
VinUiSnippet.kt Added error handling to all VIN scanner snippets
TextPatternUiSnippet.kt Added error handling to all text pattern scanner snippets
MrzUiSnippet.kt Added error handling to all MRZ scanner snippets
RtuUi2DocumentSnippets.kt Updated migration snippets to new API
DataExtractionUiSnippet.kt Added error handling to all data extractor snippets
CreditCardUiSnippet.kt Added error handling and fixed credit card result handling
CheckUiSnippet.kt Added error handling to all check scanner snippets
MainActivity.kt (data-capture) Updated multiple scanner result handlers
app/build.gradle files Bumped SDK version to 8.0.0.62-STAGING-SNAPSHOT

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

registerForActivityResult(CreditCardScannerActivity.ResultContract()) { resultEntity ->
resultEntity.onSuccess { creditCardResult ->
creditCardResult.creditCard?.let {
val creditCard = CreditCard(creditCardResult.creditCard!!)
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant null check followed by non-null assertion. Line 51 already verifies creditCard is not null with let, but line 52 uses the non-null assertion operator (!!) which could fail if the value is actually null. Either remove the let check or use the safe reference it instead of creditCardResult.creditCard!!.

Suggested change
val creditCard = CreditCard(creditCardResult.creditCard!!)
val creditCard = CreditCard(it)

Copilot uses AI. Check for mistakes.
resultEntity.result?.mrzDocument?.let {
showMrzDialog(it)
}
resultEntity?.mrzDocument?.let {
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resultEntity is nullable but registerForActivityResultOk should return a non-null result. This inconsistency suggests either the helper function signature is incorrect or the null-safe operator is unnecessary.

Suggested change
resultEntity?.mrzDocument?.let {
resultEntity.mrzDocument.let {

Copilot uses AI. Check for mistakes.
checkScannerResultLauncher =
registerForActivityResultOk(CheckScannerActivity.ResultContract()) { resultEntity ->
handleCheckScannerResult(resultEntity.result!!)
handleCheckScannerResult(resultEntity)
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function handleCheckScannerResult expects a non-null result, but if registerForActivityResultOk can return null, this will cause a runtime error. Consider adding a null check or verifying the return type of registerForActivityResultOk.

Suggested change
handleCheckScannerResult(resultEntity)
resultEntity?.let { handleCheckScannerResult(it) }

Copilot uses AI. Check for mistakes.
…bot/example/doc_code_snippet/creditcard/CreditCardUiSnippet.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants