package com.ss.android.ugc.aweme.kids.discovery.gallery;

import X.0HH;
import X.1Bn;
import X.AnonymousClass2GO;
import X.AnonymousClass2aZ;
import X.AnonymousClass3A7;
import X.C12472nP;
import X.C228139t;
import X.JIn;
import X.Lel;
import X.M12;
import X.Pc3;
import X.PcA;
import X.QHW;
import X.QJt;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.bytedance.covode.number.Covode;
import com.bytedance.router.SmartRoute;
import com.bytedance.router.SmartRouter;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.kids.common.ui.awemegrid.KidsAwemeGridFragment;
import com.ss.android.ugc.aweme.kids.common.ui.awemegrid.KidsAwemeGridViewModel;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;

public final class GalleryGridFragment extends KidsAwemeGridFragment implements AnonymousClass2GO {
    public static final C228139t LJIIIZ = new C228139t((byte) 0);
    public HashMap LJIIJ;

    static {
        Covode.recordClassIndex(89649);
    }

    public final String LIZLLL() {
        return "gallery";
    }

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

    public final boolean LIZJ() {
        Object LIZ = Pc3.LIZ.LIZ(new PcA());
        Objects.requireNonNull(LIZ, "null cannot be cast to non-null type kotlin.Int");
        if (((Integer) LIZ).intValue() == 1) {
            return true;
        }
        return false;
    }

    public final void LIZIZ() {
        String str;
        C12472nP r3 = C12472nP.LIZ;
        AnonymousClass2aZ r2 = new AnonymousClass2aZ();
        Bundle arguments = getArguments();
        if (arguments == null || (str = arguments.getString("challenge_id")) == null) {
            str = "";
        }
        r2.LIZ("category_id", str);
        r3.LIZ("end_feed_category_details_page", r2.LIZ());
    }

    public final View LJ() {
        if (getContext() == null) {
            return null;
        }
        View LIZ = 0HH.LIZ(LayoutInflater.from(getContext()), 2131560249, (ViewGroup) null, false);
        QJt LIZ2 = QHW.LIZ("https://p16-amd-va.tiktokcdn.com/obj/tiktok-obj/empty_footer.png");
        LIZ2.LJIJJLI = JIn.FIT_CENTER;
        LIZ2.LJJIIZI = (ImageView) LIZ.findViewById(2131366741);
        LIZ2.LIZJ();
        return LIZ;
    }

    public final void onDestroyView() {
        String str;
        C12472nP r3 = C12472nP.LIZ;
        AnonymousClass2aZ r2 = new AnonymousClass2aZ();
        Bundle arguments = getArguments();
        if (arguments == null || (str = arguments.getString("challenge_id")) == null) {
            str = "";
        }
        r2.LIZ("category_id", str);
        r3.LIZ("exit_category_details_page", r2.LIZ());
        super.onDestroyView();
        LJIIJJI();
    }

    public final void onCreate(Bundle bundle) {
        String str;
        String string;
        super.onCreate(bundle);
        C12472nP r4 = C12472nP.LIZ;
        AnonymousClass2aZ r3 = new AnonymousClass2aZ();
        r3.LIZ("enter_from", "discovery");
        Bundle arguments = getArguments();
        String str2 = "";
        if (arguments == null || (str = arguments.getString("mob_enter_from")) == null) {
            str = str2;
        }
        r3.LIZ("enter_method", str);
        Bundle arguments2 = getArguments();
        if (!(arguments2 == null || (string = arguments2.getString("challenge_id")) == null)) {
            str2 = string;
        }
        r3.LIZ("category_id", str2);
        r4.LIZ("show_category_details_page", r3.LIZ());
    }

    public final void LIZ(View view, Aweme aweme) {
        Context context;
        Object obj;
        1Bn<List<Aweme>> r0;
        if (aweme != null && (context = getContext()) != null) {
            KidsAwemeGridViewModel kidsAwemeGridViewModel = this.LIZJ;
            if (kidsAwemeGridViewModel == null || (r0 = kidsAwemeGridViewModel.LIZ) == null || (obj = r0.getValue()) == null) {
                obj = Lel.INSTANCE;
            }
            M12.LIZ(obj);
            AnonymousClass3A7.LIZ = new WeakReference<>(obj);
            SmartRoute buildRoute = SmartRouter.buildRoute(context, "//kids/discovery/feed");
            String aid = aweme.getAid();
            aid.toString();
            buildRoute.withParam("current_id", aid);
            buildRoute.withParam("enter_from", "category_details_page");
            buildRoute.withParam("preload_from_cache", true);
            buildRoute.withParam(getArguments());
            buildRoute.open();
        }
    }
}
