package com.seewo.factoryaging.mic;

import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
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.mic.view.MicLedBarView;
import j.n;
import j.p0.d.r;
import java.io.File;
import java.util.LinkedHashMap;
import java.util.Map;

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

    /* JADX INFO: Access modifiers changed from: private */
    public static final void N1(MicFragment micFragment) {
        r.f(micFragment, "this$0");
        g gVar = g.a;
        Context contextT1 = micFragment.t1();
        r.e(contextT1, "requireContext()");
        if (!gVar.g(contextT1)) {
            com.seewo.factoryaging.x0.c cVar = micFragment.d0;
            if (cVar == null) {
                r.t("mBinding");
                throw null;
            }
            cVar.z(micFragment.f0(R.string.message_no_mic_device));
            com.seewo.factoryaging.x0.c cVar2 = micFragment.d0;
            if (cVar2 != null) {
                cVar2.y(false);
                return;
            } else {
                r.t("mBinding");
                throw null;
            }
        }
        c cVarH1 = micFragment.H1();
        r.c(cVarH1);
        cVarH1.l();
        com.seewo.factoryaging.x0.c cVar3 = micFragment.d0;
        if (cVar3 == null) {
            r.t("mBinding");
            throw null;
        }
        cVar3.y(true);
        com.seewo.factoryaging.x0.c cVar4 = micFragment.d0;
        if (cVar4 != null) {
            cVar4.x(micFragment);
        } else {
            r.t("mBinding");
            throw null;
        }
    }

    @Override // g.h.a.c
    public View B0(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        r.f(layoutInflater, "inflater");
        ViewDataBinding viewDataBindingD = androidx.databinding.f.d(layoutInflater, R.layout.fragment_mic, viewGroup, false);
        r.e(viewDataBindingD, "inflate(inflater, R.layo…nt_mic, container, false)");
        com.seewo.factoryaging.x0.c cVar = (com.seewo.factoryaging.x0.c) viewDataBindingD;
        this.d0 = cVar;
        if (cVar == null) {
            r.t("mBinding");
            throw null;
        }
        View viewFindViewById = cVar.n().findViewById(R.id.mic_start_button);
        r.e(viewFindViewById, "mBinding.root.findViewById(R.id.mic_start_button)");
        this.c0 = (Button) viewFindViewById;
        com.seewo.factoryaging.x0.c cVar2 = this.d0;
        if (cVar2 == null) {
            r.t("mBinding");
            throw null;
        }
        View viewFindViewById2 = cVar2.n().findViewById(R.id.fl_mic);
        r.e(viewFindViewById2, "mBinding.root.findViewById(R.id.fl_mic)");
        this.e0 = (FrameLayout) viewFindViewById2;
        ArgbEvaluator argbEvaluator = new ArgbEvaluator();
        FrameLayout frameLayout = this.e0;
        if (frameLayout == null) {
            r.t("mFlMic");
            throw null;
        }
        ObjectAnimator objectAnimatorOfInt = ObjectAnimator.ofInt(frameLayout, "backgroundColor", this.f0, this.g0, this.h0, this.i0, this.j0);
        r.e(objectAnimatorOfInt, "ofInt(mFlMic, \"backgroun… BLACK, RED, GREEN, BLUE)");
        this.k0 = objectAnimatorOfInt;
        if (objectAnimatorOfInt == null) {
            r.t("colorAnimMic");
            throw null;
        }
        objectAnimatorOfInt.setDuration(3000L);
        ValueAnimator valueAnimator = this.k0;
        if (valueAnimator == null) {
            r.t("colorAnimMic");
            throw null;
        }
        valueAnimator.setEvaluator(argbEvaluator);
        ValueAnimator valueAnimator2 = this.k0;
        if (valueAnimator2 == null) {
            r.t("colorAnimMic");
            throw null;
        }
        valueAnimator2.setRepeatCount(-1);
        ValueAnimator valueAnimator3 = this.k0;
        if (valueAnimator3 == null) {
            r.t("colorAnimMic");
            throw null;
        }
        valueAnimator3.setRepeatMode(2);
        ValueAnimator valueAnimator4 = this.k0;
        if (valueAnimator4 == null) {
            r.t("colorAnimMic");
            throw null;
        }
        valueAnimator4.start();
        Button button = this.c0;
        if (button == null) {
            r.t("mButton");
            throw null;
        }
        ObjectAnimator objectAnimatorOfInt2 = ObjectAnimator.ofInt(button, "backgroundColor", this.j0, this.i0, this.h0, this.g0, this.f0);
        r.e(objectAnimatorOfInt2, "ofInt(mButton, \"backgrou…GREEN, RED, BLACK, WHITE)");
        this.l0 = objectAnimatorOfInt2;
        if (objectAnimatorOfInt2 == null) {
            r.t("colorAnimButton");
            throw null;
        }
        objectAnimatorOfInt2.setDuration(3000L);
        ValueAnimator valueAnimator5 = this.l0;
        if (valueAnimator5 == null) {
            r.t("colorAnimButton");
            throw null;
        }
        valueAnimator5.setEvaluator(argbEvaluator);
        ValueAnimator valueAnimator6 = this.l0;
        if (valueAnimator6 == null) {
            r.t("colorAnimButton");
            throw null;
        }
        valueAnimator6.setRepeatCount(-1);
        ValueAnimator valueAnimator7 = this.l0;
        if (valueAnimator7 == null) {
            r.t("colorAnimButton");
            throw null;
        }
        valueAnimator7.setRepeatMode(2);
        ValueAnimator valueAnimator8 = this.l0;
        if (valueAnimator8 == null) {
            r.t("colorAnimButton");
            throw null;
        }
        valueAnimator8.start();
        com.seewo.factoryaging.x0.c cVar3 = this.d0;
        if (cVar3 != null) {
            return cVar3.n();
        }
        r.t("mBinding");
        throw null;
    }

    @Override // g.h.a.c
    public void C0() {
        super.C0();
        c cVarH1 = H1();
        r.c(cVarH1);
        cVarH1.m();
    }

    @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.n0.clear();
    }

    @Override // com.seewo.factoryaging.s0.d
    public void J1(View view, Bundle bundle) {
        r.f(view, "view");
        super.J1(view, bundle);
        View viewFindViewById = view.findViewById(R.id.mic_led_view);
        r.e(viewFindViewById, "view.findViewById(R.id.mic_led_view)");
        this.b0 = (MicLedBarView) viewFindViewById;
        View viewFindViewById2 = view.findViewById(R.id.mic_start_button);
        r.e(viewFindViewById2, "view.findViewById(R.id.mic_start_button)");
        this.c0 = (Button) viewFindViewById2;
        ArgbEvaluator argbEvaluator = new ArgbEvaluator();
        MicLedBarView micLedBarView = this.b0;
        if (micLedBarView == null) {
            r.t("mMicLedView");
            throw null;
        }
        ObjectAnimator objectAnimatorOfInt = ObjectAnimator.ofInt(micLedBarView, "backgroundColor", this.j0, this.i0, this.h0, this.g0, this.f0);
        r.e(objectAnimatorOfInt, "ofInt(mMicLedView, \"back…GREEN, RED, BLACK, WHITE)");
        this.m0 = objectAnimatorOfInt;
        if (objectAnimatorOfInt == null) {
            r.t("colorAnimMicLed");
            throw null;
        }
        objectAnimatorOfInt.setDuration(3000L);
        ValueAnimator valueAnimator = this.m0;
        if (valueAnimator == null) {
            r.t("colorAnimMicLed");
            throw null;
        }
        valueAnimator.setEvaluator(argbEvaluator);
        ValueAnimator valueAnimator2 = this.m0;
        if (valueAnimator2 == null) {
            r.t("colorAnimMicLed");
            throw null;
        }
        valueAnimator2.setRepeatCount(-1);
        ValueAnimator valueAnimator3 = this.m0;
        if (valueAnimator3 == null) {
            r.t("colorAnimMicLed");
            throw null;
        }
        valueAnimator3.setRepeatMode(2);
        ValueAnimator valueAnimator4 = this.m0;
        if (valueAnimator4 != null) {
            valueAnimator4.start();
        } else {
            r.t("colorAnimMicLed");
            throw null;
        }
    }

    public final void K1(View view) {
        r.f(view, "view");
        com.seewo.factoryaging.x0.c cVar = this.d0;
        if (cVar == null) {
            r.t("mBinding");
            throw null;
        }
        if (!cVar.w()) {
            c cVarH1 = H1();
            r.c(cVarH1);
            cVarH1.l();
            com.seewo.factoryaging.x0.c cVar2 = this.d0;
            if (cVar2 != null) {
                cVar2.y(true);
                return;
            } else {
                r.t("mBinding");
                throw null;
            }
        }
        Log.i("MicFragment", "is burning. stop record");
        c cVarH12 = H1();
        r.c(cVarH12);
        cVarH12.m();
        com.seewo.factoryaging.x0.c cVar3 = this.d0;
        if (cVar3 == null) {
            r.t("mBinding");
            throw null;
        }
        cVar3.z(f0(R.string.message_warn_mic_reburn));
        com.seewo.factoryaging.x0.c cVar4 = this.d0;
        if (cVar4 != null) {
            cVar4.y(false);
        } else {
            r.t("mBinding");
            throw null;
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // com.seewo.factoryaging.s0.d
    /* JADX INFO: renamed from: L1, reason: merged with bridge method [inline-methods] */
    public c I1() {
        File filesDir;
        StringBuilder sb = new StringBuilder();
        Context contextP = P();
        sb.append((contextP == null || (filesDir = contextP.getFilesDir()) == null) ? null : filesDir.getAbsolutePath());
        sb.append("/data/files/");
        return new e(sb.toString());
    }

    @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);
        String strI = com.seewo.vcommons.data.c.i("persist.sys.aging_mic_timeout_sec", "8");
        r.e(strI, "getProperty(\"persist.sys…ng_mic_timeout_sec\", \"8\")");
        int i2 = Integer.parseInt(strI);
        Log.d("MicFragment", "onViewCreated: delayStartRecord = " + i2);
        Button button = this.c0;
        if (button == null) {
            r.t("mButton");
            throw null;
        }
        button.setVisibility(8);
        view.postDelayed(new Runnable() { // from class: com.seewo.factoryaging.mic.b
            @Override // java.lang.Runnable
            public final void run() {
                MicFragment.N1(this.b);
            }
        }, ((long) i2) * 1000);
        com.seewo.factoryaging.x0.c cVar = this.d0;
        if (cVar != null) {
            cVar.z(f0(R.string.message_waiting_mic_device));
        } else {
            r.t("mBinding");
            throw null;
        }
    }

    @Override // com.seewo.factoryaging.mic.d
    public void d(double d) {
        MicLedBarView micLedBarView = this.b0;
        if (micLedBarView != null) {
            micLedBarView.b((int) d);
        } else {
            r.t("mMicLedView");
            throw null;
        }
    }
}
