package com.bytedance.android.livesdk.live.data;

import X.0bm;
import X.0bn;
import X.0yx;
import X.1c5;
import X.2sG;
import X.C3482Gt1;
import X.C3483Gt2;
import X.C3485Gt4;
import X.C3521Gte;
import X.C3522Gtf;
import X.C3525Gti;
import X.C3807GyG;
import X.M12;
import X.PgU;
import android.util.Pair;
import com.bytedance.android.live.base.model.feed.FeedExtra;
import com.bytedance.android.live.base.model.user.User;
import com.bytedance.android.live.core.feed.FeedApi;
import com.bytedance.android.livesdk.chatroom.detail.RoomApi;
import com.bytedance.android.livesdk.model.FeedItem;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.covode.number.Covode;
import java.util.List;
import java.util.Objects;
import kotlin.h.b.n;

public final class DrawRoomListModel {
    static {
        Covode.recordClassIndex(17557);
    }

    private final String getObjectsStr(List<? extends Object> list) {
        if (list == null || list.isEmpty()) {
            return "";
        }
        StringBuilder sb = new StringBuilder();
        int size = list.size();
        for (int i = 0; i < size; i++) {
            sb.append(list.get(i).toString());
            if (i < list.size() - 1) {
                sb.append(",");
            }
        }
        String sb2 = sb.toString();
        n.LIZIZ(sb2, "");
        return sb2;
    }

    public final void handleRoomParams(FeedItem feedItem) {
        if ((feedItem.type == 1 || feedItem.type == 2) && (feedItem.item instanceof Room)) {
            C3807GyG gyG = feedItem.item;
            Objects.requireNonNull(gyG, "null cannot be cast to non-null type com.bytedance.android.livesdkapi.depend.model.live.Room");
            Room room = (Room) gyG;
            room.setLog_pb(feedItem.logPb);
            User owner = room.getOwner();
            if (owner != null) {
                owner.setLogPb(feedItem.logPb);
            }
            room.setRequestId(feedItem.resId);
            room.isFromRecommendCard = feedItem.isRecommendCard;
        }
    }

    public final PgU<1c5<Object>> collectUnreadRequest(long j, long j2, String str, List<Long> list) {
        String str2 = str;
        M12.LIZ(str2, list);
        return ((RoomApi) 0yx.LIZ().LIZ(RoomApi.class)).collectUnreadRequest(j, j2, str2, getObjectsStr(list));
    }

    public final PgU<C3525Gti<Pair<List<FeedItem>, FeedExtra>>> getRoomList(long j, String str, String str2, long j2, long j3, String str3) {
        PgU feed;
        String str4 = str;
        String str5 = str2;
        String str6 = str3;
        M12.LIZ(str4, str5, str6);
        String LIZ = C3482Gt1.LIZ(C3482Gt1.LJIIIZ.LIZ(), (Long) null, false, 3, (Object) null);
        Long l = C3482Gt1.LJIIIZ.LIZ().LJFF;
        int LIZJ = C3482Gt1.LJIIIZ.LIZ().LIZJ();
        2sG r0 = new 2sG();
        r0.element = str4;
        long j4 = j;
        long j5 = j2;
        long j6 = j3;
        if (LIZ == null || l == null) {
            if (C3482Gt1.LJIIIZ.LIZ().LIZ()) {
                r0.element = "ecom_normal_feed_loadmore";
                feed = 0bn.LIZ.LIZ().feed(str6, j4, "ecom_normal_feed_loadmore", str5, 1, j5, j6, "commerce_banner");
            } else {
                feed = 0bn.LIZ.LIZ().feed(str6, j4, str4, str5, 1, j5, j6);
            }
            n.LIZIZ(feed, "");
        } else {
            r0.element = "ecom_template_inner_loadmore";
            feed = 0bn.LIZ.LIZ().feed(str6, j4, "ecom_template_inner_loadmore", str5, 1, j5, j6, LIZ, l, LIZJ);
            n.LIZIZ(feed, "");
        }
        PgU<C3525Gti<Pair<List<FeedItem>, FeedExtra>>> LIZIZ = feed.LIZLLL(new C3521Gte(r0)).LIZIZ(new C3485Gt4(this));
        n.LIZIZ(LIZIZ, "");
        return LIZIZ;
    }

    public final PgU<C3525Gti<Pair<List<FeedItem>, FeedExtra>>> getRoomList(long j, String str, String str2, long j2, long j3, String str3, 0bm r28) {
        int i;
        long j4;
        String str4 = str3;
        String str5 = str;
        0bm r1 = r28;
        String str6 = str2;
        M12.LIZ(str5, str6, str4, r1);
        FeedApi LIZ = 0bn.LIZ.LIZ();
        Integer num = r1.LIZ;
        if (num != null) {
            i = num.intValue();
        } else {
            i = 0;
        }
        Long l = r1.LIZIZ;
        if (l != null) {
            j4 = l.longValue();
        } else {
            j4 = 0;
        }
        PgU<C3525Gti<Pair<List<FeedItem>, FeedExtra>>> LIZIZ = LIZ.feed(str4, j, str5, str6, 1, j2, j3, i, j4).LIZLLL(new C3522Gtf(str5)).LIZIZ(new C3483Gt2(this));
        n.LIZIZ(LIZIZ, "");
        return LIZIZ;
    }
}
