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

import X.0EF;
import X.0HH;
import X.878;
import X.C3491BMh;
import X.C3561BOz;
import X.C3592BQe;
import X.C3816BYu;
import X.C3896Bam;
import X.C3899Bap;
import X.C3900Baq;
import X.C3901Bar;
import X.C3902Bas;
import X.C3903Bat;
import X.C3904Bau;
import X.C3905Bav;
import X.C3922BbC;
import X.C5601C5l;
import X.C5602C5m;
import X.C6521Cc1;
import X.HeD;
import X.K0c;
import X.KGj;
import X.M12;
import X.OQg;
import X.OQh;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.bytedance.router.SmartRoute;
import com.bytedance.router.SmartRouter;
import com.ss.android.ugc.aweme.base.fragment.AmeBaseFragment;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.feed.model.AwemeRawAd;
import com.ss.android.ugc.aweme.views.WrapGridLayoutManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import kotlin.h.b.n;

public final class AdFakeUserProfileAwemeListFragment extends AmeBaseFragment implements C3491BMh, C3922BbC<Aweme>, C3561BOz, C5602C5m {
    public static final C3902Bas LJ = new C3902Bas((byte) 0);
    public RecyclerView LIZ;
    public 0EF LIZIZ;
    public AwemeRawAd LIZJ;
    public long LIZLLL;
    public OQg LJIIIZ;
    public C3903Bat LJIIJ;
    public String LJIIJJI = "";
    public String LJIIL = "";
    public String LJIILIIL = "";
    public String LJIILJJIL = "";
    public boolean LJIILL;
    public C3905Bav LJIIZILJ;
    public final List<String> LJIJ = new ArrayList();
    public final Map<String, Boolean> LJIJI = new HashMap();
    public boolean LJIJJ;
    public HashMap LJIJJLI;

    static {
        Covode.recordClassIndex(59392);
    }

    public final void LIZ(Exception exc) {
    }

    public final void LIZ(List<Aweme> list, boolean z) {
    }

    public final void LIZ(boolean z) {
    }

    public final void LIZJ(List<Aweme> list, boolean z) {
    }

    public final void cn_() {
    }

    public final boolean LJII() {
        return this.LJIILL;
    }

    public final void bN_() {
        LIZ();
    }

    private final boolean LIZJ() {
        C3905Bav bav = this.LJIIZILJ;
        if (bav == null || bav.getItemCount() != 0) {
            return false;
        }
        return true;
    }

    public final void LIZIZ() {
        if (LIZJ()) {
            LIZLLL();
        }
    }

    public final void LJFF() {
        if (aq_()) {
            LJIIIZ();
        }
    }

