package com.ss.android.ugc.aweme.feed.model;

import X.AdT;
import X.C4326EfC;
import X.EXZ;
import X.M12;
import X.Mk2;
import X.Mk3;
import X.PhE;
import X.PlI;
import android.os.Message;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.feed.api.FollowFeedApi;
import java.util.Iterator;
import java.util.List;
import kotlin.h.b.n;
import kotlin.o.y;

public final class FollowingFeedListModel extends EXZ<Aweme, C4326EfC> {
    public final List<String> blueDotList;
    public int footerNextCursor;
    public String footerUid = "";
    public boolean hasMoreFooter;
    public boolean hasMoreHeader;
    public int headerNextCursor;
    public String headerUid = "";
    public final List<String> uidList;

    static {
        Covode.recordClassIndex(78921);
    }

    public final boolean checkParams(Object... objArr) {
        M12.LIZ(objArr);
        return true;
    }

    public final boolean isHasMore() {
        return this.hasMoreFooter;
    }

    public final List<Aweme> getItems() {
        C4326EfC efC = (C4326EfC) this.mData;
        if (efC != null) {
            return efC.getAwemeList();
        }
        return null;
    }

    public final void loadMoreList(Object... objArr) {
        M12.LIZ(objArr);
        if (this.hasMoreFooter) {
            loadList(this.footerNextCursor, this.footerUid, 2);
        }
    }

    public final void refreshList(Object... objArr) {
        M12.LIZ(objArr);
        String str = objArr[1];
        if (!(str instanceof String)) {
            str = null;
        }
        String str2 = str;
        if (str2 != null) {
            loadList(0, str2, 1);
        }
    }

    public final void loadLatestList(Object... objArr) {
        M12.LIZ(objArr);
        if (!this.hasMoreHeader) {
            Message obtainMessage = this.mHandler.obtainMessage(0);
            n.LIZIZ(obtainMessage, "");
            obtainMessage.obj = new AdT();
            this.mHandler.sendMessage(obtainMessage);
            return;
        }
        loadList(this.headerNextCursor, this.headerUid, 3);
    }

    public FollowingFeedListModel(List<String> list, List<String> list2) {
        M12.LIZ(list, list2);
        this.uidList = list;
        this.blueDotList = list2;
    }

    private final void loadList(int i, String str, int i2) {
        int i3;
        String str2;
        boolean z;
        int i4 = i2;
        if (i4 != 3) {
            i3 = 2;
        } else {
            i3 = 1;
        }
        Iterator<String> it = this.uidList.iterator();
        int i5 = 0;
        while (true) {
            str2 = str;
            if (!it.hasNext()) {
                i5 = -1;
                break;
            } else if (y.LIZ(it.next(), str2, true)) {
                break;
            } else {
                i5++;
            }
        }
        if (i5 >= this.blueDotList.size() || !y.LIZ(this.blueDotList.get(i5), "true", true)) {
            z = false;
        } else {
            z = true;
        }
        int i6 = i;
        FollowFeedApi.LIZ.LIZ().getFollowingInterestFeed(i6, 8, str2, i3, 2, z).LIZIZ(PhE.LIZIZ(PlI.LIZJ)).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZ(new FollowingFeedListModel$loadList$1(this, i4, str2, z, i6), new FollowingFeedListModel$loadList$2(this));
    }
}
