package com.seewo.factoryaging.r0;

import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import androidx.databinding.ViewDataBinding;
import com.cvte.vman.R;
import com.seewo.factoryaging.camera.view.CameraSurfaceView;
import j.p0.d.r;
import java.util.LinkedHashMap;
import java.util.Map;
import org.greenrobot.eventbus.ThreadMode;
import org.greenrobot.eventbus.m;

/* JADX INFO: compiled from: CameraFragment.kt */
/* JADX INFO: loaded from: classes.dex */
public final class j extends com.seewo.factoryaging.s0.d<h, g> implements h {
    private com.seewo.factoryaging.x0.a b0;
    private boolean c0;
    private boolean d0;
    private Button e0;
    private Button f0;
    private FrameLayout g0;
    private ValueAnimator m0;
    private ValueAnimator n0;
    private ValueAnimator o0;
    public Map<Integer, View> p0 = new LinkedHashMap();
    private int h0 = -1;
    private int i0 = -16777216;
    private int j0 = -65536;
    private int k0 = -16711936;
    private int l0 = -16776961;

    /* JADX INFO: Access modifiers changed from: private */
    public static final void M1(j jVar) {
        r.f(jVar, "this$0");
        jVar.d0 = false;
        jVar.Q1();
    }

    private final void Q1() {
        com.seewo.factoryaging.x0.a aVar = this.b0;
        if (aVar == null) {
            r.t("mBinding");
            throw null;
        }
        aVar.A(true);
        com.seewo.factoryaging.x0.a aVar2 = this.b0;
        if (aVar2 == null) {
            r.t("mBinding");
            throw null;
        }
        if (!aVar2.t.b()) {
            com.seewo.factoryaging.x0.a aVar3 = this.b0;
            if (aVar3 != null) {
                aVar3.t.postDelayed(new Runnable() { // from class: com.seewo.factoryaging.r0.d
                    @Override // java.lang.Runnable
                    public final void run() {
                        j.R1(this.b);
                    }
                }, 1000L);
                return;
            } else {
                r.t("mBinding");
                throw null;
            }
        }
        Log.i("CameraFragment", "startPreview");
        try {
            com.seewo.factoryaging.x0.a aVar4 = this.b0;
            if (aVar4 != null) {
                aVar4.t.c();
            } else {
                r.t("mBinding");
                throw null;
            }
        } catch (Exception e) {
            this.c0 = false;
            com.seewo.factoryaging.x0.a aVar5 = this.b0;
            if (aVar5 != null) {
                aVar5.B(e.getMessage());
            } else {
                r.t("mBinding");
                throw null;
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void R1(j jVar) {
        r.f(jVar, "this$0");
        jVar.Q1();
    }

    private final void S1(boolean z) {
        g gVarH1 = H1();
        r.c(gVarH1);
        gVarH1.m();
        com.seewo.factoryaging.x0.a aVar = this.b0;
        if (aVar == null) {
            r.t("mBinding");
            throw null;
        }
        aVar.t.d();
        if (z) {
            com.seewo.factoryaging.x0.a aVar2 = this.b0;
            if (aVar2 == null) {
                r.t("mBinding");
                throw null;
            }
            aVar2.A(false);
            com.seewo.factoryaging.x0.a aVar3 = this.b0;
            if (aVar3 != null) {
                aVar3.B(f0(R.string.message_warn_camera_reburn));
            } else {
                r.t("mBinding");
                throw null;
            }
        }
    }

    static /* synthetic */ void T1(j jVar, boolean z, int i2, Object obj) {
        if ((i2 & 1) != 0) {
            z = true;
        }
        jVar.S1(z);
    }

    @Override // g.h.a.c
    public View B0(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        r.f(layoutInflater, "inflater");
        View viewInflate = layoutInflater.inflate(R.layout.fragment_camera, viewGroup);
        View viewFindViewById = viewInflate.findViewById(R.id.btn1_camera);
        r.e(viewFindViewById, "inflate.findViewById(R.id.btn1_camera)");
        this.e0 = (Button) viewFindViewById;
        View viewFindViewById2 = viewInflate.findViewById(R.id.btn2_camera);
        r.e(viewFindViewById2, "inflate.findViewById(R.id.btn2_camera)");
        this.f0 = (Button) viewFindViewById2;
        View viewFindViewById3 = viewInflate.findViewById(R.id.fl_camera);
        r.e(viewFindViewById3, "inflate.findViewById(R.id.fl_camera)");
        this.g0 = (FrameLayout) viewFindViewById3;
        ArgbEvaluator argbEvaluator = new ArgbEvaluator();
        FrameLayout frameLayout = this.g0;
        if (frameLayout == null) {
            r.t("mFlCamera");
            throw null;
        }
        ObjectAnimator objectAnimatorOfInt = ObjectAnimator.ofInt(frameLayout, "backgroundColor", this.h0, this.i0, this.j0, this.k0, this.l0);
        r.e(objectAnimatorOfInt, "ofInt(mFlCamera, \"backgr…BLACK, RED,  GREEN, BLUE)");
        this.m0 = objectAnimatorOfInt;
        if (objectAnimatorOfInt == null) {
            r.t("colorAnimCamera");
            throw null;
        }
        objectAnimatorOfInt.setDuration(3000L);
        ValueAnimator valueAnimator = this.m0;
        if (valueAnimator == null) {
            r.t("colorAnimCamera");
            throw null;
        }
        valueAnimator.setEvaluator(argbEvaluator);
        ValueAnimator valueAnimator2 = this.m0;
        if (valueAnimator2 == null) {
            r.t("colorAnimCamera");
            throw null;
        }
        valueAnimator2.setRepeatCount(-1);
        ValueAnimator valueAnimator3 = this.m0;
        if (valueAnimator3 == null) {
            r.t("colorAnimCamera");
            throw null;
        }
        valueAnimator3.setRepeatMode(2);
        ValueAnimator valueAnimator4 = this.m0;
        if (valueAnimator4 == null) {
            r.t("colorAnimCamera");
            throw null;
        }
        valueAnimator4.start();
        Button button = this.e0;
        if (button == null) {
            r.t("mBtn1Camera");
            throw null;
        }
        ObjectAnimator objectAnimatorOfInt2 = ObjectAnimator.ofInt(button, "backgroundColor", this.h0, this.i0, this.j0, this.k0, this.l0);
        r.e(objectAnimatorOfInt2, "ofInt(mBtn1Camera, \"back…BLACK, RED,  GREEN, BLUE)");
        this.n0 = objectAnimatorOfInt2;
        if (objectAnimatorOfInt2 == null) {
            r.t("colorAnimButton1");
            throw null;
        }
        objectAnimatorOfInt2.setDuration(3000L);
        ValueAnimator valueAnimator5 = this.n0;
        if (valueAnimator5 == null) {
            r.t("colorAnimButton1");
            throw null;
        }
        valueAnimator5.setEvaluator(argbEvaluator);
        ValueAnimator valueAnimator6 = this.n0;
        if (valueAnimator6 == null) {
            r.t("colorAnimButton1");
            throw null;
        }
        valueAnimator6.setRepeatCount(-1);
        ValueAnimator valueAnimator7 = this.n0;
        if (valueAnimator7 == null) {
            r.t("colorAnimButton1");
            throw null;
        }
        valueAnimator7.setRepeatMode(2);
        ValueAnimator valueAnimator8 = this.n0;
        if (valueAnimator8 == null) {
            r.t("colorAnimButton1");
            throw null;
        }
        valueAnimator8.start();
        Button button2 = this.f0;
        if (button2 == null) {
            r.t("mBtn2Camera");
            throw null;
        }
        ObjectAnimator objectAnimatorOfInt3 = ObjectAnimator.ofInt(button2, "backgroundColor", this.h0, this.i0, this.j0, this.k0, this.l0);
        r.e(objectAnimatorOfInt3, "ofInt(mBtn2Camera, \"back…BLACK, RED,  GREEN, BLUE)");
        this.o0 = objectAnimatorOfInt3;
        if (objectAnimatorOfInt3 == null) {
            r.t("colorAnimButton2");
            throw null;
        }
        objectAnimatorOfInt3.setDuration(3000L);
        ValueAnimator valueAnimator9 = this.o0;
        if (valueAnimator9 == null) {
            r.t("colorAnimButton2");
            throw null;
        }
        valueAnimator9.setEvaluator(argbEvaluator);
        ValueAnimator valueAnimator10 = this.o0;
        if (valueAnimator10 == null) {
            r.t("colorAnimButton2");
            throw null;
        }
        valueAnimator10.setRepeatCount(-1);
        ValueAnimator valueAnimator11 = this.o0;
        if (valueAnimator11 == null) {
            r.t("colorAnimButton2");
            throw null;
        }
        valueAnimator11.setRepeatMode(2);
        ValueAnimator valueAnimator12 = this.o0;
        if (valueAnimator12 == null) {
            r.t("colorAnimButton2");
            throw null;
        }
        valueAnimator12.start();
        ViewDataBinding viewDataBindingD = androidx.databinding.f.d(layoutInflater, R.layout.fragment_camera, viewGroup, false);
        r.e(viewDataBindingD, "inflate(inflater, R.layo…camera, container, false)");
        com.seewo.factoryaging.x0.a aVar = (com.seewo.factoryaging.x0.a) viewDataBindingD;
        this.b0 = aVar;
        if (aVar == null) {
            r.t("mBinding");
            throw null;
        }
        aVar.A(false);
        com.seewo.factoryaging.x0.a aVar2 = this.b0;
        if (aVar2 == null) {
            r.t("mBinding");
            throw null;
        }
        aVar2.y(this);
        com.seewo.factoryaging.x0.a aVar3 = this.b0;
        if (aVar3 == null) {
            r.t("mBinding");
            throw null;
        }
        aVar3.B(f0(R.string.message_opening_camera));
        com.seewo.factoryaging.x0.a aVar4 = this.b0;
        if (aVar4 == null) {
            r.t("mBinding");
            throw null;
        }
        aVar4.t.setCameraStateListener(new CameraSurfaceView.a() { // from class: com.seewo.factoryaging.r0.f
        });
        com.seewo.factoryaging.x0.a aVar5 = this.b0;
        if (aVar5 != null) {
            return aVar5.n();
        }
        r.t("mBinding");
        throw null;
    }

    @Override // g.h.a.c
    public void C0() {
        super.C0();
        if (org.greenrobot.eventbus.c.c().j(this)) {
            org.greenrobot.eventbus.c.c().s(this);
        }
    }

    @Override // com.seewo.factoryaging.s0.d, g.h.a.c
    public /* synthetic */ void E0() {
        super.E0();
        G1();
    }

    @Override // com.seewo.factoryaging.s0.d
    public void G1() {
        this.p0.clear();
    }

    public final void K1(View view) {
        r.f(view, "view");
        com.seewo.factoryaging.x0.a aVar = this.b0;
        if (aVar == null) {
            r.t("mBinding");
            throw null;
        }
        if (aVar.w()) {
            com.seewo.factoryaging.x0.a aVar2 = this.b0;
            if (aVar2 == null) {
                r.t("mBinding");
                throw null;
            }
            aVar2.z(false);
            Log.i("CameraFragment", "stop camera auto rotate");
            g gVarH1 = H1();
            r.c(gVarH1);
            gVarH1.m();
            return;
        }
        com.seewo.factoryaging.x0.a aVar3 = this.b0;
        if (aVar3 == null) {
            r.t("mBinding");
            throw null;
        }
        aVar3.z(true);
        Log.i("CameraFragment", "initCamera camera auto rotate");
        g gVarH12 = H1();
        r.c(gVarH12);
        gVarH12.l();
    }

    public final void L1(View view) {
        r.f(view, "view");
        com.seewo.factoryaging.x0.a aVar = this.b0;
        if (aVar == null) {
            r.t("mBinding");
            throw null;
        }
        if (!aVar.x()) {
            view.postDelayed(new Runnable() { // from class: com.seewo.factoryaging.r0.e
                @Override // java.lang.Runnable
                public final void run() {
                    j.M1(this.b);
                }
            }, 500L);
            return;
        }
        Log.i("CameraFragment", "stop preview");
        T1(this, false, 1, null);
        this.d0 = true;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // com.seewo.factoryaging.s0.d
    /* JADX INFO: renamed from: N1, reason: merged with bridge method [inline-methods] */
    public g I1() {
        return new i();
    }

    @Override // com.seewo.factoryaging.s0.d, g.h.a.c
    public void V0(View view, Bundle bundle) {
        r.f(view, "view");
        super.V0(view, bundle);
        org.greenrobot.eventbus.c.c().q(this);
        com.seewo.factoryaging.x0.a aVar = this.b0;
        if (aVar != null) {
            aVar.A(true);
        } else {
            r.t("mBinding");
            throw null;
        }
    }

    @Override // com.seewo.factoryaging.r0.h
    public void e(int i2) {
        Log.i("CameraFragment", "directionChanged:" + i2);
    }

    @m(sticky = true, threadMode = ThreadMode.MAIN)
    public final void onVideoStartPlay(com.seewo.factoryaging.t0.h hVar) {
        r.f(hVar, "event");
        new StringBuilder().append("receive burn event of video, can initCamera camera: ");
        hVar.a();
        throw null;
    }

    @Override // com.seewo.factoryaging.r0.h
    public void p() {
        Log.i("CameraFragment", "rotation initCamera");
    }
}
