package com.ss.android.ugc.aweme.kids.profile;

import X.0Br;
import X.0HH;
import X.2GO;
import X.2HZ;
import X.2aZ;
import X.2nP;
import X.2uR;
import X.3Dq;
import X.3SC;
import X.3af;
import X.3c7;
import X.3cA;
import X.3cC;
import X.3cI;
import X.4UM;
import X.4UP;
import X.4r1;
import X.6oU;
import X.73i;
import X.7he;
import X.C0295Crj;
import X.C0746D8s;
import X.C0782DAc;
import X.C3953EYb;
import X.C3955EYd;
import X.C3956EYe;
import X.C3958EYg;
import X.DAU;
import X.DE9;
import X.ESN;
import X.EYB;
import X.EYI;
import X.EYK;
import X.EYP;
import X.EYW;
import X.EYX;
import X.EYY;
import X.EYZ;
import X.ISm;
import X.Ls0;
import X.M12;
import X.Rc9;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import androidx.lifecycle.LiveData;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.kids.profile.base.BaseFragment;
import com.ss.android.ugc.aweme.kids.profile.utils.MyProfileReportWidget;
import com.ss.android.ugc.aweme.kids.profile.viewmodel.KidsProfileViewModel;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import kotlin.h.b.n;
import org.greenrobot.eventbus.ThreadMode;

public final class MyProfileFragment extends BaseFragment implements 2HZ, 2GO {
    public static final C3958EYg LIZJ = new C3958EYg((byte) 0);
    public final C0295Crj LIZ = 7he.LIZ(C3955EYd.LIZ);
    public final C0295Crj LIZIZ = 7he.LIZ(new EYW(this));
    public final C0295Crj LJ = 7he.LIZ(new C3956EYe(this));
    public final C0295Crj LJIIIZ = 7he.LIZ(new EYX(this));
    public final C0295Crj LJIIJ = 7he.LIZ(new C3953EYb(this));
    public HashMap LJIIJJI;

    static {
        Covode.recordClassIndex(89796);
    }

    private final KidsProfileViewModel LIZJ() {
        return (KidsProfileViewModel) this.LJIIJ.getValue();
    }

    public final EYB LIZ() {
        return (EYB) this.LJIIIZ.getValue();
    }

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

    public final void LIZIZ() {
        HashMap hashMap = this.LJIIJJI;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    public final boolean LJJIJIIJI() {
        return true;
    }

    public final Map<Integer, Object> getSubscriberEventTypes() {
        HashMap hashMap = new HashMap();
        hashMap.put(257, new Rc9(MyProfileFragment.class, "onDeleteDraftItemEvent", 73i.class, ThreadMode.MAIN, 0, false));
        hashMap.put(258, new Rc9(MyProfileFragment.class, "onVideoCreatedOrSaved", 6oU.class, ThreadMode.MAIN, 0, true));
        return hashMap;
    }

    public final /* synthetic */ void onDestroyView() {
        super.onDestroyView();
        LIZIZ();
    }

    public final void onStart() {
        MyProfileFragment.super.onStart();
        KidsProfileViewModel LIZJ2 = LIZJ();
        LIZJ2.LIZ = C0782DAc.LIZ(3SC.LIZ, (C0746D8s) null, (DAU) null, new DE9(LIZJ2, (4r1) null), 3);
    }

    public final void onHiddenChanged(boolean z) {
        MyProfileFragment.super.onHiddenChanged(z);
        LinearLayout linearLayout = (LinearLayout) LIZ(2131368036);
        n.LIZIZ(linearLayout, "");
        if (linearLayout.getVisibility() == 0 && !z) {
            2nP r3 = 2nP.LIZ;
            2aZ r2 = new 2aZ();
            r2.LIZ("enter_from", "personal_homepage");
            r3.LIZ("shoot_bubble_show", r2.LIZ());
        }
    }

    @ISm(LIZ = ThreadMode.MAIN)
    public final void onDeleteDraftItemEvent(73i r6) {
        M12.LIZ(r6);
        Object value = LIZJ().LIZJ.getValue();
        Objects.requireNonNull(value, "null cannot be cast to non-null type kotlin.collections.MutableList<com.ss.android.ugc.aweme.kids.profile.ProfileVideoData>");
        List LIZLLL = Ls0.LIZLLL(value);
        Iterator it = LIZLLL.iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            EYP eyp = (EYP) it.next();
            if ((eyp instanceof EYI) && n.LIZ(r6.LIZ.LJFF().getCreationId(), ((EYI) eyp).LIZ.LJFF().getCreationId())) {
                it.remove();
                break;
            }
        }
        LIZJ().LIZJ.setValue(LIZLLL);
        LIZJ().LIZLLL.setValue(Integer.valueOf(LIZLLL.size() - 1));
        LIZ().notifyDataSetChanged();
    }

    @ISm(LIZ = ThreadMode.MAIN, LIZIZ = true)
    public final void onVideoCreatedOrSaved(6oU r5) {
        M12.LIZ(r5);
        if (r5.LIZ == 1) {
            3af r1 = new 3af(this);
            r1.LIZ();
            r1.LJ(2131826485);
            r1.LIZIZ(2131755697);
            r1.LIZLLL(2130968646);
            3af.LIZ(r1);
        } else if (r5.LIZ == 2) {
            3af r12 = new 3af(this);
            r12.LIZ();
            r12.LJ(2131826478);
            r12.LIZIZ(2131755697);
            r12.LIZLLL(2130968646);
            3af.LIZ(r12);
        }
    }

    public final void onViewCreated(View view, Bundle bundle) {
        String str;
        M12.LIZ(view);
        MyProfileFragment.super.onViewCreated(view, bundle);
        RecyclerView LIZ2 = LIZ(2131369772);
        LIZ2.setAdapter(LIZ());
        LIZ2.setLayoutManager((GridLayoutManager) this.LJ.getValue());
        Resources system = Resources.getSystem();
        n.LIZIZ(system, "");
        LIZ2.LIZ(new 3Dq((int) (system.getDisplayMetrics().density * 2.0f)));
        3c7 LIZ3 = LIZ(2131368895);
        2uR r6 = new 2uR();
        3cC r2 = new 3cC();
        Context context = getContext();
        if (context == null || (str = context.getString(2131826481)) == null) {
            str = "";
        }
        n.LIZIZ(str, "");
        r2.LIZ(str);
        r6.LIZ(r2);
        3cA r1 = new 3cA();
        r1.LIZ(2131755380);
        r1.LIZIZ = true;
        r1.LIZ(new 4UP(this));
        r6.LIZIZ(new 3cI[]{r1});
        r6.LIZLLL = true;
        LIZ3.setNavActions(r6);
        LiveData LIZ4 = 0Br.LIZ(LIZJ().LIZIZ, EYK.LIZ);
        n.LIZIZ(LIZ4, "");
        LIZ4.observe(getViewLifecycleOwner(), new 4UM(this));
        LIZJ().LIZLLL.observe(getViewLifecycleOwner(), new EYY(this));
        LIZJ().LIZJ.observe(getViewLifecycleOwner(), new EYZ(this));
        if (this.LIZLLL == null && getView() != null) {
            this.LIZLLL = ESN.LJI.LIZ(this, getView());
        }
        ESN esn = this.LIZLLL;
        if (esn != null) {
            esn.LIZ(new MyProfileReportWidget((ViewGroup) view));
        }
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        M12.LIZ(layoutInflater);
        this.LIZLLL = null;
        return 0HH.LIZ(layoutInflater, 2131560297, viewGroup, false);
    }
}
