package com.seewo.factoryaging.newvideo;

import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.media.MediaPlayer;
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 android.widget.SeekBar;
import android.widget.TextView;
import android.widget.VideoView;
import com.cvte.vman.R;
import com.seewo.sdk.event.OSEvent;
import com.seewo.sdk.eventbus.OnEventOfOS;
import j.p0.d.r;
import java.util.LinkedHashMap;
import java.util.Map;
import org.greenrobot.eventbus.ThreadMode;

/* JADX INFO: compiled from: NewVideoFragment.kt */
/* JADX INFO: loaded from: classes.dex */
@j.n
public final class NewVideoFragment extends com.seewo.factoryaging.s0.d<m, l> implements m {
    private VideoView c0;
    private Button d0;
    private TextView e0;
    private TextView f0;
    private SeekBar g0;
    private FrameLayout h0;
    private FrameLayout i0;
    private ValueAnimator o0;
    private ValueAnimator p0;
    private ValueAnimator q0;
    private boolean r0;
    private boolean s0;
    public Map<Integer, View> t0 = new LinkedHashMap();
    private final String b0 = "NewVideoFragment";
    private int j0 = -1;
    private int k0 = -16777216;
    private int l0 = -65536;
    private int m0 = -16711936;
    private int n0 = -16776961;

    /* JADX INFO: compiled from: NewVideoFragment.kt */
    public static final class a implements SeekBar.OnSeekBarChangeListener {
        a() {
        }

        @Override // android.widget.SeekBar.OnSeekBarChangeListener
        public void onProgressChanged(SeekBar seekBar, int i2, boolean z) {
            if (z) {
                h.c.c.d.b.d(i2);
                TextView textView = NewVideoFragment.this.f0;
                if (textView != null) {
                    textView.setText(String.valueOf(h.c.c.d.b.b()));
                } else {
                    r.t("mVolumeTextView");
                    throw null;
                }
            }
        }

        @Override // android.widget.SeekBar.OnSeekBarChangeListener
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override // android.widget.SeekBar.OnSeekBarChangeListener
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    }

    private final void L1() {
        if (this.r0) {
            this.r0 = false;
            VideoView videoView = this.c0;
            if (videoView == null) {
                r.t("mVideoView");
                throw null;
            }
            videoView.pause();
            Button button = this.d0;
            if (button != null) {
                button.setText(a0().getString(R.string.message_start_burn));
                return;
            } else {
                r.t("mBtnVideoStart");
                throw null;
            }
        }
        this.r0 = true;
        VideoView videoView2 = this.c0;
        if (videoView2 == null) {
            r.t("mVideoView");
            throw null;
        }
        videoView2.start();
        Button button2 = this.d0;
        if (button2 != null) {
            button2.setText(a0().getString(R.string.message_stop_burn));
        } else {
            r.t("mBtnVideoStart");
            throw null;
        }
    }

