Skip to content

Commit

Permalink
Merge pull request #348 from gini/PIA-4414-fix-qr-code-stuck
Browse files Browse the repository at this point in the history
fix(capture-sdk): Fix QR code stuck
  • Loading branch information
abolfazlimahdi authored Sep 1, 2023
2 parents 4add54f + ba8a2ea commit a72d692
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import net.gini.android.capture.AsyncCallback;
import net.gini.android.capture.Document;
Expand All @@ -38,6 +37,7 @@
import net.gini.android.capture.document.ImageMultiPageDocument;
import net.gini.android.capture.document.QRCodeDocument;
import net.gini.android.capture.error.ErrorActivity;
import net.gini.android.capture.error.ErrorType;
import net.gini.android.capture.help.HelpActivity;
import net.gini.android.capture.internal.camera.api.CameraException;
import net.gini.android.capture.internal.camera.api.CameraInterface;
Expand All @@ -49,6 +49,7 @@
import net.gini.android.capture.internal.camera.view.QRCodePopup;
import net.gini.android.capture.internal.fileimport.FileChooserActivity;
import net.gini.android.capture.internal.network.AnalysisNetworkRequestResult;
import net.gini.android.capture.internal.network.FailureException;
import net.gini.android.capture.internal.network.NetworkRequestsManager;
import net.gini.android.capture.internal.qrcode.PaymentQRCodeData;
import net.gini.android.capture.internal.qrcode.PaymentQRCodeReader;
Expand All @@ -69,8 +70,6 @@
import net.gini.android.capture.logging.ErrorLog;
import net.gini.android.capture.logging.ErrorLogger;
import net.gini.android.capture.network.Error;
import net.gini.android.capture.error.ErrorType;
import net.gini.android.capture.internal.network.FailureException;
import net.gini.android.capture.network.model.GiniCaptureExtraction;
import net.gini.android.capture.network.model.GiniCaptureSpecificExtraction;
import net.gini.android.capture.requirements.CameraHolder;
Expand Down Expand Up @@ -101,7 +100,6 @@
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat;

import jersey.repackaged.jsr166e.CompletableFuture;
import kotlin.Unit;

Expand Down Expand Up @@ -580,7 +578,6 @@ void onSaveInstanceState(@NonNull final Bundle outState) {

void onStop() {
closeCamera();

if (mPaymentQRCodePopup != null) {
mPaymentQRCodePopup.hide();
}
Expand Down Expand Up @@ -1334,7 +1331,7 @@ private void showInvalidFileAlert(final String message) {

mFragment.showAlertDialog(message,
activity.getString(R.string.gc_document_import_close_error),
(dialogInterface, i) -> dialogInterface.dismiss() , null, null, null);
(dialogInterface, i) -> dialogInterface.dismiss(), null, null, null);
}

@UiThread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ internal class QRCodePopup<T> @JvmOverloads constructor(
fragmentImplCallback.view?.postDelayed(hideRunnable, hideDelayMs)
return
}
isShown = true
showViews()
fragmentImplCallback.view?.removeCallbacks(hideRunnable)
fragmentImplCallback.view?.postDelayed(hideRunnable, hideDelayMs)
Expand Down Expand Up @@ -124,7 +123,6 @@ internal class QRCodePopup<T> @JvmOverloads constructor(
}

private fun progressViews() {

qrCheckImage.visibility = View.GONE
qrImageFrame.visibility = View.INVISIBLE
loadingIndicatorContainer?.modifyAdapterIfOwned { it.onVisible() }
Expand All @@ -133,7 +131,6 @@ internal class QRCodePopup<T> @JvmOverloads constructor(
}

private fun hideViews() {

qrStatusTxt.visibility = View.GONE
qrCheckImage.visibility = View.GONE
qrImageFrame.visibility = View.VISIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public void onNonPaymentQRCodeDetected(@NonNull final String qrCodeContent) {
public void onQRCodeReaderFail() {
}
};
private boolean isReleased = false;

/**
* Create a new instance which uses the provided {@link QRCodeDetectorTask} to do QRCode
Expand All @@ -66,6 +67,9 @@ private PaymentQRCodeReader(
mDetector.setListener(new QRCodeDetector.Listener() {
@Override
public void onQRCodesDetected(@NonNull final List<String> qrCodes) {
if (isReleased) {
return;
}
for (final String qrCodeContent : qrCodes) {
try {
final PaymentQRCodeData paymentData = mParser.parse(qrCodeContent);
Expand Down Expand Up @@ -119,6 +123,7 @@ public void readFromByteArray(@NonNull final byte[] image, @NonNull final Size i
* Release all resources. Detection not possible after this has been called.
*/
public void release() {
isReleased = true;
mDetector.release();
}

Expand Down

0 comments on commit a72d692

Please sign in to comment.