package com.ss.android.ugc.aweme.badge;

import X.0CH;
import X.0HH;
import X.2Pr;
import X.2cN;
import X.30v;
import X.3EX;
import X.3af;
import X.5Am;
import X.5An;
import X.5vY;
import X.5wO;
import X.7he;
import X.B8T;
import X.C3303JTa;
import X.C3306JTd;
import X.C3307JTe;
import X.C3308JTf;
import X.C3309JTg;
import X.C3310JTh;
import X.C3312JTj;
import X.CbG;
import X.Crj;
import X.Cwt;
import X.D4t;
import X.DRZ;
import X.DUT;
import X.DUy;
import X.DUz;
import X.DV0;
import X.DV9;
import X.DVU;
import X.Drz;
import X.JTS;
import X.JTV;
import X.JTX;
import X.JTY;
import X.LsC;
import X.LsD;
import X.LsE;
import X.LsF;
import X.Lsh;
import X.M12;
import X.OQg;
import X.OQh;
import X.PHD;
import X.QHW;
import X.QJt;
import X.Qeg;
import android.app.Dialog;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.RelativeLayout;
import androidx.fragment.app.DialogFragment;
import androidx.recyclerview.widget.GridLayoutManager;
import com.bytedance.covode.number.Covode;
import com.bytedance.jedi.arch.JediViewModel;
import com.bytedance.lighten.loader.SmartImageView;
import com.ss.android.ugc.aweme.IProfileBadgeService;
import com.ss.android.ugc.aweme.account.profilebadge.ProfileBadgeServiceImpl;
import com.ss.android.ugc.aweme.profile.model.ProfileBadgeStruct;
import com.ss.android.ugc.aweme.profile.model.User;
import kotlin.h.b.n;

public final class EditProfileBadgeDialog extends DialogFragment implements 5vY, C3312JTj {
    public static final int LJIIIIZZ = 3;
    public static final C3310JTh LJIIIZ = new C3310JTh((byte) 0);
    public static final String LJIIL = "EditProfileBadgeDialog";
    public static final long LJIILIIL = 2000;
    public JTV LIZ;
    public boolean LIZIZ;
    public ProfileBadgeStruct LIZJ;
    public ProfileBadgeStruct LIZLLL;
    public JTY LJ;
    public GridLayoutManager LJFF;
    public final IProfileBadgeService LJI;
    public final User LJII;
    public final Crj LJIIJ = 7he.LIZ(new C3307JTe(this));
    public final Crj LJIIJJI;
    public SparseArray LJIILJJIL;

    public final OQg LIZ() {
        return (OQg) this.LJIIJ.getValue();
    }

    public final View LIZ(int i) {
        if (this.LJIILJJIL == null) {
            this.LJIILJJIL = new SparseArray();
        }
        View view = (View) this.LJIILJJIL.get(i);
        if (view != null) {
            return view;
        }
        View view2 = getView();
        if (view2 == null) {
            return null;
        }
        View findViewById = view2.findViewById(i);
        this.LJIILJJIL.put(i, findViewById);
        return findViewById;
    }

    public final EditProfileBadgeViewModel LIZIZ() {
        return (EditProfileBadgeViewModel) this.LJIIJJI.getValue();
    }

    public final boolean getUniqueOnlyGlobal() {
        return true;
    }

    public final /* bridge */ /* synthetic */ 5An getReceiver() {
        return this;
    }

    public final 0CH getLifecycleOwner() {
        5wO.LIZJ(this);
        return this;
    }

    public final DUz getLifecycleOwnerHolder() {
        5wO.LIZ(this);
        return this;
    }

    public final DUy<DVU> getReceiverHolder() {
        5wO.LIZIZ(this);
        return this;
    }