    private final void M1() {
        this.s0 = true;
        VideoView videoView = this.c0;
        if (videoView == null) {
            r.t("mVideoView");
            throw null;
        }
        videoView.pause();
        l lVarH1 = H1();
        if (lVarH1 != null) {
            lVarH1.m();
        }
        org.greenrobot.eventbus.c.c().s(this);
        h.c.c.c.d().l(this);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void N1(MediaPlayer mediaPlayer) {
        mediaPlayer.start();
        mediaPlayer.setLooping(true);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final boolean T1(NewVideoFragment newVideoFragment, MediaPlayer mediaPlayer, int i2, int i3) {
        r.f(newVideoFragment, "this$0");
        Log.d(newVideoFragment.b0, "setOnErrorListener: " + i2);
        return true;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void U1(NewVideoFragment newVideoFragment, View view) {
        r.f(newVideoFragment, "this$0");
        newVideoFragment.L1();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void V1(NewVideoFragment newVideoFragment, Boolean bool) {
        r.f(newVideoFragment, "this$0");
        int iB = h.c.c.d.b.b();
        TextView textView = newVideoFragment.f0;
        if (textView == null) {
            r.t("mVolumeTextView");
            throw null;
        }
        textView.setText(String.valueOf(iB));
        SeekBar seekBar = newVideoFragment.g0;
        if (seekBar != null) {
            seekBar.setProgress(iB);
        } else {
            r.t("mVolumeSeekBar");
            throw null;
        }
    }

    @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_new_video, (ViewGroup) null);
        View viewFindViewById = viewInflate.findViewById(R.id.video_view);
        r.e(viewFindViewById, "rootView.findViewById(R.id.video_view)");
        VideoView videoView = (VideoView) viewFindViewById;
        this.c0 = videoView;
        if (videoView == null) {
            r.t("mVideoView");
            throw null;
        }
        videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() { // from class: com.seewo.factoryaging.newvideo.a
            @Override // android.media.MediaPlayer.OnErrorListener
            public final boolean onError(MediaPlayer mediaPlayer, int i2, int i3) {
                return NewVideoFragment.T1(this.a, mediaPlayer, i2, i3);
            }
        });
        View viewFindViewById2 = viewInflate.findViewById(R.id.volume_layout);
        r.e(viewFindViewById2, "rootView.findViewById(R.id.volume_layout)");
        this.h0 = (FrameLayout) viewFindViewById2;
        View viewFindViewById3 = viewInflate.findViewById(R.id.video_burn_state_view);
        r.e(viewFindViewById3, "rootView.findViewById(R.id.video_burn_state_view)");
        this.e0 = (TextView) viewFindViewById3;
        View viewFindViewById4 = viewInflate.findViewById(R.id.btn_video_start);
        r.e(viewFindViewById4, "rootView.findViewById(R.id.btn_video_start)");
        this.d0 = (Button) viewFindViewById4;
        View viewFindViewById5 = viewInflate.findViewById(R.id.volume_text);
        r.e(viewFindViewById5, "rootView.findViewById(R.id.volume_text)");
        this.f0 = (TextView) viewFindViewById5;
        View viewFindViewById6 = viewInflate.findViewById(R.id.seekBar_volume);
        r.e(viewFindViewById6, "rootView.findViewById(R.id.seekBar_volume)");
        this.g0 = (SeekBar) viewFindViewById6;
        View viewFindViewById7 = viewInflate.findViewById(R.id.fl_video);
        r.e(viewFindViewById7, "rootView.findViewById(R.id.fl_video)");
        this.i0 = (FrameLayout) viewFindViewById7;
        org.greenrobot.eventbus.c.c().q(this);
        ArgbEvaluator argbEvaluator = new ArgbEvaluator();
        FrameLayout frameLayout = this.i0;
        if (frameLayout == null) {
            r.t("mFlVideo");
            throw null;
        }
        ObjectAnimator objectAnimatorOfInt = ObjectAnimator.ofInt(frameLayout, "backgroundColor", this.j0, this.k0, this.l0, this.m0, this.n0);
        r.e(objectAnimatorOfInt, "ofInt(mFlVideo, \"backgro…BLACK, RED,  GREEN, BLUE)");
        this.o0 = objectAnimatorOfInt;
        if (objectAnimatorOfInt == null) {
            r.t("colorAnimVideo");
            throw null;
        }
        objectAnimatorOfInt.setDuration(3000L);
        ValueAnimator valueAnimator = this.o0;
        if (valueAnimator == null) {
            r.t("colorAnimVideo");
            throw null;
        }
        valueAnimator.setEvaluator(argbEvaluator);
        ValueAnimator valueAnimator2 = this.o0;
        if (valueAnimator2 == null) {
            r.t("colorAnimVideo");
            throw null;
        }
        valueAnimator2.setRepeatCount(-1);
        ValueAnimator valueAnimator3 = this.o0;
        if (valueAnimator3 == null) {
            r.t("colorAnimVideo");
            throw null;
        }
        valueAnimator3.setRepeatMode(2);
        ValueAnimator valueAnimator4 = this.o0;
        if (valueAnimator4 == null) {
            r.t("colorAnimVideo");
            throw null;
        }
        valueAnimator4.start();
        Button button = this.d0;
        if (button == null) {
            r.t("mBtnVideoStart");
            throw null;
        }
        ObjectAnimator objectAnimatorOfInt2 = ObjectAnimator.ofInt(button, "backgroundColor", this.n0, this.m0, this.l0, this.k0, this.j0);
        r.e(objectAnimatorOfInt2, "ofInt(mBtnVideoStart, \"b…REEN, RED,  BLACK, WHITE)");
        this.p0 = objectAnimatorOfInt2;
        if (objectAnimatorOfInt2 == null) {
            r.t("colorAnimButton");
            throw null;
        }
        objectAnimatorOfInt2.setDuration(3000L);
        ValueAnimator valueAnimator5 = this.p0;
        if (valueAnimator5 == null) {
            r.t("colorAnimButton");
            throw null;
        }
        valueAnimator5.setEvaluator(argbEvaluator);
        ValueAnimator valueAnimator6 = this.p0;
        if (valueAnimator6 == null) {
            r.t("colorAnimButton");
            throw null;
        }
        valueAnimator6.setRepeatCount(-1);
        ValueAnimator valueAnimator7 = this.p0;
        if (valueAnimator7 == null) {
            r.t("colorAnimButton");
            throw null;
        }
        valueAnimator7.setRepeatMode(2);
        ValueAnimator valueAnimator8 = this.p0;
        if (valueAnimator8 == null) {
            r.t("colorAnimButton");
            throw null;
        }
        valueAnimator8.start();
        SeekBar seekBar = this.g0;
        if (seekBar == null) {
            r.t("mVolumeSeekBar");
            throw null;
        }
        ObjectAnimator objectAnimatorOfInt3 = ObjectAnimator.ofInt(seekBar, "backgroundColor", this.n0, this.m0, this.l0, this.k0, this.j0);
        r.e(objectAnimatorOfInt3, "ofInt(mVolumeSeekBar, \"b…REEN, RED,  BLACK, WHITE)");
        this.q0 = objectAnimatorOfInt3;
        if (objectAnimatorOfInt3 == null) {
            r.t("colorAnimSeekBar");
            throw null;
        }
        objectAnimatorOfInt3.setDuration(3000L);
        ValueAnimator valueAnimator9 = this.q0;
        if (valueAnimator9 == null) {
            r.t("colorAnimSeekBar");
            throw null;
        }
        valueAnimator9.setEvaluator(argbEvaluator);
        ValueAnimator valueAnimator10 = this.q0;
        if (valueAnimator10 == null) {
            r.t("colorAnimSeekBar");
            throw null;
        }
        valueAnimator10.setRepeatCount(-1);
        ValueAnimator valueAnimator11 = this.q0;
        if (valueAnimator11 == null) {
            r.t("colorAnimSeekBar");
            throw null;
        }
        valueAnimator11.setRepeatMode(2);
        ValueAnimator valueAnimator12 = this.q0;
        if (valueAnimator12 == null) {
            r.t("colorAnimSeekBar");
            throw null;
        }
        valueAnimator12.start();
        VideoView videoView2 = this.c0;
        if (videoView2 == null) {
            r.t("mVideoView");
            throw null;
        }
        videoView2.requestFocus();
        Button button2 = this.d0;
        if (button2 == null) {
            r.t("mBtnVideoStart");
            throw null;
        }
        button2.setOnClickListener(new View.OnClickListener() { // from class: com.seewo.factoryaging.newvideo.b
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                NewVideoFragment.U1(this.b, view);
            }
        });
        TextView textView = this.f0;
        if (textView == null) {
            r.t("mVolumeTextView");
            throw null;
        }
        textView.setText(String.valueOf(h.c.c.d.b.b()));
        SeekBar seekBar2 = this.g0;
        if (seekBar2 != null) {
            seekBar2.setOnSeekBarChangeListener(new a());
            return viewInflate;
        }
        r.t("mVolumeSeekBar");
        throw null;
    }

