package com.ss.android.ugc.aweme.view.editor;

import X.5vY;
import X.C2936JEx;
import X.C2941JFc;
import X.C2942JFd;
import X.C2950JFl;
import X.C2964JFz;
import X.C2967JGc;
import X.C2973JGi;
import X.C2974JGj;
import X.JEJ;
import X.JFH;
import X.JFQ;
import X.JG1;
import X.JG2;
import X.JG9;
import X.JGJ;
import X.JGS;
import X.JGZ;
import X.M12;
import android.util.SparseArray;
import android.view.View;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.viewModel.ProfileNaviEditorViewModel;
import kotlin.h.b.n;

public final class ProfileNaviEditorCategoryFragment extends ProfileNaviViewPagerFragment implements 5vY, JGS {
    public static final C2974JGj LIZIZ = new C2974JGj((byte) 0);
    public JGZ LIZ;
    public SparseArray LIZJ;

    static {
        Covode.recordClassIndex(123360);
    }

    public final int LIZ() {
        return 2131560850;
    }

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

    public final void LIZJ() {
        SparseArray sparseArray = this.LIZJ;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

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

    public final void LIZIZ() {
        RecyclerView LIZ2;
        if (this.LIZ != null) {
            RecyclerView LIZ3 = LIZ(2131368915);
            if (LIZ3 != null) {
                getContext();
                LIZ3.setLayoutManager(new LinearLayoutManager(1, false));
            }
            LIZLLL();
            C2936JEx jEx = JEJ.LIZ;
            if (jEx != null && (LIZ2 = LIZ(2131368915)) != null) {
                JGZ jgz = this.LIZ;
                if (jgz == null) {
                    n.LIZIZ();
                }
                LIZ2.setAdapter(new C2942JFd(jEx, jgz, this));
            }
        }
    }

    public final void LIZ(JFQ jfq) {
        String str;
        M12.LIZ(jfq);
        C2950JFl jFl = C2950JFl.LIZIZ;
        JGZ jgz = this.LIZ;
        if (jgz != null) {
            str = jgz.LIZ();
        } else {
            str = null;
        }
        jFl.LIZ(str, jfq.LIZ());
        LIZLLL().LIZJ(jfq);
    }

    public final void LIZIZ(JFQ jfq) {
        String str;
        M12.LIZ(jfq);
        C2950JFl jFl = C2950JFl.LIZIZ;
        JGZ jgz = this.LIZ;
        if (jgz != null) {
            str = jgz.LIZ();
        } else {
            str = null;
        }
        jFl.LIZIZ(str, jfq.LIZ());
        LIZLLL().LIZLLL(jfq);
    }

    public final void LIZ(C2973JGi jGi) {
        String str;
        C2941JFc jFc;
        M12.LIZ(jGi);
        C2950JFl jFl = C2950JFl.LIZIZ;
        String LIZ2 = jGi.LIZ();
        JGZ jgz = this.LIZ;
        String str2 = null;
        if (jgz != null) {
            str = jgz.LIZ();
        } else {
            str = null;
        }
        String LIZ3 = jGi.LIZJ().LIZ();
        JFH LJIIIZ = jGi.LIZJ().LJIIIZ();
        if (!(LJIIIZ == null || (jFc = LJIIIZ.LIZIZ) == null)) {
            str2 = jFc.LIZJ;
        }
        jFl.LIZ(LIZ2, str, LIZ3, str2);
        ProfileNaviEditorViewModel LIZLLL = LIZLLL();
        M12.LIZ(jGi);
        if (jGi instanceof C2967JGc) {
            C2967JGc LIZIZ2 = LIZLLL.LIZIZ(jGi.LIZJ());
            if (LIZIZ2 == null || (!n.LIZ(LIZIZ2.LIZ(), jGi.LIZ()))) {
                C2967JGc jGc = (C2967JGc) jGi;
                C2967JGc LIZIZ3 = LIZLLL.LIZIZ(jGc.LIZJ());
                if (LIZIZ3 == null || !n.LIZ(LIZIZ3.LIZ(), jGc.LIZ())) {
                    String LIZ4 = LIZLLL.LIZ(jGc.LIZJ());
                    C2936JEx jEx = JEJ.LIZ;
                    if (jEx != null) {
                        M12.LIZ(LIZ4);
                        jEx.LIZJ.put(LIZ4, jGc);
                    }
                    if (LIZIZ3 != null) {
                        LIZLLL.LIZLLL(new JG1(LIZIZ3));
                    }
                    LIZLLL.LIZ(jGc);
                }
                LIZLLL.LIZJ(JGJ.LIZ);
            }
        } else if (jGi instanceof JG9) {
            C2936JEx jEx2 = JEJ.LIZ;
            if (jEx2 != null) {
                String LIZ5 = jGi.LIZJ().LIZ();
                M12.LIZ(LIZ5, jGi);
                jEx2.LIZLLL.put(LIZ5, jGi);
            }
            LIZLLL.LIZJ(new C2964JFz(jGi));
        }
    }

    public final void LIZ(JFQ jfq, C2941JFc jFc) {
        String str;
        M12.LIZ(jfq, jFc);
        C2950JFl jFl = C2950JFl.LIZIZ;
        C2967JGc LIZIZ2 = LIZLLL().LIZIZ(jfq);
        String str2 = null;
        if (LIZIZ2 != null) {
            str = LIZIZ2.LIZ();
        } else {
            str = null;
        }
        JGZ jgz = this.LIZ;
        if (jgz != null) {
            str2 = jgz.LIZ();
        }
        jFl.LIZ(str, str2, jfq.LIZ(), jFc.LIZJ);
        ProfileNaviEditorViewModel LIZLLL = LIZLLL();
        M12.LIZ(jfq, jFc);
        if (jFc.LIZJ != null && jfq.LJIIIZ() != null) {
            JFH LJIIIZ = jfq.LJIIIZ();
            if (LJIIIZ == null) {
                n.LIZIZ();
            }
            LJIIIZ.LIZIZ = jFc;
            LIZLLL.LIZLLL(new JG2(jFc));
        }
    }

    public final void LIZ(C2973JGi jGi, int i) {
        M12.LIZ(jGi);
        if (i == 2) {
            LIZIZ(jGi.LIZJ());
        } else if (i == 1) {
            LIZ(jGi.LIZJ());
        }
    }
}