    public final /* synthetic */ void onDestroyView() {
        EditProfileBadgeDialog.super.onDestroyView();
        SparseArray sparseArray = this.LJIILJJIL;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

    static {
        Covode.recordClassIndex(54053);
    }

    public final void LIZJ() {
        OQh oQh = new OQh();
        30v.LIZ(oQh, new C3306JTd(this));
        LIZ(2131370625).setStatus(oQh);
        OQg LIZ2 = LIZ(2131370625);
        n.LIZIZ(LIZ2, "");
        LIZ2.setVisibility(0);
    }

    public final void LIZLLL() {
        3af r2 = new 3af(this);
        r2.LJ(2131831007);
        r2.LIZIZ(2131755697);
        r2.LIZLLL(2130968646);
        r2.LIZ(LJIILIIL);
        3af.LIZ(r2);
    }

    public final void LIZ(JTV jtv) {
        String str;
        this.LIZ = jtv;
        this.LIZIZ = true;
        Boolean bool = null;
        if (jtv != null) {
            str = jtv.getUrl();
            bool = jtv.getShouldShow();
        } else {
            str = null;
        }
        LIZ(str, bool);
    }

    public final void onCreate(Bundle bundle) {
        EditProfileBadgeDialog.super.onCreate(bundle);
        this.LIZJ = this.LJII.getProfileBadge();
        this.LIZLLL = this.LJII.getProfileBadge();
        setStyle(0, 2131887195);
    }

    public EditProfileBadgeDialog(User user) {
        M12.LIZ(user);
        this.LJII = user;
        IProfileBadgeService LIZIZ2 = ProfileBadgeServiceImpl.LIZIZ();
        n.LIZIZ(LIZIZ2, "");
        this.LJI = LIZIZ2;
        this.LJIIJJI = 7he.LIZ(new C3303JTa(this));
    }

    public final void LIZ(boolean z) {
        int i;
        if (z) {
            i = 8;
        } else {
            i = 0;
        }
        if (LIZ(2131364366) != null && LIZ(2131364369) != null && LIZ(2131364369) != null && LIZ(2131364377) != null) {
            RelativeLayout relativeLayout = (RelativeLayout) LIZ(2131364366);
            n.LIZIZ(relativeLayout, "");
            relativeLayout.setVisibility(i);
            Qeg LIZ2 = LIZ(2131364369);
            n.LIZIZ(LIZ2, "");
            LIZ2.setVisibility(i);
            Qeg LIZ3 = LIZ(2131364368);
            n.LIZIZ(LIZ3, "");
            LIZ3.setVisibility(i);
            CbG LIZ4 = LIZ(2131364377);
            n.LIZIZ(LIZ4, "");
            LIZ4.setVisibility(i);
        }
    }

    public final <VM1 extends JediViewModel<S1>, S1 extends 5Am, R> R withState(VM1 vm1, LsC<? super S1, ? extends R> lsC) {
        M12.LIZ(vm1, lsC);
        return 5wO.LIZ(vm1, lsC);
    }

    public final void LIZ(String str, Boolean bool) {
        if (str != null && n.LIZ(bool, true) && LIZ(2131364365) != null) {
            SmartImageView LIZ2 = LIZ(2131364365);
            n.LIZIZ(LIZ2, "");
            LIZ2.setVisibility(0);
            QJt LIZ3 = QHW.LIZ(str);
            LIZ3.LJJIIZ = LIZ(2131364365);
            LIZ3.LIZ(LJIIL);
            LIZ3.LIZJ();
        } else if (LIZ(2131364365) != null) {
            SmartImageView LIZ4 = LIZ(2131364365);
            n.LIZIZ(LIZ4, "");
            LIZ4.setVisibility(8);
        }
    }

    /* JADX WARNING: type inference failed for: r0v12, types: [android.view.View$OnClickListener, X.JTS] */
    public final void onViewCreated(View view, Bundle bundle) {
        String str;
        Window window;
        M12.LIZ(view);
        EditProfileBadgeDialog.super.onViewCreated(view, bundle);
        OQg LIZ2 = LIZ(2131370625);
        n.LIZIZ(LIZ2, "");
        LIZ2.setVisibility(8);
        Dialog dialog = getDialog();
        if (!(dialog == null || (window = dialog.getWindow()) == null)) {
            window.setLayout(-1, -1);
            window.setGravity(80);
            window.setBackgroundDrawableResource(2131099659);
        }
        if (LIZ(2131364364) != null) {
            QJt LIZ3 = QHW.LIZ(3EX.LIZ(Drz.LIZ(this.LJII)));
            LIZ3.LJJIIZ = LIZ(2131364364);
            LIZ3.LIZ(LJIIL);
            LIZ3.LIZJ();
        }
        ProfileBadgeStruct profileBadge = this.LJII.getProfileBadge();
        Boolean bool = null;
        if (profileBadge != null) {
            str = profileBadge.getUrl();
        } else {
            str = null;
        }
        ProfileBadgeStruct profileBadge2 = this.LJII.getProfileBadge();
        if (profileBadge2 != null) {
            bool = Boolean.valueOf(profileBadge2.getShouldShow());
        }
        LIZ(str, bool);
        ((RelativeLayout) LIZ(2131364379)).setOnClickListener(new C3309JTg(this));
        LIZ(2131364377).setOnClickListener(new JTS(this));
        LIZIZ().LIZIZ();
        DV0.LIZ(this, LIZIZ(), C3308JTf.LIZ, new JTX(this));
    }

    public final <S extends 5Am> 2cN subscribe(JediViewModel<S> jediViewModel, DUT<S> dut, LsD<? super DVU, ? super S, 2Pr> lsD) {
        M12.LIZ(jediViewModel, dut, lsD);
        return 5wO.LIZ(this, jediViewModel, dut, lsD);
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        M12.LIZ(layoutInflater);
        return 0HH.LIZ(layoutInflater, 2131561300, viewGroup, false);
    }

    public final <S extends 5Am, A> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, DUT<DRZ<A>> dut, LsD<? super DVU, ? super A, 2Pr> lsD) {
        M12.LIZ(jediViewModel, phd, dut, lsD);
        return 5wO.LIZ(this, jediViewModel, phd, dut, lsD);
    }

