导航菜单

页面标题

页面副标题

pg 娱乐 v1.0.7.202506242308 - ScanCodeActivity.java 源代码

正在查看: pg 娱乐 v1.0.7.202506242308 应用的 ScanCodeActivity.java JAVA 源代码文件

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


package com.yxing;

import android.animation.AnimatorSet;
import android.animation.Keyframe;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.util.Size;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.camera.core.Camera;
import androidx.camera.core.CameraControl;
import androidx.camera.core.CameraInfo;
import androidx.camera.core.CameraSelector;
import androidx.camera.core.FocusMeteringAction;
import androidx.camera.core.ImageAnalysis;
import androidx.camera.core.MeteringPoint;
import androidx.camera.core.Preview;
import androidx.camera.core.SurfaceOrientedMeteringPointFactory;
import androidx.camera.core.UseCase;
import androidx.camera.core.ZoomState;
import androidx.camera.lifecycle.ProcessCameraProvider;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LiveData;
import com.example.yxing.R;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.yxing.PreviewTouchListener;
import com.yxing.iface.OnScancodeListener;
import com.yxing.view.ScanCustomizeView;
import com.yxing.view.ScanQqView;
import com.yxing.view.ScanWechatView;
import com.yxing.view.base.BaseScanView;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import kotlin.Deprecated;
import kotlin.Metadata;
import kotlin.Result;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.jvm.internal.Intrinsics;

