导航菜单

页面标题

页面副标题

Mabilis Cash v1.19.4 - PHIdCardScanOCRV2Activity.java 源代码

正在查看: Mabilis Cash v1.19.4 应用的 PHIdCardScanOCRV2Activity.java JAVA 源代码文件

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


package com.loans.mabiliscash.auth.idcard.scanv2;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets;
import androidx.core.view.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import butterknife.BindView;
import butterknife.OnClick;
import com.airbnb.lottie.LottieAnimationView;
import com.fintopia.libCommon.common.CommonActivity;
import com.fintopia.libCommon.common.CommonObserver;
import com.fintopia.libCommon.common.CommonResult;
import com.lingyue.supertoolkit.Action;
import com.lingyue.supertoolkit.permission.PermissionHelper;
import com.lingyue.supertoolkit.tools.BaseUtils;
import com.lingyue.supertoolkit.tools.customtools.Logger;
import com.lingyue.supertoolkit.tools.filetools.FilePathUtil;
import com.lingyue.supertoolkit.tools.imagetools.BitmapUtil;
import com.lingyue.supertoolkit.tools.rxjavatools.RxUtil;
import com.lingyue.supertoolkit.widgets.ToastCompat;
import com.lingyue.tracklib.ThirdPartTrackLib;
import com.lingyue.tracklib.TrackEventParamsConfigurator;
import com.loans.mabiliscash.R;
import com.loans.mabiliscash.auth.idcard.PHBaseIdCardScanActivity;
import com.loans.mabiliscash.auth.idcard.PHIdCardScanOCRActivity;
import com.loans.mabiliscash.auth.idcard.scanv2.IdCardIndicatorV2;
import com.loans.mabiliscash.auth.idcard.scanv2.PHIdCardScanOCRV2Activity;
import com.loans.mabiliscash.auth.idcard.w1;
import com.loans.mabiliscash.common.PHBaseActivity;
import com.loans.mabiliscash.models.TrackingEvents;
import com.loans.mabiliscash.models.response.OCRResponse;
import com.loans.mabiliscash.net.MultipartBuild;
import com.loans.mabiliscash.utils.ComponentExtensionsKt;
import com.loans.mabiliscash.widght.PHCommonDialog;
import com.veda.android.bananalibrary.net.ICallBack;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import java.io.File;
import java.util.Map;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import okhttp3.MultipartBody;

public class PHIdCardScanOCRV2Activity extends PHBaseActivity implements TextureView.SurfaceTextureListener {

    @BindView(R.id.cl_content)
    ConstraintLayout clContent;

    @BindView(R.id.gp_camera_picture)
    Group gpCameraPicture;

    @BindView(R.id.gp_camera_preview)
    Group gpCameraPreview;

    @BindView(R.id.ii_camera_frame)
    IdCardIndicatorV2 iICameraFrame;

    @BindView(R.id.iv_camera)
    LottieAnimationView ivCamera;

    @BindView(R.id.iv_close)
    ImageView ivClose;

    @BindView(R.id.iv_rescan_ok)
    View ivRescanOk;

    @BindView(R.id.iv_rescan_reset)
    View ivRescanReset;
    private Bitmap o;
    private String p;
    private UploadIdCardImageHelper q;
    private Disposable r;
    private byte[] s;

    private ICamera f111t;

    @BindView(R.id.tv_camera_tip)
    TextView tvCameraTip;

    @BindView(R.id.ttv_surface)
    TextureView tvSurface;

    private final OpenCameraTask f112u = new OpenCameraTask();

    private String f113v = "";

    protected int f114w;

    class AnonymousClass1 implements PermissionHelper.CallBack {
        AnonymousClass1() {
        }

        public void c(Map map) {
            map.put("requirement_id", 18);
            map.put("track_sign", "aauth.b41.c324.click.auth_b41_c324_click");
            map.put("button_name", "未开启");
            map.put("entry_page", PHIdCardScanOCRV2Activity.this.getClass().getSimpleName());
        }

        public void d(Map map) {
            map.put("requirement_id", 18);
            map.put("track_sign", "aauth.b41.c324.click.auth_b41_c324_click");
            map.put("button_name", "开启");
            map.put("entry_page", PHIdCardScanOCRV2Activity.this.getClass().getSimpleName());
        }

