package com.ss.android.ugc.aweme.story.edit.clip.impl;

import X.0CB;
import X.0CD;
import X.0CH;
import X.0CN;
import X.1Bk;
import X.2Pr;
import X.7he;
import X.AnonymousClass4zV;
import X.AnonymousClass54U;
import X.AnonymousClass59Q;
import X.AnonymousClass5B2;
import X.C017553t;
import X.C017653u;
import X.C019854q;
import X.C024456k;
import X.C024756n;
import X.C026257c;
import X.C030758v;
import X.C032459m;
import X.C03615Ax;
import X.C03625Ay;
import X.C03635Az;
import X.Crj;
import X.Ls2;
import X.LsC;
import X.LsD;
import X.M12;
import android.content.Context;
import android.view.SurfaceView;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.story.edit.model.StoryEditClipModel;
import com.ss.android.ugc.aweme.story.edit.model.StoryEditModel;
import dmt.av.video.VEPreviewParams;
import java.util.Objects;

public final class VEEditClip implements C03635Az<C024756n>, C03635Az {
    public C026257c LIZ;
    public boolean LIZIZ;
    public AnonymousClass5B2 LIZJ = AnonymousClass5B2.INITIALIZED;
    public final LsD<StoryEditModel, StoryEditClipModel, C024756n> LIZLLL;
    public final LsD<StoryEditModel, StoryEditClipModel, C017553t> LJ;
    public final StoryEditModel LJFF;
    public final StoryEditClipModel LJI;
    public final 1Bk LJII = new 1Bk(this);
    public boolean LJIIIIZZ;
    public boolean LJIIIZ;
    public boolean LJIIJ;
    public final Crj LJIIJJI = 7he.LIZ(new C03625Ay(this));
    public final Crj LJIIL = 7he.LIZ(new C03615Ax(this));
    public final Context LJIILIIL;
    public final 0CH LJIILJJIL;
    public final SurfaceView LJIILL;

    static {
        Covode.recordClassIndex(117562);
    }

    public final C017553t LIZ() {
        return (C017553t) this.LJIIJJI.getValue();
    }

    public final C024756n LIZIZ() {
        return (C024756n) this.LJIIL.getValue();
    }

    public final void onStateChanged(0CH r2, 0CB r3) {
        if (r3 == 0CB.ON_START) {
            onStart();
        } else if (r3 == 0CB.ON_RESUME) {
            onResume();
        } else if (r3 == 0CB.ON_PAUSE) {
            onPause();
        } else if (r3 == 0CB.ON_STOP) {
            onStop();
        }
    }

    public final 0CD getLifecycle() {
        return this.LJII;
    }

    @0CN(LIZ = 0CB.ON_PAUSE)
    private final void onPause() {
        this.LJIIIIZZ = false;
        if (this.LIZJ == AnonymousClass5B2.LOADED) {
            this.LJII.LIZ(0CB.ON_PAUSE);
        }
    }

    @0CN(LIZ = 0CB.ON_RESUME)
    private final void onResume() {
        this.LJIIIIZZ = true;
        if (this.LIZJ == AnonymousClass5B2.LOADED) {
            this.LJII.LIZ(0CB.ON_RESUME);
        }
    }

    @0CN(LIZ = 0CB.ON_START)
    private final void onStart() {
        this.LJIIIZ = true;
        if (this.LIZJ == AnonymousClass5B2.LOADED) {
            this.LJII.LIZ(0CB.ON_START);
        }
    }

    @0CN(LIZ = 0CB.ON_STOP)
    private final void onStop() {
        this.LJIIIZ = true;
        if (this.LIZJ == AnonymousClass5B2.LOADED) {
            this.LJII.LIZ(0CB.ON_STOP);
        }
    }

    public final void LJFF() {
        C030758v LIZ2;
        this.LIZJ = AnonymousClass5B2.DESTROYED;
        if (this.LIZIZ && (LIZ2 = AnonymousClass59Q.LIZ(this)) != null) {
            LIZ2.LJIL();
        }
        this.LJII.LIZ(0CB.ON_DESTROY);
    }

    public final void LIZLLL() {
        this.LIZJ = AnonymousClass5B2.LOADED;
        LIZIZ().LIZ(true);
        if (this.LJIIIZ) {
            this.LJII.LIZ(0CB.ON_START);
        }
        if (this.LJIIIIZZ) {
            this.LJII.LIZ(0CB.ON_RESUME);
        }
    }

    public final void LJ() {
        this.LIZJ = AnonymousClass5B2.CREATED;
        this.LJIIJ = true;
        C030758v LIZIZ2 = LIZIZ().LIZIZ();
        if (LIZIZ2 != null) {
            LIZIZ2.LJIJJLI();
        }
        if (this.LJIIIIZZ) {
            this.LJII.LIZ(0CB.ON_PAUSE);
        }
        if (this.LJIIIZ) {
            this.LJII.LIZ(0CB.ON_STOP);
        }
    }

    public final void LIZJ() {
        this.LIZJ = AnonymousClass5B2.CREATED;
        LIZIZ().LJJ = new C032459m(this);
        LIZIZ().LIZ(this.LJIILIIL, LIZ(), this.LJIILL, (0CH) this);
        AnonymousClass54U.LIZIZ("VEEditClip.initEditor", new C024456k(this));
        if (LIZ() instanceof VEPreviewParams) {
            C017553t LIZ2 = LIZ();
            Objects.requireNonNull(LIZ2, "null cannot be cast to non-null type dmt.av.video.VEPreviewParams");
            if (((VEPreviewParams) LIZ2).isFastImport) {
                C030758v LIZIZ2 = LIZIZ().LIZIZ();
                AnonymousClass54U.LIZ("", (Ls2<2Pr>) new C019854q(this, LIZIZ2));
                AnonymousClass54U.LIZ("", LIZIZ2, (LsC<? super AnonymousClass4zV, 2Pr>) new C017653u(this));
            }
        }
        this.LJII.LIZ(0CB.ON_CREATE);
    }

    public VEEditClip(Context context, 0CH r10, LsD<? super StoryEditModel, ? super StoryEditClipModel, ? extends C024756n> lsD, LsD<? super StoryEditModel, ? super StoryEditClipModel, ? extends C017553t> lsD2, StoryEditModel storyEditModel, StoryEditClipModel storyEditClipModel, SurfaceView surfaceView) {
        StoryEditClipModel storyEditClipModel2 = storyEditClipModel;
        0CH r2 = r10;
        SurfaceView surfaceView2 = surfaceView;
        Context context2 = context;
        LsD<? super StoryEditModel, ? super StoryEditClipModel, ? extends C024756n> lsD3 = lsD;
        LsD<? super StoryEditModel, ? super StoryEditClipModel, ? extends C017553t> lsD4 = lsD2;
        StoryEditModel storyEditModel2 = storyEditModel;
        M12.LIZ(context2, r2, lsD3, lsD4, storyEditModel2, storyEditClipModel2, surfaceView2);
        this.LJIILIIL = context2;
        this.LJIILJJIL = r2;
        this.LIZLLL = lsD3;
        this.LJ = lsD4;
        this.LJFF = storyEditModel2;
        this.LJI = storyEditClipModel2;
        this.LJIILL = surfaceView2;
        r2.getLifecycle().LIZ(this);
    }
}