@Metadata(d1 = {"\u0000ª\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010!\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0007\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0011\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u000b\b\u0016\u0018\u0000 Q2\u00020\u00012\u00020\u0002:\u0001QB\u0005¢\u0006\u0002\u0010\u0003J\u0017\u0010 \u001a\u00020!2\b\u0010\"\u001a\u0004\u0018\u00010#H\u0002¢\u0006\u0002\u0010$J\u0018\u0010%\u001a\u00020#2\u0006\u0010&\u001a\u00020#2\u0006\u0010'\u001a\u00020#H\u0002J\b\u0010(\u001a\u00020!H\u0002J\b\u0010)\u001a\u00020!H\u0002J\u0010\u0010*\u001a\u00020!2\u0006\u0010+\u001a\u00020,H\u0002J\u0018\u0010-\u001a\u00020!2\u0006\u0010.\u001a\u00020/2\u0006\u00100\u001a\u00020/H\u0002J\b\u00101\u001a\u00020!H\u0002J\b\u00102\u001a\u000203H\u0002J\u0010\u00104\u001a\u00020!2\u0006\u00105\u001a\u000206H\u0002J\u0018\u00107\u001a\u0002062\u0006\u0010+\u001a\u00020,2\u0006\u00108\u001a\u00020\u001aH\u0002J\u0010\u00109\u001a\u0002062\u0006\u0010:\u001a\u00020;H\u0002J+\u0010<\u001a\u00020!2\u0006\u0010=\u001a\u00020;2\f\u0010>\u001a\b\u0012\u0004\u0012\u00020,0?2\u0006\u00108\u001a\u00020\u001aH\u0002¢\u0006\u0002\u0010@J\b\u0010A\u001a\u000206H\u0002J\u0010\u0010B\u001a\u00020\u000f2\u0006\u0010C\u001a\u00020#H\u0002J\u0010\u0010D\u001a\u00020\u00182\u0006\u0010C\u001a\u00020#H\u0002J\u0010\u0010E\u001a\u00020#2\u0006\u0010F\u001a\u00020GH\u0002J\b\u0010H\u001a\u00020#H\u0016J\b\u0010I\u001a\u00020!H\u0002J\b\u0010J\u001a\u00020!H\u0016J\u0010\u0010K\u001a\u00020!2\u0006\u0010+\u001a\u00020,H\u0016J+\u0010L\u001a\u00020!2\u0006\u0010=\u001a\u00020;2\f\u0010>\u001a\b\u0012\u0004\u0012\u00020,0?2\u0006\u00108\u001a\u00020\u001aH\u0016¢\u0006\u0002\u0010@J\b\u0010M\u001a\u00020!H\u0017J\b\u0010N\u001a\u00020!H\u0014J\u000e\u0010O\u001a\u00020!2\u0006\u0010P\u001a\u000203R\u0010\u0010\u0004\u001a\u0004\u0018\u00010\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\tX\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\rX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u000e\u001a\u00020\u000fX\u0082.¢\u0006\u0002\n\u0000R\u0014\u0010\u0010\u001a\b\u0012\u0004\u0012\u00020\u00120\u0011X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0013\u001a\u00020\u0014X\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010\u0015\u001a\u0004\u0018\u00010\u0016X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0017\u001a\u00020\u0018X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\u0019\u001a\u00020\u001aX\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010\u001b\u001a\u0004\u0018\u00010\u001cX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u001d\u001a\u0004\u0018\u00010\u001cX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u001e\u001a\u00020\u001fX\u0082.¢\u0006\u0002\n\u0000¨\u0006R"}, d2 = {"Lcom/yxing/ScanCodeActivity;", "Lcom/yxing/BaseScanActivity;", "Lcom/yxing/iface/OnScancodeListener;", "()V", "baseScanView", "Lcom/yxing/view/base/BaseScanView;", "camera", "Landroidx/camera/core/Camera;", "cameraControl", "Landroidx/camera/core/CameraControl;", "cameraExecutor", "Ljava/util/concurrent/ExecutorService;", "cameraSelector", "Landroidx/camera/core/CameraSelector;", "imageAnalyzer", "Landroidx/camera/core/ImageAnalysis;", "mAnimeSetList", "", "Landroid/animation/AnimatorSet;", "mCameraInfo", "Landroidx/camera/core/CameraInfo;", "mScanCodeAnalyzer", "Lcom/yxing/ScanCodeAnalyzer;", "preview", "Landroidx/camera/core/Preview;", "resolutionSize", "Landroid/util/Size;", "rlCodeHintContainer", "Landroid/widget/RelativeLayout;", "rlParentContent", "scModel", "Lcom/yxing/ScanCodeModel;", "addScanView", "", "style", "", "(Ljava/lang/Integer;)V", "aspectRatio", "width", "height", "bindCameraUseCases", "bindTouchListener", "callBackResult", "result", "Lcom/google/zxing/Result;", "cameraFocus", "pointX", "", "pointY", "clearAnimation", "clearCodeHintContainer", "", "createCodeAnimeSet", "view", "Landroid/view/View;", "createCodeHintView", "realSize", "createCodeSnapshotView", "bitmap", "Landroid/graphics/Bitmap;", "createSmegma", "resultBitmap", "results", "", "(Landroid/graphics/Bitmap;[Lcom/google/zxing/Result;Landroid/util/Size;)V", "createSmegmaView", "getCameraAnalyzer", "rotation", "getCameraPreView", "getCodeType", "barcodeFormat", "Lcom/google/zxing/BarcodeFormat;", "getLayoutId", "initCodeHintContainer", "initData", "onBackCode", "onBackMultiResultCode", "onBackPressed", "onDestroy", "setFlashStatus", "isOpenFlash", "Companion", "yxing_release"}, k = 1, mv = {1, 7, 1}, xi = 48)
public class ScanCodeActivity extends BaseScanActivity implements OnScancodeListener {
    private static final double RATIO_16_9_VALUE = 1.7777777777777777d;
    private static final double RATIO_4_3_VALUE = 1.3333333333333333d;
    private static final String TAG_CODE_HINT = "Yxing_CodeHintContainer";
    public Map<Integer, View> _$_findViewCache = new LinkedHashMap();
    private BaseScanView baseScanView;
    private Camera camera;
    private CameraControl cameraControl;
    private ExecutorService cameraExecutor;
    private final CameraSelector cameraSelector;
    private ImageAnalysis imageAnalyzer;
    private List<AnimatorSet> mAnimeSetList;
    private CameraInfo mCameraInfo;
    private ScanCodeAnalyzer mScanCodeAnalyzer;
    private Preview preview;
    private Size resolutionSize;
    private RelativeLayout rlCodeHintContainer;
    private RelativeLayout rlParentContent;
    private ScanCodeModel scModel;

    @Override
    public void _$_clearFindViewByIdCache() {
        this._$_findViewCache.clear();
    }