        @Override
        public void denied(String str) {
            ThirdPartTrackLib.d(PHIdCardScanOCRV2Activity.this, "auth_b41_c324_click", new TrackEventParamsConfigurator() {
                @Override
                public final void a(Map map) {
                    PHIdCardScanOCRV2Activity.AnonymousClass1.this.c(map);
                }
            });
            ((CommonActivity) PHIdCardScanOCRV2Activity.this).permissionHelper.clearCallBack();
            PHIdCardScanOCRV2Activity.this.onPermissionResult();
        }

        @Override
        public void granted(String str) {
            ThirdPartTrackLib.d(PHIdCardScanOCRV2Activity.this, "auth_b41_c324_click", new TrackEventParamsConfigurator() {
                @Override
                public final void a(Map map) {
                    PHIdCardScanOCRV2Activity.AnonymousClass1.this.d(map);
                }
            });
            ((CommonActivity) PHIdCardScanOCRV2Activity.this).permissionHelper.clearCallBack();
            PHIdCardScanOCRV2Activity.this.onPermissionResult();
        }
    }

    class OpenCameraTask extends AsyncTask<Integer, Integer, Camera> {
        public void h(Exception exc, Map map) {
            Boolean bool = Boolean.FALSE;
            map.put("is_success", bool);
            map.put("is_id_card_scan_v1", bool);
            map.put("reason", "open_camera_failed");
            map.put("exception", (exc == null || exc.getMessage() == null) ? "" : exc.getMessage());
            map.put("is_camera_null", Boolean.valueOf(PHIdCardScanOCRV2Activity.this.f111t.a == null));
        }

        public void i(Exception exc, Map map) {
            Boolean bool = Boolean.FALSE;
            map.put("is_success", bool);
            map.put("is_id_card_scan_v1", bool);
            map.put("reason", "init_camera_params_failed");
            map.put("exception", (exc == null || exc.getMessage() == null) ? "" : exc.getMessage());
            map.put("is_camera_null", Boolean.valueOf(PHIdCardScanOCRV2Activity.this.f111t.a == null));
        }

        public void j(Map map) {
            map.put("is_success", Boolean.TRUE);
            map.put("is_id_card_scan_v1", Boolean.FALSE);
            map.put("is_camera_null", Boolean.valueOf(PHIdCardScanOCRV2Activity.this.f111t.a == null));
        }

        public void k(String str) {
            ThirdPartTrackLib.d(PHIdCardScanOCRV2Activity.this, "id_card_scan_init_camera", new TrackEventParamsConfigurator() {
                @Override
                public final void a(Map map) {
                    PHIdCardScanOCRV2Activity.OpenCameraTask.this.j(map);
                }
            });
        }

        public void l(Throwable th, Map map) {
            Boolean bool = Boolean.FALSE;
            map.put("is_success", bool);
            map.put("is_id_card_scan_v1", bool);
            map.put("reason", "start_preview_failed");
            map.put("exception", (th == null || th.getMessage() == null) ? "" : th.getMessage());
            map.put("is_camera_null", Boolean.valueOf(PHIdCardScanOCRV2Activity.this.f111t.a == null));
        }

        public void m(final Throwable th) {
            ThirdPartTrackLib.d(PHIdCardScanOCRV2Activity.this, "id_card_scan_init_camera", new TrackEventParamsConfigurator() {
                @Override
                public final void a(Map map) {
                    PHIdCardScanOCRV2Activity.OpenCameraTask.this.l(th, map);
                }
            });
            CommonActivity commonActivity = PHIdCardScanOCRV2Activity.this;
            ToastCompat.e(commonActivity, commonActivity.getString(R.string.open_camera_permission));
            PHIdCardScanOCRV2Activity.this.finish();
        }

        @Override
        public Camera doInBackground(Integer... numArr) {
            try {
                return PHIdCardScanOCRV2Activity.this.f111t.j();
            } catch (Exception e) {
                ThirdPartTrackLib.d(PHIdCardScanOCRV2Activity.this, "id_card_scan_init_camera", new TrackEventParamsConfigurator() {
                    @Override
                    public final void a(Map map) {
                        PHIdCardScanOCRV2Activity.OpenCameraTask.this.h(e, map);
                    }
                });
                return null;
            }
        }

