导航菜单

页面标题

页面副标题

bbinstant v6.24.0 - QRScanActivity.java 源代码

正在查看: bbinstant v6.24.0 应用的 QRScanActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.bigbasket.bbinstant.ui.common;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import androidx.appcompat.widget.AppCompatImageView;
import com.bigbasket.bbinstant.ui.BaseActivity;
import com.journeyapps.barcodescanner.DecoratedBarcodeView;
import com.journeyapps.barcodescanner.j;

public class QRScanActivity extends BaseActivity implements DecoratedBarcodeView.a {
    private DecoratedBarcodeView barcodeScannerView;
    private j capture;
    private AppCompatImageView flashLight;
    private boolean isFlashLightOn;

    private boolean hasFlash() {
        return getApplicationContext().getPackageManager().hasSystemFeature("android.hardware.camera.flash");
    }

    private void initUI() {
        this.barcodeScannerView = findViewById(2131362831);
        this.flashLight = (AppCompatImageView) findViewById(2131362106);
        ((AppCompatImageView) findViewById(2131362152)).setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                QRScanActivity.this.lambda$initUI$0(view);
            }
        });
        this.barcodeScannerView.setTorchListener(this);
    }

    public void lambda$initUI$0(View view) {
        finish();
    }

    public void lambda$setupTorch$1(View view) {
        toggleTorch();
    }

    private void setupCaptureManager(Bundle bundle) {
        j jVar = new j(this, this.barcodeScannerView);
        this.capture = jVar;
        jVar.initializeFromIntent(getIntent(), bundle);
        this.capture.decode();
    }

    private void setupTorch() {
        if (hasFlash()) {
            this.flashLight.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    QRScanActivity.this.lambda$setupTorch$1(view);
                }
            });
        } else {
            this.flashLight.setVisibility(8);
        }
    }

    private void toggleTorch() {
        if (this.isFlashLightOn) {
            this.barcodeScannerView.setTorchOff();
        } else {
            this.barcodeScannerView.setTorchOn();
        }
    }

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(2131558652);
        initUI();
        setupTorch();
        setupCaptureManager(bundle);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        this.capture.onDestroy();
    }

    @Override
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        return this.barcodeScannerView.onKeyDown(i, keyEvent) || super.onKeyDown(i, keyEvent);
    }

    @Override
    protected void onPause() {
        super.onPause();
        this.capture.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        this.capture.onResume();
    }

    @Override
    protected void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        this.capture.onSaveInstanceState(bundle);
    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    public void onTorchOff() {
        this.isFlashLightOn = false;
        this.flashLight.setImageResource(2131231168);
    }

    public void onTorchOn() {
        this.isFlashLightOn = true;
        this.flashLight.setImageResource(2131231167);
    }
}