    @Override
    public View _$_findCachedViewById(int i) {
        Map<Integer, View> map = this._$_findViewCache;
        View view = map.get(Integer.valueOf(i));
        if (view != null) {
            return view;
        }
        View findViewById = findViewById(i);
        if (findViewById == null) {
            return null;
        }
        map.put(Integer.valueOf(i), findViewById);
        return findViewById;
    }

    public ScanCodeActivity() {
        CameraSelector DEFAULT_BACK_CAMERA = CameraSelector.DEFAULT_BACK_CAMERA;
        Intrinsics.checkNotNullExpressionValue(DEFAULT_BACK_CAMERA, "DEFAULT_BACK_CAMERA");
        this.cameraSelector = DEFAULT_BACK_CAMERA;
        this.mAnimeSetList = new ArrayList();
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_scancode;
    }

    @Override
    public void initData() {
        Bundle extras;
        Intent intent = getIntent();
        ScanCodeModel scanCodeModel = (intent == null || (extras = intent.getExtras()) == null) ? null : (ScanCodeModel) extras.getParcelable("model");
        Intrinsics.checkNotNull(scanCodeModel);
        this.scModel = scanCodeModel;
        initCodeHintContainer();
        ScanCodeModel scanCodeModel2 = this.scModel;
        if (scanCodeModel2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("scModel");
            scanCodeModel2 = null;
        }
        addScanView(Integer.valueOf(scanCodeModel2.getStyle()));
        ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor();
        Intrinsics.checkNotNullExpressionValue(newSingleThreadExecutor, "newSingleThreadExecutor()");
        this.cameraExecutor = newSingleThreadExecutor;
        Activity activity = (Activity) this;
        ScanCodeModel scanCodeModel3 = this.scModel;
        if (scanCodeModel3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("scModel");
            scanCodeModel3 = null;
        }
        BaseScanView baseScanView = this.baseScanView;
        this.mScanCodeAnalyzer = new ScanCodeAnalyzer(activity, scanCodeModel3, baseScanView != null ? baseScanView.getScanRect() : null, this);
        _$_findCachedViewById(R.id.pvCamera).post(new Runnable() {
            @Override
            public final void run() {
                ScanCodeActivity.m41initData$lambda0(ScanCodeActivity.this);
            }
        });
    }