        @Override
        public void onPostExecute(Camera camera) {
            super.onPostExecute(camera);
            if (camera == null) {
                CommonActivity commonActivity = PHIdCardScanOCRV2Activity.this;
                ToastCompat.e(commonActivity, commonActivity.getString(R.string.open_camera_permission));
                PHIdCardScanOCRV2Activity.this.finish();
                return;
            }
            try {
                PHIdCardScanOCRV2Activity.this.f111t.g(PHIdCardScanOCRV2Activity.this);
            } catch (Exception e) {
                ThirdPartTrackLib.d(PHIdCardScanOCRV2Activity.this, "id_card_scan_init_camera", new TrackEventParamsConfigurator() {
                    @Override
                    public final void a(Map map) {
                        PHIdCardScanOCRV2Activity.OpenCameraTask.this.i(e, map);
                    }
                });
                CommonActivity commonActivity2 = PHIdCardScanOCRV2Activity.this;
                ToastCompat.e(commonActivity2, commonActivity2.getString(R.string.open_camera_permission));
                PHIdCardScanOCRV2Activity.this.finish();
            }
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) PHIdCardScanOCRV2Activity.this.f111t.e(PHIdCardScanOCRV2Activity.this.clContent.getLayoutParams());
            layoutParams.gravity = 17;
            PHIdCardScanOCRV2Activity.this.clContent.setLayoutParams(layoutParams);
            PHIdCardScanOCRV2Activity.this.G0(new Action() {
                @Override
                public final void a(Object obj) {
                    PHIdCardScanOCRV2Activity.OpenCameraTask.this.k((String) obj);
                }
            }, new Action() {
                @Override
                public final void a(Object obj) {
                    PHIdCardScanOCRV2Activity.OpenCameraTask.this.m((Throwable) obj);
                }
            });
        }

