package com.ss.android.ugc.aweme.kids.liked.favorite;

import X.069;
import X.1Bn;
import X.AnonymousClass2GO;
import X.AnonymousClass2K7;
import X.AnonymousClass3ZQ;
import X.C03012Pr;
import X.C18812xd;
import X.C204930v;
import X.C219236i;
import X.C227739p;
import X.C227839q;
import X.C228039s;
import X.C30053af;
import X.Cc1;
import X.Lea;
import X.Lel;
import X.LsC;
import X.M12;
import X.OQg;
import X.OQh;
import android.content.Context;
import android.view.View;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
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.Iterator;
import java.util.List;
import kotlin.h.b.n;

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

    static {
        Covode.recordClassIndex(89782);
    }

    public final void LIZIZ() {
    }

    public final boolean LIZJ() {
        return false;
    }

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

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

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

    public static boolean LJIILIIL() {
        try {
            return AnonymousClass2K7.LIZ.LIZJ();
        } catch (Exception unused) {
            return false;
        }
    }

    public final View LJ() {
        MethodCollector.i(14074);
        Context context = getContext();
        if (context != null) {
            View view = new View(context);
            MethodCollector.o(14074);
            return view;
        }
        MethodCollector.o(14074);
        return null;
    }

    public final void LJIIIZ() {
        OQg oQg = this.LJ;
        if (oQg != null) {
            OQh oQh = new OQh();
            C204930v.LIZIZ(oQh, new C228039s(this));
            oQg.setStatus(oQh);
        }
    }

    public final void LJI() {
        OQg oQg = this.LJ;
        if (oQg != null) {
            OQh oQh = new OQh();
            oQh.LIZ(C18812xd.LIZ((LsC<? super AnonymousClass3ZQ, C03012Pr>) C227739p.LIZ));
            String string = getString(2131826459);
            n.LIZIZ(string, "");
            oQh.LIZ(string);
            String string2 = getString(2131826458);
            n.LIZIZ(string2, "");
            oQh.LIZ(string2);
            oQg.setStatus(oQh);
        }
        OQg oQg2 = this.LJ;
        if (oQg2 != null) {
            oQg2.setVisibility(0);
        }
    }

    public final void LJIIL() {
        if (aq_()) {
            getContext();
            if (!LJIILIIL()) {
                C30053af r1 = new C30053af((Fragment) this);
                r1.LJ(2131827476);
                C30053af.LIZ(r1);
                LJIIIZ();
                return;
            }
            LJFF();
        }
    }

    public final void onResume() {
        1Bn<List<Aweme>> r0;
        List list;
        KidsAwemeGridViewModel kidsAwemeGridViewModel;
        1Bn<List<Aweme>> r02;
        FavoriteGridFragment.super.onResume();
        KidsAwemeGridViewModel kidsAwemeGridViewModel2 = this.LIZJ;
        if (!(kidsAwemeGridViewModel2 == null || (r0 = kidsAwemeGridViewModel2.LIZ) == null || (list = (List) r0.getValue()) == null)) {
            List LJII = Lea.LJII(list);
            if (!LJII.isEmpty()) {
                boolean z = false;
                Iterator it = LJII.iterator();
                while (it.hasNext()) {
                    if (!((Aweme) it.next()).isLike()) {
                        it.remove();
                        z = true;
                    }
                }
                if (!(!z || (kidsAwemeGridViewModel = this.LIZJ) == null || (r02 = kidsAwemeGridViewModel.LIZ) == null)) {
                    r02.postValue(LJII);
                }
            }
        }
        getContext();
        if (!LJIILIIL()) {
            C30053af r1 = new C30053af((Fragment) this);
            r1.LJ(2131827476);
            C30053af.LIZ(r1);
        }
    }

    public final void LIZ(View view, Aweme aweme) {
        Object obj;
        1Bn<List<Aweme>> r0;
        if (!Cc1.LIZ(view, 1200)) {
            if (!(aweme == null || getActivity() == null)) {
                getContext();
                if (!LJIILIIL()) {
                    C30053af r1 = new C30053af((Fragment) this);
                    r1.LJ(2131827476);
                    C30053af.LIZ(r1);
                    return;
                }
            }
            KidsAwemeGridViewModel kidsAwemeGridViewModel = this.LIZJ;
            String str = null;
            if (kidsAwemeGridViewModel == null || (r0 = kidsAwemeGridViewModel.LIZ) == null || (obj = r0.getValue()) == null) {
                obj = Lel.INSTANCE;
            }
            M12.LIZ(obj);
            C219236i.LIZ = new WeakReference<>(obj);
            SmartRoute buildRoute = SmartRouter.buildRoute(getActivity(), "//kids/like/feed");
            if (aweme != null) {
                str = aweme.getAid();
            }
            buildRoute.withParam("current_id", str);
            if (view != null) {
                069 LIZIZ = 069.LIZIZ(view, view.getWidth(), view.getHeight());
                n.LIZIZ(LIZIZ, "");
                buildRoute.withBundleAnimation(LIZIZ.LIZ());
            }
            buildRoute.open();
        }
    }
}