    public static final void m41initData$lambda0(ScanCodeActivity this$0) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        this$0.bindCameraUseCases();
    }

    private final void initCodeHintContainer() {
        RelativeLayout relativeLayout = new RelativeLayout((Context) this);
        relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
        relativeLayout.setTranslationZ(99.0f);
        relativeLayout.setTag(TAG_CODE_HINT);
        this.rlCodeHintContainer = relativeLayout;
    }

    public final void setFlashStatus(boolean isOpenFlash) {
        CameraControl cameraControl = this.cameraControl;
        if (cameraControl == null) {
            Intrinsics.throwUninitializedPropertyAccessException("cameraControl");
            cameraControl = null;
        }
        cameraControl.enableTorch(isOpenFlash);
    }

    private final void addScanView(Integer style) {
        this.rlParentContent = (RelativeLayout) findViewById(R.id.rlparent);
        if (style != null && style.intValue() == 1001) {
            this.baseScanView = new ScanQqView((Context) this);
        } else if (style != null && style.intValue() == 1002) {
            this.baseScanView = new ScanWechatView((Context) this);
        } else if (style != null && style.intValue() == 1003) {
            ScanCustomizeView scanCustomizeView = new ScanCustomizeView((Context) this);
            ScanCodeModel scanCodeModel = this.scModel;
            if (scanCodeModel == null) {
                Intrinsics.throwUninitializedPropertyAccessException("scModel");
                scanCodeModel = null;
            }
            scanCustomizeView.setScanCodeModel(scanCodeModel);
            this.baseScanView = scanCustomizeView;
        }
        BaseScanView baseScanView = this.baseScanView;
        if (baseScanView != null) {
            baseScanView.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
            RelativeLayout relativeLayout = this.rlParentContent;
            if (relativeLayout != null) {
                relativeLayout.addView(baseScanView, 1);
            }
        }
    }

    private final void bindCameraUseCases() {
        Size size = new Size(_$_findCachedViewById(R.id.pvCamera).getMeasuredWidth(), _$_findCachedViewById(R.id.pvCamera).getMeasuredHeight());
        this.resolutionSize = size;
        ScanCodeAnalyzer scanCodeAnalyzer = this.mScanCodeAnalyzer;
        if (scanCodeAnalyzer != null) {
            scanCodeAnalyzer.setResolutionSize(size);
        }
        final int rotation = _$_findCachedViewById(R.id.pvCamera).getDisplay().getRotation();
        Context context = (Context) this;
        final ListenableFuture processCameraProvider = ProcessCameraProvider.getInstance(context);
        Intrinsics.checkNotNullExpressionValue(processCameraProvider, "getInstance(this)");
        processCameraProvider.addListener(new Runnable() {
            @Override
            public final void run() {
                ScanCodeActivity.m39bindCameraUseCases$lambda4(processCameraProvider, this, rotation);
            }
        }, ContextCompat.getMainExecutor(context));
    }

    public static final void m39bindCameraUseCases$lambda4(ListenableFuture cameraProviderFuture, ScanCodeActivity this$0, int i) {
        Intrinsics.checkNotNullParameter(cameraProviderFuture, "$cameraProviderFuture");
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        ProcessCameraProvider processCameraProvider = (ProcessCameraProvider) cameraProviderFuture.get();
        this$0.preview = this$0.getCameraPreView(i);
        this$0.imageAnalyzer = this$0.getCameraAnalyzer(i);
        processCameraProvider.unbindAll();
        try {
            LifecycleOwner lifecycleOwner = (LifecycleOwner) this$0;
            CameraSelector cameraSelector = this$0.cameraSelector;
            UseCase[] useCaseArr = new UseCase[2];
            Preview preview = this$0.preview;
            Camera camera = null;
            if (preview == null) {
                Intrinsics.throwUninitializedPropertyAccessException("preview");
                preview = null;
            }
            useCaseArr[0] = (UseCase) preview;
            ImageAnalysis imageAnalysis = this$0.imageAnalyzer;
            if (imageAnalysis == null) {
                Intrinsics.throwUninitializedPropertyAccessException("imageAnalyzer");
                imageAnalysis = null;
            }
            useCaseArr[1] = (UseCase) imageAnalysis;
            Camera bindToLifecycle = processCameraProvider.bindToLifecycle(lifecycleOwner, cameraSelector, useCaseArr);
            Intrinsics.checkNotNullExpressionValue(bindToLifecycle, "cameraProvider.bindToLif…nalyzer\n                )");
            this$0.camera = bindToLifecycle;
            Preview preview2 = this$0.preview;
            if (preview2 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("preview");
                preview2 = null;
            }
            preview2.setSurfaceProvider(this$0._$_findCachedViewById(R.id.pvCamera).getSurfaceProvider());
            Camera camera2 = this$0.camera;
            if (camera2 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("camera");
                camera2 = null;
            }
            CameraControl cameraControl = camera2.getCameraControl();
            Intrinsics.checkNotNullExpressionValue(cameraControl, "camera.cameraControl");
            this$0.cameraControl = cameraControl;
            Camera camera3 = this$0.camera;
            if (camera3 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("camera");
            } else {
                camera = camera3;
            }
            CameraInfo cameraInfo = camera.getCameraInfo();
            Intrinsics.checkNotNullExpressionValue(cameraInfo, "camera.cameraInfo");
            this$0.mCameraInfo = cameraInfo;
            this$0.bindTouchListener();
        } catch (Exception e) {
            Log.e(Config.TAG, "Use case binding failed", e);
        }
    }

    private final Preview getCameraPreView(int rotation) {
        Preview.Builder builder = new Preview.Builder();
        Size size = this.resolutionSize;
        if (size == null) {
            Intrinsics.throwUninitializedPropertyAccessException("resolutionSize");
            size = null;
        }
        Preview build = builder.setTargetResolution(size).setTargetRotation(rotation).build();
        Intrinsics.checkNotNullExpressionValue(build, "Builder()\n            .s…ion)\n            .build()");
        return build;
    }

    private final ImageAnalysis getCameraAnalyzer(int rotation) {
        ImageAnalysis.Builder builder = new ImageAnalysis.Builder();
        Size size = this.resolutionSize;
        ExecutorService executorService = null;
        if (size == null) {
            Intrinsics.throwUninitializedPropertyAccessException("resolutionSize");
            size = null;
        }
        ImageAnalysis build = builder.setTargetResolution(size).setTargetRotation(rotation).build();
        Intrinsics.checkNotNullExpressionValue(build, "Builder()\n            .s…ion)\n            .build()");
        ScanCodeAnalyzer scanCodeAnalyzer = this.mScanCodeAnalyzer;
        if (scanCodeAnalyzer != null) {
            ExecutorService executorService2 = this.cameraExecutor;
            if (executorService2 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("cameraExecutor");
            } else {
                executorService = executorService2;
            }
            build.setAnalyzer(executorService, scanCodeAnalyzer);
        }
        return build;
    }

    private final void bindTouchListener() {
        CameraInfo cameraInfo = this.mCameraInfo;
        if (cameraInfo == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mCameraInfo");
            cameraInfo = null;
        }
        final LiveData zoomState = cameraInfo.getZoomState();
        Intrinsics.checkNotNullExpressionValue(zoomState, "mCameraInfo.zoomState");
        PreviewTouchListener previewTouchListener = new PreviewTouchListener((Context) this);
        previewTouchListener.setCustomTouchListener(new PreviewTouchListener.CustomTouchListener() {
            @Override
            public void zoom(float delta) {
                CameraControl cameraControl;
                ZoomState zoomState2 = (ZoomState) zoomState.getValue();
                if (zoomState2 != null) {
                    ScanCodeActivity scanCodeActivity = this;
                    float zoomRatio = zoomState2.getZoomRatio();
                    cameraControl = scanCodeActivity.cameraControl;
                    if (cameraControl == null) {
                        Intrinsics.throwUninitializedPropertyAccessException("cameraControl");
                        cameraControl = null;
                    }
                    cameraControl.setZoomRatio(zoomRatio * delta);
                }
            }

            @Override
            public void focus(float pointX, float pointY) {
                this.cameraFocus(pointX, pointY);
            }
        });
        _$_findCachedViewById(R.id.pvCamera).setOnTouchListener(previewTouchListener);
    }

    public final void cameraFocus(float pointX, float pointY) {
        Size size = this.resolutionSize;
        CameraControl cameraControl = null;
        if (size == null) {
            Intrinsics.throwUninitializedPropertyAccessException("resolutionSize");
            size = null;
        }
        float width = size.getWidth();
        Size size2 = this.resolutionSize;
        if (size2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("resolutionSize");
            size2 = null;
        }
        MeteringPoint createPoint = new SurfaceOrientedMeteringPointFactory(width, size2.getHeight()).createPoint(pointX, pointY);
        Intrinsics.checkNotNullExpressionValue(createPoint, "factory.createPoint(pointX, pointY)");
        FocusMeteringAction build = new FocusMeteringAction.Builder(createPoint, 1).setAutoCancelDuration(4L, TimeUnit.SECONDS).build();
        Intrinsics.checkNotNullExpressionValue(build, "Builder(point, FocusMete…NDS)\n            .build()");
        CameraControl cameraControl2 = this.cameraControl;
        if (cameraControl2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("cameraControl");
        } else {
            cameraControl = cameraControl2;
        }
        cameraControl.startFocusAndMetering(build);
    }

    private final int aspectRatio(int width, int height) {
        double max = Math.max(width, height) / Math.min(width, height);
        return Math.abs(max - RATIO_4_3_VALUE) <= Math.abs(max - RATIO_16_9_VALUE) ? 0 : 1;
    }

    private final int getCodeType(BarcodeFormat barcodeFormat) {
        if (DecodeFormatManager.TWO_CODE.contains(barcodeFormat)) {
            return 1;
        }
        return DecodeFormatManager.ONE_CODE.contains(barcodeFormat) ? 0 : -1;
    }

    private final android.view.View createCodeHintView(final com.google.zxing.Result r17, android.util.Size r18) {
        throw new UnsupportedOperationException("Method not decompiled: com.yxing.ScanCodeActivity.createCodeHintView(com.google.zxing.Result, android.util.Size):android.view.View");
    }

    public static final void m40createCodeHintView$lambda6(ScanCodeActivity this$0, Result result, View view) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        Intrinsics.checkNotNullParameter(result, "$result");
        this$0.callBackResult(result);
    }

    private final View createCodeSnapshotView(Bitmap bitmap) {
        View appCompatImageView = new AppCompatImageView((Context) this);
        appCompatImageView.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
        appCompatImageView.setScaleType(ImageView.ScaleType.FIT_XY);
        appCompatImageView.setImageBitmap(bitmap);
        return appCompatImageView;
    }

    private final View createSmegmaView() {
        Context context = (Context) this;
        View view = new View(context);
        view.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
        view.setBackgroundColor(ContextCompat.getColor(context, R.color.black));
        ScanCodeModel scanCodeModel = this.scModel;
        if (scanCodeModel == null) {
            Intrinsics.throwUninitializedPropertyAccessException("scModel");
            scanCodeModel = null;
        }
        view.setAlpha(scanCodeModel.getQrCodeHintAlpha());
        return view;
    }

    private final void callBackResult(Result result) {
        Intent intent = new Intent();
        BarcodeFormat barcodeFormat = result.getBarcodeFormat();
        Intrinsics.checkNotNullExpressionValue(barcodeFormat, "result.barcodeFormat");
        intent.putExtra(ScanCodeConfig.CODE_TYPE, getCodeType(barcodeFormat));
        intent.putExtra(ScanCodeConfig.CODE_KEY, result.getText());
        setResult(-1, intent);
        finish();
    }

    private final boolean clearCodeHintContainer() {
        if (this.rlParentContent == null) {
            return false;
        }
        clearAnimation();
        RelativeLayout relativeLayout = this.rlParentContent;
        Intrinsics.checkNotNull(relativeLayout);
        int childCount = relativeLayout.getChildCount();
        for (int i = 0; i < childCount; i++) {
            RelativeLayout relativeLayout2 = this.rlParentContent;
            Intrinsics.checkNotNull(relativeLayout2);
            View childAt = relativeLayout2.getChildAt(i);
            if (Intrinsics.areEqual(TAG_CODE_HINT, childAt.getTag())) {
                Intrinsics.checkNotNull(childAt, "null cannot be cast to non-null type android.view.ViewGroup");
                ((ViewGroup) childAt).removeAllViews();
                RelativeLayout relativeLayout3 = this.rlParentContent;
                Intrinsics.checkNotNull(relativeLayout3);
                relativeLayout3.removeView(childAt);
                return true;
            }
        }
        return false;
    }

    private final void createSmegma(Bitmap resultBitmap, Result[] results, Size realSize) {
        RelativeLayout relativeLayout = this.rlCodeHintContainer;
        if (relativeLayout != null) {
            relativeLayout.addView(createCodeSnapshotView(resultBitmap));
        }
        RelativeLayout relativeLayout2 = this.rlCodeHintContainer;
        if (relativeLayout2 != null) {
            relativeLayout2.addView(createSmegmaView());
        }
        for (Result result : results) {
            View createCodeHintView = createCodeHintView(result, realSize);
            RelativeLayout relativeLayout3 = this.rlCodeHintContainer;
            if (relativeLayout3 != null) {
                relativeLayout3.addView(createCodeHintView);
            }
            ScanCodeModel scanCodeModel = this.scModel;
            if (scanCodeModel == null) {
                Intrinsics.throwUninitializedPropertyAccessException("scModel");
                scanCodeModel = null;
            }
            if (scanCodeModel.isStartCodeHintAnimation()) {
                createCodeAnimeSet(createCodeHintView);
            }
        }
        RelativeLayout relativeLayout4 = this.rlParentContent;
        if (relativeLayout4 != null) {
            relativeLayout4.addView(this.rlCodeHintContainer);
        }
    }

    private final void createCodeAnimeSet(View view) {
        Keyframe ofFloat = Keyframe.ofFloat(0.0f, 1.0f);
        Keyframe ofFloat2 = Keyframe.ofFloat(0.7f, 1.0f);
        Keyframe ofFloat3 = Keyframe.ofFloat(0.85f, 0.7f);
        Keyframe ofFloat4 = Keyframe.ofFloat(1.0f, 1.0f);
        ObjectAnimator ofPropertyValuesHolder = ObjectAnimator.ofPropertyValuesHolder(view, PropertyValuesHolder.ofKeyframe("scaleX", ofFloat, ofFloat2, ofFloat3, ofFloat4));
        Intrinsics.checkNotNullExpressionValue(ofPropertyValuesHolder, "ofPropertyValuesHolder(view, frameHolderX)");
        ofPropertyValuesHolder.setDuration(2000L);
        ofPropertyValuesHolder.setRepeatCount(-1);
        ofPropertyValuesHolder.setRepeatMode(2);
        ObjectAnimator ofPropertyValuesHolder2 = ObjectAnimator.ofPropertyValuesHolder(view, PropertyValuesHolder.ofKeyframe("scaleY", ofFloat, ofFloat2, ofFloat3, ofFloat4));
        Intrinsics.checkNotNullExpressionValue(ofPropertyValuesHolder2, "ofPropertyValuesHolder(view, frameHolderY)");
        ofPropertyValuesHolder2.setDuration(2000L);
        ofPropertyValuesHolder2.setRepeatCount(-1);
        ofPropertyValuesHolder2.setRepeatMode(2);
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(ofPropertyValuesHolder, ofPropertyValuesHolder2);
        animatorSet.setInterpolator(new DecelerateInterpolator());
        animatorSet.start();
        this.mAnimeSetList.add(animatorSet);
    }

    private final void clearAnimation() {
        if (this.mAnimeSetList.isEmpty()) {
            return;
        }
        Iterator<T> it = this.mAnimeSetList.iterator();
        while (it.hasNext()) {
            ((AnimatorSet) it.next()).cancel();
        }
    }

    protected void onDestroy() {
        super.onDestroy();
        ExecutorService executorService = this.cameraExecutor;
        if (executorService == null) {
            Intrinsics.throwUninitializedPropertyAccessException("cameraExecutor");
            executorService = null;
        }
        executorService.shutdownNow();
        BaseScanView baseScanView = this.baseScanView;
        if (baseScanView != null) {
            baseScanView.cancelAnim();
        }
        clearAnimation();
    }

    @Deprecated(message = "Deprecated in Java")
    public void onBackPressed() {
        if (clearCodeHintContainer()) {
            ScanCodeAnalyzer scanCodeAnalyzer = this.mScanCodeAnalyzer;
            if (scanCodeAnalyzer != null) {
                scanCodeAnalyzer.resumeMultiReader();
                return;
            }
            return;
        }
        super.onBackPressed();
    }

    @Override
    public void onBackCode(Result result) {
        Intrinsics.checkNotNullParameter(result, "result");
        callBackResult(result);
    }

    @Override
    public void onBackMultiResultCode(final Bitmap resultBitmap, final Result[] results, final Size realSize) {
        Intrinsics.checkNotNullParameter(resultBitmap, "resultBitmap");
        Intrinsics.checkNotNullParameter(results, "results");
        Intrinsics.checkNotNullParameter(realSize, "realSize");
        runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                ScanCodeActivity.m42onBackMultiResultCode$lambda11(results, this, resultBitmap, realSize);
            }
        });
    }

    public static final void m42onBackMultiResultCode$lambda11(Result[] results, ScanCodeActivity this$0, Bitmap resultBitmap, Size realSize) {
        Object m346constructorimpl;
        ScanCodeAnalyzer scanCodeAnalyzer;
        Intrinsics.checkNotNullParameter(results, "$results");
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        Intrinsics.checkNotNullParameter(resultBitmap, "$resultBitmap");
        Intrinsics.checkNotNullParameter(realSize, "$realSize");
        Result.Companion companion = kotlin.Result.INSTANCE;
        try {
            Result.Companion companion2 = kotlin.Result.INSTANCE;
            if (results.length == 1) {
                this$0.callBackResult(results[0]);
            } else {
                this$0.createSmegma(resultBitmap, results, realSize);
            }
            m346constructorimpl = kotlin.Result.m346constructorimpl(Unit.INSTANCE);
        } catch (Throwable th) {
            Result.Companion companion3 = kotlin.Result.INSTANCE;
            m346constructorimpl = kotlin.Result.m346constructorimpl(ResultKt.createFailure(th));
        }
        if (kotlin.Result.m349exceptionOrNullimpl(m346constructorimpl) == null || (scanCodeAnalyzer = this$0.mScanCodeAnalyzer) == null) {
            return;
        }
        scanCodeAnalyzer.resumeMultiReader();
    }
}