    public final /* synthetic */ void onDestroyView() {
        super.onDestroyView();
        HashMap hashMap = this.LJIJJLI;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    private final void LJIIJ() {
        this.LJIJJ = false;
        OQg oQg = this.LJIIIZ;
        if (oQg == null) {
            n.LIZ("");
        }
        oQg.setVisibility(8);
    }

    public final View LJIIJJI() {
        if (!aq_()) {
            return null;
        }
        RecyclerView recyclerView = this.LIZ;
        if (recyclerView == null) {
            n.LIZ("");
        }
        return recyclerView;
    }

    /* JADX WARNING: type inference failed for: r0v2, types: [X.C5d, X.Bav] */
    public final void bw_() {
        if (aq_()) {
            if (LIZJ()) {
                LIZLLL();
            }
            ? r0 = this.LJIIZILJ;
            if (r0 != 0) {
                r0.showLoadMoreLoading();
            }
        }
    }

    private final void LIZLLL() {
        OQg oQg = this.LJIIIZ;
        if (oQg == null) {
            n.LIZ("");
        }
        oQg.setVisibility(0);
        OQg oQg2 = this.LJIIIZ;
        if (oQg2 == null) {
            n.LIZ("");
        }
        oQg2.LIZ();
        OQg oQg3 = this.LJIIIZ;
        if (oQg3 == null) {
            n.LIZ("");
        }
        oQg3.setOnClickListener((View.OnClickListener) null);
        this.LJIJJ = true;
    }

    private final void LJIIIZ() {
        OQg oQg = this.LJIIIZ;
        if (oQg == null) {
            n.LIZ("");
        }
        oQg.setVisibility(0);
        OQg oQg2 = this.LJIIIZ;
        if (oQg2 == null) {
            n.LIZ("");
        }
        OQh oQh = new OQh();
        String string = getString(2131826714);
        n.LIZIZ(string, "");
        oQh.LIZ(string);
        oQg2.setStatus(oQh);
        OQg oQg3 = this.LJIIIZ;
        if (oQg3 == null) {
            n.LIZ("");
        }
        oQg3.setOnClickListener(new C3901Bar(this));
        this.LJIJJ = false;
    }

    /* JADX WARNING: type inference failed for: r5v0, types: [X.B9I, X.Bav] */
    /* JADX WARNING: type inference failed for: r4v0, types: [X.Bat, X.BbA] */
    public final void LIZ() {
        ? r5 = this.LJIIZILJ;
        if (r5 != 0) {
            ? r4 = this.LJIIJ;
            if (r4 == 0) {
                n.LIZ("");
            }
            Object[] objArr = new Object[8];
            objArr[0] = this.LJIIL;
            int i = 1;
            objArr[1] = this.LJIILIIL;
            objArr[2] = Long.valueOf(this.LIZLLL);
            objArr[3] = 0L;
            objArr[4] = 6;
            List<T> list = r5.mItems;
            if (!(list == null || list.size() == 0)) {
                i = 4;
            }
            objArr[5] = Integer.valueOf(i);
            objArr[6] = this.LJIILJJIL;
            objArr[7] = this.LJIIJJI;
            r4.LIZ(objArr);
        }
    }

    /* JADX WARNING: type inference failed for: r0v2, types: [X.C5d, X.Bav] */
    public final void LIZJ(Exception exc) {
        if (aq_()) {
            C3905Bav bav = this.LJIIZILJ;
            if (bav != null && bav.getItemCount() == 0) {
                LJIIJ();
            }
            ? r0 = this.LJIIZILJ;
            if (r0 != 0) {
                r0.showPullUpLoadMore();
            }
        }
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [X.B9I, X.Bav] */
    /* JADX WARNING: type inference failed for: r0v2, types: [X.B9I, X.Bav] */
    public final void setUserVisibleHint(boolean z) {
        ? r0;
        List<T> list;
        AdFakeUserProfileAwemeListFragment.super.setUserVisibleHint(z);
        if (z) {
            ? r02 = this.LJIIZILJ;
            if (r02 == 0 || r02.mItems == null || !((r0 = this.LJIIZILJ) == 0 || (list = r0.mItems) == null || list.size() != 0)) {
                LIZ();
            }
        }
    }

    /* JADX WARNING: type inference failed for: r0v1, types: [X.B9I, X.Bav] */
    /* JADX WARNING: type inference failed for: r0v5, types: [X.B9I, X.Bav] */
    public final void LIZIZ(Exception exc) {
        List list;
        ? r0;
        if (aq_()) {
            LJIIIZ();
            ? r02 = this.LJIIZILJ;
            if (r02 != 0) {
                list = r02.getData();
            } else {
                list = null;
            }
            if (!878.LIZ(list) && (r0 = this.LJIIZILJ) != 0) {
                r0.clearData();
            }
        }
    }

    /* JADX WARNING: type inference failed for: r0v8, types: [X.B9I, X.Bav] */
    /* JADX WARNING: type inference failed for: r0v11, types: [X.B9I, X.Bav] */
    public final void LIZIZ(boolean z) {
        int i;
        ? r0;
        List<T> list;
        Aweme aweme;
        List<T> list2;
        0EF r1 = this.LIZIZ;
        if (r1 == null) {
            n.LIZ("");
        }
        if (!(r1 instanceof WrapGridLayoutManager)) {
            r1 = null;
        }
        LinearLayoutManager linearLayoutManager = (LinearLayoutManager) r1;
        if (linearLayoutManager != null) {
            int LJIIJ2 = linearLayoutManager.LJIIJ();
            int LJIIL2 = linearLayoutManager.LJIIL();
            this.LJIJ.clear();
            if (z && LJIIL2 >= 5) {
                LJIIL2 = 5;
            }
            int i2 = LJIIL2 + 1;
            while (LJIIJ2 < i2) {
                ? r02 = this.LJIIZILJ;
                if (r02 == 0 || (list2 = r02.mItems) == null) {
                    i = 0;
                } else {
                    i = list2.size();
                }
                if (LJIIJ2 < i && (r0 = this.LJIIZILJ) != 0 && (list = r0.mItems) != null && (aweme = list.get(LJIIJ2)) != null) {
                    String aid = aweme.getAid();
                    Boolean bool = this.LJIJI.get(aid);
                    if (bool == null || !bool.booleanValue()) {
                        KGj LIZ2 = K0c.LIZ("homepage_ad", "othershow", this.LIZJ);
                        LIZ2.LIZIZ("refer", "video_cover");
                        LIZ2.LIZ("item_id", aweme.getAid());
                        LIZ2.LIZIZ();
                    }
                    Map<String, Boolean> map = this.LJIJI;
                    n.LIZIZ(aid, "");
                    map.put(aid, true);
                    this.LJIJ.add(aid);
                    LJIIJ2++;
                } else {
                    return;
                }
            }
            for (String next : this.LJIJI.keySet()) {
                if (!this.LJIJ.contains(next)) {
                    this.LJIJI.put(next, false);
                }
            }
        }
    }

    /* JADX WARNING: type inference failed for: r0v1, types: [X.C5d, X.Bav] */
    /* JADX WARNING: type inference failed for: r1v0, types: [X.Bat, X.BbA] */
    /* JADX WARNING: type inference failed for: r0v3, types: [X.B9I, X.Bav] */
    public final void LIZIZ(List<Aweme> list, boolean z) {
        if (aq_()) {
            ? r0 = this.LJIIZILJ;
            if (r0 != 0) {
                r0.resetLoadMoreState();
            }
            ? r1 = this.LJIIJ;
            if (r1 == 0) {
                n.LIZ("");
            }
            C3896Bam bam = r1.LJII;
            Objects.requireNonNull(bam, "null cannot be cast to non-null type com.ss.android.ugc.aweme.commercialize.profile.FakeUserAwemeModel");
            bam.LIZ();
            ? r02 = this.LJIIZILJ;
            if (r02 != 0) {
                r02.setData(list);
            }
            this.LJIILL = z;
            C3905Bav bav = this.LJIIZILJ;
            if (bav != null && bav.getBasicItemCount() == 0 && !z && this.LJIJJ) {
                LJIIJ();
            } else if (878.LIZ(list) && z) {
                LIZ();
            } else if (!878.LIZ(list)) {
                LJIIJ();
            }
        }
    }

    /* JADX WARNING: type inference failed for: r1v12, types: [X.Bat, X.BbA] */
    /* JADX WARNING: type inference failed for: r1v13, types: [X.Bam, X.Bb8] */
    /* JADX WARNING: type inference failed for: r0v22, types: [X.Bat, X.BbA] */
    public final void onViewCreated(View view, Bundle bundle) {
        String str;
        String str2;
        String str3;
        String str4;
        M12.LIZ(view);
        super.onViewCreated(view, bundle);
        RecyclerView findViewById = view.findViewById(2131364714);
        n.LIZIZ(findViewById, "");
        RecyclerView recyclerView = findViewById;
        this.LIZ = recyclerView;
        if (recyclerView == null) {
            n.LIZ("");
        }
        RecyclerView recyclerView2 = this.LIZ;
        if (recyclerView2 == null) {
            n.LIZ("");
        }
        recyclerView.setOnFlingListener(new C5601C5l(recyclerView2, this));
        OQg findViewById2 = view.findViewById(2131364724);
        n.LIZIZ(findViewById2, "");
        this.LJIIIZ = findViewById2;
        Bundle arguments = getArguments();
        if (arguments == null || (str = arguments.getString("user_id")) == null) {
            str = "";
        }
        this.LJIIL = str;
        Bundle arguments2 = getArguments();
        if (arguments2 == null || (str2 = arguments2.getString("sec_user_id")) == null) {
            str2 = "";
        }
        this.LJIILIIL = str2;
        Bundle arguments3 = getArguments();
        if (arguments3 == null || (str3 = arguments3.getString("aweme_id")) == null) {
            str3 = "";
        }
        this.LJIIJJI = str3;
        Bundle arguments4 = getArguments();
        if (arguments4 == null || (str4 = arguments4.getString("adv_id")) == null) {
            str4 = "";
        }
        this.LJIILJJIL = str4;
        RecyclerView recyclerView3 = this.LIZ;
        if (recyclerView3 == null) {
            n.LIZ("");
        }
        recyclerView3.setOverScrollMode(2);
        getActivity();
        this.LIZIZ = new WrapGridLayoutManager(2, 1, false);
        RecyclerView recyclerView4 = this.LIZ;
        if (recyclerView4 == null) {
            n.LIZ("");
        }
        0EF r0 = this.LIZIZ;
        if (r0 == null) {
            n.LIZ("");
        }
        recyclerView4.setLayoutManager(r0);
        RecyclerView recyclerView5 = this.LIZ;
        if (recyclerView5 == null) {
            n.LIZ("");
        }
        recyclerView5.LIZ(new C3904Bau(2, (int) HeD.LIZIZ(getContext(), 1.0f)));
        RecyclerView recyclerView6 = this.LIZ;
        if (recyclerView6 == null) {
            n.LIZ("");
        }
        recyclerView6.LIZ(new C3592BQe());
        C3905Bav bav = new C3905Bav(this);
        this.LJIIZILJ = bav;
        String str5 = this.LJIIJJI;
        M12.LIZ(str5);
        bav.LIZLLL = str5;
        RecyclerView recyclerView7 = this.LIZ;
        if (recyclerView7 == null) {
            n.LIZ("");
        }
        recyclerView7.setAdapter(this.LJIIZILJ);
        RecyclerView recyclerView8 = this.LIZ;
        if (recyclerView8 == null) {
            n.LIZ("");
        }
        recyclerView8.getViewTreeObserver().addOnGlobalLayoutListener(new C3899Bap(this));
        ? bat = new C3903Bat();
        this.LJIIJ = bat;
        bat.a_(this);
        ? bam = new C3896Bam();
        ? r02 = this.LJIIJ;
        if (r02 == 0) {
            n.LIZ("");
        }
        r02.LIZ(bam);
        C3900Baq baq = new C3900Baq(this);
        RecyclerView recyclerView9 = this.LIZ;
        if (recyclerView9 == null) {
            n.LIZ("");
        }
        recyclerView9.LIZ(baq);
    }

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

    /* JADX WARNING: type inference failed for: r1v0, types: [X.Bat, X.BbA] */
    public final void LIZ(View view, Aweme aweme, String str) {
        if (!C6521Cc1.LIZ(view, 1200) && aweme != null && getActivity() != null) {
            ? r1 = this.LJIIJ;
            if (r1 == 0) {
                n.LIZ("");
            }
            C3816BYu.LIZ = r1.LJII;
            Bundle bundle = new Bundle();
            bundle.putString("id", aweme.getAid());
            bundle.putString("userid", this.LJIIL);
            bundle.putString("sec_userid", this.LJIILIIL);
            bundle.putString("refer", "new_ad_fake_user");
            bundle.putString("video_from", "from_ad_new_fake_user");
            bundle.putString("feed_ad_aweme_id", this.LJIIJJI);
            bundle.putString("feed_adv_id", this.LJIILJJIL);
            bundle.putLong("max_cursor", this.LIZLLL);
            SmartRoute buildRoute = SmartRouter.buildRoute(getActivity(), "aweme://aweme/detail/");
            buildRoute.withParam(bundle);
            buildRoute.open();
            KGj LIZ2 = K0c.LIZ("homepage_ad", "otherclick", this.LIZJ);
            LIZ2.LIZIZ("refer", "video_cover");
            LIZ2.LIZ("item_id", aweme.getAid());
            LIZ2.LIZIZ();
        }
    }
}