        private OpenCameraTask() {
        }
    }

    public class UploadIdCardImageHelper {
        private final Callback a;

        class AnonymousClass1 extends CommonObserver<OCRResponse> {
            final String b;

            AnonymousClass1(ICallBack iCallBack, String str) {
                super(iCallBack);
                this.b = str;
            }

            public void j(Throwable th, OCRResponse oCRResponse, Map map) {
                map.put("requirement_id", 18);
                map.put("track_sign", "aauth.result.auth_id_ocr_identity_result.497");
                map.put("is_success", "false");
                map.put("reason", th != null ? th.getMessage() : oCRResponse != null ? ((CommonResult) oCRResponse).status.detail : "");
                map.put("page_name", PHIdCardScanOCRV2Activity.this.H0());
            }

            public static void k(OCRResponse oCRResponse, Throwable th, Map map) {
                map.put("is_id_card_scan_v1", Boolean.FALSE);
                map.put("api_code", oCRResponse.getStatusCodeString());
                map.put("exception", (th == null || th.getMessage() == null) ? "" : th.getMessage());
            }

            public void l(Map map) {
                map.put("requirement_id", 18);
                map.put("track_sign", "aauth.result.auth_id_ocr_identity_result.497");
                map.put("is_success", "true");
                map.put("page_name", PHIdCardScanOCRV2Activity.this.H0());
            }

            public static void m(Map map) {
                map.put("is_id_card_scan_v1", Boolean.FALSE);
            }

            protected boolean d() {
                return false;
            }

            public void e(final Throwable th, final OCRResponse oCRResponse) {
                super.e(th, oCRResponse);
                ThirdPartTrackLib.d(PHIdCardScanOCRV2Activity.this, "auth_id_ocr_identity_result", new TrackEventParamsConfigurator() {
                    @Override
                    public final void a(Map map) {
                        PHIdCardScanOCRV2Activity.UploadIdCardImageHelper.AnonymousClass1.this.j(th, oCRResponse, map);
                    }
                });
                ThirdPartTrackLib.d(PHIdCardScanOCRV2Activity.this, "id_card_scan_upload_failed", new TrackEventParamsConfigurator() {
                    @Override
                    public final void a(Map map) {
                        PHIdCardScanOCRV2Activity.UploadIdCardImageHelper.AnonymousClass1.k(OCRResponse.this, th, map);
                    }
                });
                if (UploadIdCardImageHelper.this.a != null) {
                    UploadIdCardImageHelper.this.a.a(((CommonResult) oCRResponse).status.detail);
                }
            }

            public void c(OCRResponse oCRResponse) {
                ThirdPartTrackLib.d(PHIdCardScanOCRV2Activity.this, "auth_id_ocr_identity_result", new TrackEventParamsConfigurator() {
                    @Override
                    public final void a(Map map) {
                        PHIdCardScanOCRV2Activity.UploadIdCardImageHelper.AnonymousClass1.this.l(map);
                    }
                });
                ThirdPartTrackLib.d(PHIdCardScanOCRV2Activity.this, "id_card_scan_upload_successful", new TrackEventParamsConfigurator() {
                    @Override
                    public final void a(Map map) {
                        PHIdCardScanOCRV2Activity.UploadIdCardImageHelper.AnonymousClass1.m(map);
                    }
                });
                if (UploadIdCardImageHelper.this.a != null) {
                    UploadIdCardImageHelper.this.a.b(oCRResponse.body, this.b);
                }
            }
        }

        public interface Callback {
            void a(String str);

            void b(OCRResponse.Body body, String str);
        }

        public UploadIdCardImageHelper(@Nullable Callback callback) {
            this.a = callback;
        }

        public void b(@Nullable String str, @NonNull MultipartBody.Part part) {
            PHIdCardScanOCRV2Activity.this.apiHelper.a().J(part, MultipartBuild.a("uploadType", "TAKE_PHOTOS"), MultipartBuild.a("type", PHIdCardScanOCRV2Activity.this.f113v), MultipartBuild.a("isFrontImage", String.valueOf(PHIdCardScanOCRV2Activity.this.f114w == 1))).w(AndroidSchedulers.a()).a(new AnonymousClass1(PHIdCardScanOCRV2Activity.this, str));
        }

        public void c(byte[] bArr) {
            b(null, MultipartBuild.b("image", bArr));
        }
    }

    private void C0() {
        ViewCompat.setOnApplyWindowInsetsListener(this.clContent, new OnApplyWindowInsetsListener() {
            public final WindowInsetsCompat onApplyWindowInsets(View view, WindowInsetsCompat windowInsetsCompat) {
                WindowInsetsCompat J0;
                J0 = PHIdCardScanOCRV2Activity.this.J0(view, windowInsetsCompat);
                return J0;
            }
        });
    }

    private void D0(Bitmap bitmap) {
        if (bitmap != null) {
            this.r = Flowable.w(bitmap).Q(Schedulers.b()).x(new Function() {
                public final Object apply(Object obj) {
                    File K0;
                    K0 = PHIdCardScanOCRV2Activity.this.K0((Bitmap) obj);
                    return K0;
                }
            }).z(AndroidSchedulers.a()).M(new Consumer() {
                public final void accept(Object obj) {
                    PHIdCardScanOCRV2Activity.this.o1((File) obj);
                }
            }, new Consumer() {
                public final void accept(Object obj) {
                    PHIdCardScanOCRV2Activity.this.M0((Throwable) obj);
                }
            });
            return;
        }
        ToastCompat.g(this, getString(R.string.data_error_message));
        F0();
        s1();
    }

    private void F0() {
        G0(null, null);
    }

    public void G0(@Nullable Action<String> action, @Nullable Action<Throwable> action2) {
        this.f111t.l(this.tvSurface.getSurfaceTexture(), action, action2);
    }

    public String H0() {
        Intent intent = getIntent();
        return intent == null ? "" : intent.getStringExtra(PHBaseIdCardScanActivity.EXTRA_FROM_PAGE);
    }

    private void I0() {
        this.q = new UploadIdCardImageHelper(new UploadIdCardImageHelper.Callback() {
            @Override
            public void a(String str) {
                PHIdCardScanOCRV2Activity.this.l1(str);
            }

            @Override
            public void b(OCRResponse.Body body, String str) {
                PHIdCardScanOCRV2Activity.this.m1(body);
            }
        });
    }

    public WindowInsetsCompat J0(View view, WindowInsetsCompat windowInsetsCompat) {
        Insets insets = windowInsetsCompat.getInsets(WindowInsetsCompat.Type.systemBars());
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) this.ivCamera.getLayoutParams();
        marginLayoutParams.setMargins(marginLayoutParams.leftMargin, marginLayoutParams.topMargin, getResources().getDimensionPixelOffset(2131165599) + insets.right, marginLayoutParams.bottomMargin);
        this.ivCamera.setLayoutParams(marginLayoutParams);
        ViewGroup.MarginLayoutParams marginLayoutParams2 = (ViewGroup.MarginLayoutParams) this.ivRescanOk.getLayoutParams();
        marginLayoutParams2.setMargins(marginLayoutParams2.leftMargin, marginLayoutParams2.topMargin, getResources().getDimensionPixelOffset(2131165599) + insets.right, marginLayoutParams2.bottomMargin);
        this.ivRescanOk.setLayoutParams(marginLayoutParams2);
        return WindowInsetsCompat.CONSUMED;
    }

    public File K0(Bitmap bitmap) throws Exception {
        this.p = BitmapUtil.d(BitmapUtil.a(bitmap, this.iICameraFrame.getContentWidth() / this.iICameraFrame.getWidth(), this.iICameraFrame.getContentHeight() / this.iICameraFrame.getHeight()), new File(FilePathUtil.a(this), "cardScanImage"));
        File file = new File(this.p);
        if (file.exists()) {
            return file;
        }
        throw new Exception(getResources().getString(R.string.open_storage_permission));
    }

    public static void L0(Throwable th, Map map) {
        map.put("is_id_card_scan_v1", Boolean.FALSE);
        map.put("exception", (th == null || th.getMessage() == null) ? "" : th.getMessage());
    }

    public void M0(final Throwable th) throws Exception {
        ThirdPartTrackLib.d(this, "id_card_scan_upload_failed", new TrackEventParamsConfigurator() {
            @Override
            public final void a(Map map) {
                PHIdCardScanOCRV2Activity.L0(th, map);
            }
        });
        l1(th.getMessage());
    }

    public void N0(Map map) {
        map.put("requirement_id", 18);
        map.put("track_sign", "aauth.b349.pageview.auth_b349_pageview");
        map.put("entry_page", H0());
    }

    public static void O0(Map map) {
        map.put("is_id_card_scan_v1", Boolean.FALSE);
    }

    public static void P0(Map map) {
        map.put("is_id_card_scan_v1", Boolean.FALSE);
    }

    public void Q0(Map map) {
        map.put("requirement_id", 18);
        map.put("track_sign", "aauth.b352.leave.auth_b352_leave");
        map.put("entry_page", H0());
    }

    public void R0(Map map) {
        map.put("requirement_id", 18);
        map.put("track_sign", "aauth.b349.leave.auth_b349_leave");
        map.put("entry_page", H0());
    }

    public void S0(Exception exc, Map map) {
        Boolean bool = Boolean.FALSE;
        map.put("is_success", bool);
        map.put("is_id_card_scan_v1", bool);
        map.put("reason", "open_camera_task_execute_failed");
        map.put("exception", (exc == null || exc.getMessage() == null) ? "" : exc.getMessage());
        map.put("is_camera_null", Boolean.valueOf(this.f111t.a == null));
    }

    public static void T0(Map map) {
        map.put("is_id_card_scan_v1", Boolean.FALSE);
    }

    public void U0(Map map) {
        map.put("requirement_id", 18);
        map.put("track_sign", "aauth.b349.d351.click.auth_b349_d351_click");
        map.put("entry_page", H0());
    }

    public void V0(Map map) {
        map.put("is_id_card_scan_v1", Boolean.FALSE);
        map.put("is_success", Boolean.TRUE);
        map.put("is_camera_null", Boolean.valueOf(this.f111t.a == null));
    }

    public void W0(Bitmap bitmap) {
        ThirdPartTrackLib.d(this, "id_card_scan_pre_deal_bitmap_failed", new TrackEventParamsConfigurator() {
            @Override
            public final void a(Map map) {
                PHIdCardScanOCRV2Activity.this.V0(map);
            }
        });
        this.o = bitmap;
        r1();
    }

    public void X0(Throwable th, Map map) {
        Boolean bool = Boolean.FALSE;
        map.put("is_id_card_scan_v1", bool);
        map.put("is_success", bool);
        map.put("reason", (th == null || th.getMessage() == null) ? "" : th.getMessage());
        map.put("is_camera_null", Boolean.valueOf(this.f111t.a == null));
    }

    public void Y0(final Throwable th) {
        ThirdPartTrackLib.d(this, "id_card_scan_pre_deal_bitmap_failed", new TrackEventParamsConfigurator() {
            @Override
            public final void a(Map map) {
                PHIdCardScanOCRV2Activity.this.X0(th, map);
            }
        });
        ToastCompat.g(this, getString(R.string.open_camera_permission));
        F0();
    }

    public void Z0(Map map) {
        map.put("requirement_id", 18);
        map.put("track_sign", "aauth.b352.d354.click.auth_b352_d354_click");
        map.put("entry_page", H0());
    }

    public void a1(Map map) {
        map.put("requirement_id", 18);
        map.put("track_sign", "aauth.b352.d353.click.auth_b352_d353_click");
        map.put("entry_page", H0());
    }

    public void b1(Map map) {
        map.put("requirement_id", 18);
        map.put("track_sign", "aauth.b352.pageview.auth_b352_pageview");
        map.put("entry_page", H0());
    }

    public void c1(Map map) {
        map.put("requirement_id", 18);
        map.put("track_sign", "aauth.b352.leave.auth_b352_leave");
        map.put("entry_page", H0());
    }

    public Unit d1() {
        ThirdPartTrackLib.d(this, "auth_b352_leave", new TrackEventParamsConfigurator() {
            @Override
            public final void a(Map map) {
                PHIdCardScanOCRV2Activity.this.c1(map);
            }
        });
        return Unit.a;
    }

    public void e1(byte[] bArr, Camera camera) {
        ThirdPartTrackLib.d(this, "id_card_scan_take_photo_successful", new TrackEventParamsConfigurator() {
            @Override
            public final void a(Map map) {
                PHIdCardScanOCRV2Activity.i1(map);
            }
        });
        Logger.c().b("onPictureTaken2");
        k1(bArr);
    }

    public static void f1(Throwable th, Map map) {
        map.put("is_id_card_scan_v1", Boolean.FALSE);
        map.put("reason", (th == null || th.getMessage() == null) ? "" : th.getMessage());
    }

    public void g1(final Throwable th) {
        ThirdPartTrackLib.d(this, "id_card_scan_take_photo_failed", new TrackEventParamsConfigurator() {
            @Override
            public final void a(Map map) {
                PHIdCardScanOCRV2Activity.f1(th, map);
            }
        });
    }

    public static void h1(Map map) {
        map.put("is_id_card_scan_v1", Boolean.FALSE);
    }

    public static void i1(Map map) {
        map.put("is_id_card_scan_v1", Boolean.FALSE);
    }

    private void j1() {
        E0();
        this.tvCameraTip.setText("");
        this.ivCamera.setEnabled(true);
        this.ivCamera.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.easycash_ic_camera));
        try {
            Bitmap bitmap = this.o;
            if (bitmap == null || bitmap.isRecycled()) {
                return;
            }
            this.o.recycle();
            this.o = null;
        } catch (Exception unused) {
        }
    }

    private void k1(byte[] bArr) {
        this.s = bArr;
        BitmapUtil.c(1000, bArr, new Action() {
            @Override
            public final void a(Object obj) {
                PHIdCardScanOCRV2Activity.this.W0((Bitmap) obj);
            }
        }, new Action() {
            @Override
            public final void a(Object obj) {
                PHIdCardScanOCRV2Activity.this.Y0((Throwable) obj);
            }
        });
    }

    public void l1(String str) {
        dismissLoadingDialog();
        F0();
        s1();
        q1(str);
    }

    public void m1(OCRResponse.Body body) {
        dismissLoadingDialog();
        Intent intent = new Intent();
        intent.putExtra(PHBaseIdCardScanActivity.FILE_PATH, this.p);
        intent.putExtra(PHIdCardScanOCRActivity.OCR_RESULT, body);
        setResult(-1, intent);
        finish();
    }

    private void n1() {
        ((CommonActivity) this).permissionHelper.requestPermissions(this, new AnonymousClass1(), "android.permission.CAMERA");
    }

    public void o1(File file) {
        if (file != null && file.exists()) {
            p1();
        } else {
            ToastCompat.g(this, getString(R.string.permission_denied_storage));
            F0();
        }
    }

    private void p1() {
        if (this.q == null) {
            I0();
        }
        showLoadingDialog();
        this.q.c(this.s);
    }

    private void q1(String str) {
        if (isFinishing() || isDestroyed() || TextUtils.isEmpty(str)) {
            return;
        }
        new PHCommonDialog.Builder(this).i(str).f(2131886252).g(new w1()).d(false).k(TrackingEvents.PH_ID_CARD_SCAN_ERROR_DIALOG).a().show();
    }

    private void r1() {
        this.gpCameraPreview.setVisibility(8);
        this.gpCameraPicture.setVisibility(0);
        ThirdPartTrackLib.d(this, "auth_b352_pageview", new TrackEventParamsConfigurator() {
            @Override
            public final void a(Map map) {
                PHIdCardScanOCRV2Activity.this.b1(map);
            }
        });
    }

    private void s1() {
        this.gpCameraPreview.setVisibility(0);
        ComponentExtensionsKt.o(this.gpCameraPicture, 8, new Function0() {
            public final Object invoke() {
                Unit d1;
                d1 = PHIdCardScanOCRV2Activity.this.d1();
                return d1;
            }
        });
        j1();
    }

    public static void startForResult(Activity activity, int i, int i2, @Nullable String str) {
        Intent intent = new Intent(activity, (Class<?>) PHIdCardScanOCRV2Activity.class);
        intent.putExtra(PHBaseIdCardScanActivity.ORIENTATION, i2);
        intent.putExtra(PHIdCardScanOCRActivity.EXTRA_ID_CARD_TYPE, str);
        intent.putExtra(PHBaseIdCardScanActivity.EXTRA_FROM_PAGE, activity.getClass().getSimpleName());
        activity.startActivityForResult(intent, i);
    }

    private void t1() {
        ThirdPartTrackLib.d(this, "id_card_scan_click_take_photo", new TrackEventParamsConfigurator() {
            @Override
            public final void a(Map map) {
                PHIdCardScanOCRV2Activity.h1(map);
            }
        });
        this.f111t.m(new Camera.PictureCallback() {
            @Override
            public final void onPictureTaken(byte[] bArr, Camera camera) {
                PHIdCardScanOCRV2Activity.this.e1(bArr, camera);
            }
        }, new Action() {
            @Override
            public final void a(Object obj) {
                PHIdCardScanOCRV2Activity.this.g1((Throwable) obj);
            }
        });
    }

    @Override
    public int getLayoutID() {
        return R.layout.layout_ec_id_card_scan_v2_activity;
    }

    @SuppressLint({"CheckResult"})
    protected void init() {
        super.init();
        this.f111t = new ICamera(false);
    }

    protected void j() {
        j1();
        Q();
        ThirdPartTrackLib.d(this, "auth_b349_pageview", new TrackEventParamsConfigurator() {
            @Override
            public final void a(Map map) {
                PHIdCardScanOCRV2Activity.this.N0(map);
            }
        });
    }

    @Override
    protected void k(@NonNull Bundle bundle) {
        super.k(bundle);
        this.f113v = getIntent().getStringExtra(PHIdCardScanOCRActivity.EXTRA_ID_CARD_TYPE);
        this.f114w = getIntent().getIntExtra(PHBaseIdCardScanActivity.ORIENTATION, 1);
    }

    protected void o() {
        IdCardIndicatorV2.IDCardAttr iDCardAttr = new IdCardIndicatorV2.IDCardAttr();
        if (this.f114w == 1) {
            iDCardAttr.a = 0;
            this.iICameraFrame.f(false, iDCardAttr);
        } else {
            iDCardAttr.a = 1;
            this.iICameraFrame.f(false, iDCardAttr);
        }
        this.tvSurface.setSurfaceTextureListener(this);
    }

    @Override
    protected void onCreate(Bundle bundle) {
        getWindow().setFlags(1024, 1024);
        super.onCreate(bundle);
        C0();
        ThirdPartTrackLib.d(this, "id_card_scan_enter", new TrackEventParamsConfigurator() {
            @Override
            public final void a(Map map) {
                PHIdCardScanOCRV2Activity.O0(map);
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ThirdPartTrackLib.d(this, "id_card_scan_destroy", new TrackEventParamsConfigurator() {
            @Override
            public final void a(Map map) {
                PHIdCardScanOCRV2Activity.P0(map);
            }
        });
        this.f111t.c();
        this.f112u.cancel(true);
        LottieAnimationView lottieAnimationView = this.ivCamera;
        if (lottieAnimationView != null && lottieAnimationView.q()) {
            this.ivCamera.j();
        }
        Bitmap bitmap = this.o;
        if (bitmap != null && !bitmap.isRecycled()) {
            this.o.recycle();
            this.o = null;
        }
        if (this.ivRescanReset.getVisibility() == 0) {
            ThirdPartTrackLib.d(this, "auth_b352_leave", new TrackEventParamsConfigurator() {
                @Override
                public final void a(Map map) {
                    PHIdCardScanOCRV2Activity.this.Q0(map);
                }
            });
        }
        ThirdPartTrackLib.d(this, "auth_b349_leave", new TrackEventParamsConfigurator() {
            @Override
            public final void a(Map map) {
                PHIdCardScanOCRV2Activity.this.R0(map);
            }
        });
    }

    protected void onPause() {
        super.onPause();
        this.tvSurface.setKeepScreenOn(false);
        RxUtil.a(this.r);
    }

    public void onPermissionResult() {
        try {
            this.f112u.execute(new Integer[0]);
        } catch (Exception e) {
            ThirdPartTrackLib.d(this, "id_card_scan_init_camera", new TrackEventParamsConfigurator() {
                @Override
                public final void a(Map map) {
                    PHIdCardScanOCRV2Activity.this.S0(e, map);
                }
            });
        }
    }

    protected void onResume() {
        super.onResume();
        this.tvSurface.setVisibility(0);
        this.tvSurface.setKeepScreenOn(true);
    }

    @Override
    public void onSurfaceTextureAvailable(@NonNull SurfaceTexture surfaceTexture, int i, int i2) {
        ThirdPartTrackLib.d(this, "id_card_scan_surface_available", new TrackEventParamsConfigurator() {
            @Override
            public final void a(Map map) {
                PHIdCardScanOCRV2Activity.T0(map);
            }
        });
        n1();
    }

    @Override
    public boolean onSurfaceTextureDestroyed(@NonNull SurfaceTexture surfaceTexture) {
        this.f111t.c();
        return true;
    }

    @OnClick({R.id.ttv_surface, R.id.ii_camera_frame, R.id.iv_camera, R.id.iv_close})
    public void onViewClicked(View view) {
        if (BaseUtils.a()) {
        }
        switch (view.getId()) {
            case R.id.ii_camera_frame:
            case R.id.ttv_surface:
                this.f111t.b();
                break;
            case R.id.iv_camera:
                t1();
                ThirdPartTrackLib.d(this, "auth_b349_d351_click", new TrackEventParamsConfigurator() {
                    @Override
                    public final void a(Map map) {
                        PHIdCardScanOCRV2Activity.this.U0(map);
                    }
                });
                break;
            case R.id.iv_close:
                setResult(0);
                finish();
                break;
        }
    }

    @OnClick({R.id.iv_rescan_reset, R.id.iv_rescan_ok})
    protected void rescanViewClick(View view) {
        switch (view.getId()) {
            case R.id.iv_rescan_ok:
                D0(this.o);
                ThirdPartTrackLib.d(this, "auth_b352_d353_click", new TrackEventParamsConfigurator() {
                    @Override
                    public final void a(Map map) {
                        PHIdCardScanOCRV2Activity.this.a1(map);
                    }
                });
                break;
            case R.id.iv_rescan_reset:
                F0();
                s1();
                ThirdPartTrackLib.d(this, "auth_b352_d354_click", new TrackEventParamsConfigurator() {
                    @Override
                    public final void a(Map map) {
                        PHIdCardScanOCRV2Activity.this.Z0(map);
                    }
                });
                break;
        }
    }

    protected void s(@NonNull Bundle bundle) {
        super.s(bundle);
        bundle.putString(PHIdCardScanOCRActivity.EXTRA_ID_CARD_TYPE, this.f113v);
        bundle.putInt(PHBaseIdCardScanActivity.ORIENTATION, this.f114w);
    }

    private void E0() {
    }

    @Override
    public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surfaceTexture) {
    }

    @Override
    public void onSurfaceTextureSizeChanged(@NonNull SurfaceTexture surfaceTexture, int i, int i2) {
    }
}