    @Override // g.h.a.c
    public void C0() {
        super.C0();
        if (this.s0) {
            return;
        }
        M1();
    }

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

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

    @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);
        l lVarH1 = H1();
        if (lVarH1 != null) {
            lVarH1.l();
        }
        h.c.c.c.d().j(this);
    }

    @Override // com.seewo.factoryaging.newvideo.m
    public Context a() {
        Context contextP = P();
        r.c(contextP);
        return contextP;
    }

    @Override // com.seewo.factoryaging.newvideo.m
    public void f(String str) {
        r.f(str, "message");
        TextView textView = this.e0;
        if (textView == null) {
            r.t("mVideoBurnStateView");
            throw null;
        }
        textView.setVisibility(0);
        FrameLayout frameLayout = this.h0;
        if (frameLayout == null) {
            r.t("mVolumeLayout");
            throw null;
        }
        frameLayout.setVisibility(8);
        Button button = this.d0;
        if (button == null) {
            r.t("mBtnVideoStart");
            throw null;
        }
        button.setVisibility(8);
        TextView textView2 = this.e0;
        if (textView2 != null) {
            textView2.setText(str);
        } else {
            r.t("mVideoBurnStateView");
            throw null;
        }
    }

    @org.greenrobot.eventbus.m(sticky = true, threadMode = ThreadMode.MAIN)
    public final void handleBackPress(com.seewo.factoryaging.t0.b bVar) {
        r.f(bVar, "event");
        Log.d(this.b0, "handleBackPress " + bVar.a());
        if (!this.s0) {
            M1();
        }
        com.seewo.factoryaging.e1.i.a.b(bVar.a(), false);
    }

    @Override // com.seewo.factoryaging.newvideo.m
    public void i() {
        TextView textView = this.e0;
        if (textView == null) {
            r.t("mVideoBurnStateView");
            throw null;
        }
        textView.setVisibility(0);
        Button button = this.d0;
        if (button == null) {
            r.t("mBtnVideoStart");
            throw null;
        }
        button.setVisibility(8);
        TextView textView2 = this.e0;
        if (textView2 != null) {
            textView2.setText(f0(R.string.message_searching_burn_video));
        } else {
            r.t("mVideoBurnStateView");
            throw null;
        }
    }

    @Override // com.seewo.factoryaging.newvideo.m
    public void n(String str) {
        r.f(str, "message");
        TextView textView = this.e0;
        if (textView == null) {
            r.t("mVideoBurnStateView");
            throw null;
        }
        textView.setVisibility(0);
        FrameLayout frameLayout = this.h0;
        if (frameLayout == null) {
            r.t("mVolumeLayout");
            throw null;
        }
        frameLayout.setVisibility(8);
        Button button = this.d0;
        if (button == null) {
            r.t("mBtnVideoStart");
            throw null;
        }
        button.setVisibility(8);
        TextView textView2 = this.e0;
        if (textView2 != null) {
            textView2.setText(str);
        } else {
            r.t("mVideoBurnStateView");
            throw null;
        }
    }

    @OnEventOfOS
    @SuppressLint({"CheckResult"})
    public final void onVolumeChanged(OSEvent.VolumeChanged volumeChanged) {
        r.f(volumeChanged, "x");
        i.a.d.s(Boolean.TRUE).u(i.a.j.b.a.a()).x(new i.a.m.c() { // from class: com.seewo.factoryaging.newvideo.d
            @Override // i.a.m.c
            public final void accept(Object obj) {
                NewVideoFragment.V1(this.a, (Boolean) obj);
            }
        });
    }

    @Override // com.seewo.factoryaging.newvideo.m
    public void y(String str) {
        r.f(str, "videoPath");
        Log.d(this.b0, "configBurnVideoSucceed: " + str);
        VideoView videoView = this.c0;
        if (videoView == null) {
            r.t("mVideoView");
            throw null;
        }
        videoView.setVideoPath(str);
        VideoView videoView2 = this.c0;
        if (videoView2 == null) {
            r.t("mVideoView");
            throw null;
        }
        videoView2.requestFocus();
        Button button = this.d0;
        if (button == null) {
            r.t("mBtnVideoStart");
            throw null;
        }
        button.setVisibility(8);
        TextView textView = this.e0;
        if (textView == null) {
            r.t("mVideoBurnStateView");
            throw null;
        }
        textView.setVisibility(8);
        FrameLayout frameLayout = this.h0;
        if (frameLayout == null) {
            r.t("mVolumeLayout");
            throw null;
        }
        frameLayout.setVisibility(8);
        SeekBar seekBar = this.g0;
        if (seekBar == null) {
            r.t("mVolumeSeekBar");
            throw null;
        }
        seekBar.setProgress(h.c.c.d.b.b());
        this.r0 = true;
        VideoView videoView3 = this.c0;
        if (videoView3 != null) {
            videoView3.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { // from class: com.seewo.factoryaging.newvideo.c
                @Override // android.media.MediaPlayer.OnPreparedListener
                public final void onPrepared(MediaPlayer mediaPlayer) {
                    NewVideoFragment.N1(mediaPlayer);
                }
            });
        } else {
            r.t("mVideoView");
            throw null;
        }
    }
}