    public final <S extends 5Am, A, B> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, DUT<Cwt<A, B>> dut, LsE<? super DVU, ? super A, ? super B, 2Pr> lsE) {
        M12.LIZ(jediViewModel, phd, phd2, dut, lsE);
        return 5wO.LIZ(this, jediViewModel, phd, phd2, dut, lsE);
    }

    public final <S extends 5Am, T> 2cN asyncSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends B8T<? extends T>> phd, DUT<DRZ<B8T<T>>> dut, LsD<? super DVU, ? super Throwable, 2Pr> lsD, LsC<? super DVU, 2Pr> lsC, LsD<? super DVU, ? super T, 2Pr> lsD2) {
        M12.LIZ(jediViewModel, phd, dut);
        return 5wO.LIZ(this, jediViewModel, phd, dut, lsD, lsC, lsD2);
    }

    public final <S extends 5Am, A, B, C> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, PHD<S, ? extends C> phd3, DUT<DV9<A, B, C>> dut, LsF<? super DVU, ? super A, ? super B, ? super C, 2Pr> lsF) {
        M12.LIZ(jediViewModel, phd, phd2, phd3, dut, lsF);
        return 5wO.LIZ(this, jediViewModel, phd, phd2, phd3, dut, lsF);
    }

    public final <S extends 5Am, A, B, C, D> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, PHD<S, ? extends C> phd3, PHD<S, ? extends D> phd4, DUT<D4t<A, B, C, D>> dut, Lsh<? super DVU, ? super A, ? super B, ? super C, ? super D, 2Pr> lsh) {
        M12.LIZ(jediViewModel, phd, phd2, phd3, phd4, dut, lsh);
        return 5wO.LIZ(this, jediViewModel, phd, phd2, phd3, phd4, dut, lsh);
    }
}
