Commit 08536bd9 authored by Sophey Dong's avatar Sophey Dong Committed by Commit Bot

[QRCode Clank] Cancel old error toast before showing new toast.

Bug: 1143957
Change-Id: I60455afdfc375fc6a5d27e9c941acff96e70b6b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2509002Reviewed-by: default avatarTanya Gupta <tgupta@chromium.org>
Commit-Queue: Sophey Dong <sophey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823760}
parent c466f1fe
......@@ -49,6 +49,7 @@ public class QrCodeScanMediator implements Camera.PreviewCallback {
private final AndroidPermissionDelegate mPermissionDelegate;
private BarcodeDetector mDetector;
private Toast mToast;
/**
* The QrCodeScanMediator constructor.
......@@ -137,7 +138,7 @@ public class QrCodeScanMediator implements Camera.PreviewCallback {
/**
* Processes data received from the camera preview to detect QR/barcode containing URLs. If
* found, navigates to it by creating a new tab. If not found registers for camera preview
* callback again. Runs on the same tread that was used to open the camera.
* callback again. Runs on the same thread that was used to open the camera.
*/
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
......@@ -165,7 +166,11 @@ public class QrCodeScanMediator implements Camera.PreviewCallback {
if (!URLUtil.isValidUrl(firstCode.rawValue)) {
String toastMessage =
mContext.getString(R.string.qr_code_not_a_url_label, firstCode.rawValue);
Toast.makeText(mContext, toastMessage, Toast.LENGTH_LONG).show();
if (mToast != null) {
mToast.cancel();
}
mToast = Toast.makeText(mContext, toastMessage, Toast.LENGTH_LONG);
mToast.show();
RecordUserAction.record("SharingQRCode.ScannedNonURL");
camera.setOneShotPreviewCallback(this);
return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment