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

fix(onDetect): Fixed bug where onDetect method was being called multiple times. #594

Merged
merged 1 commit into from
Apr 20, 2023

Conversation

AilurusRP
Copy link
Contributor

@AilurusRP AilurusRP commented Apr 13, 2023

A possible solution of this issue: Issue#510

In the relevant Kotlin code, to prevent duplicated invocation of the onDetect callback method upon successful barcode scanning, the function must exit immediately upon detecting the same barcode information within a short duration.
However, it has been observed that newScannedBarcodes is reset multiple times in quick succession, often resulting in an empty list. If newScannedBarcodes is reset to an empty list between two successful scans, and lastScanned is assigned a value from newScannedBarcodes, the code to prevent redundancies will fail. Therefore, a check has been added to determine if newScannedBarcodes is empty.

This modification has been successfully tested on Oneplus 8 (Color OS 13), resolving the issue of duplicate calls to onDetect.

@AilurusRP AilurusRP marked this pull request as ready for review April 13, 2023 12:23
@juliansteenbakker
Copy link
Owner

Thanks for your work!

@juliansteenbakker juliansteenbakker merged commit 905ee1a into juliansteenbakker:master Apr 20, 2023
@josephomills
Copy link

Thanks @AilurusRP!
@juliansteenbakker when can we have this fix available on pub.dev please? Still facing this issue on version 3.2.0 (latest)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants