package com.bytedance.android.livesdk.list;

import X.0CB;
import X.0CD;
import X.0CH;
import X.0CN;
import X.2cN;
import X.5Fn;
import X.6Is;
import X.C3023Glc;
import X.C3464Gsj;
import X.C3466Gsl;
import X.C3631GvQ;
import X.GRC;
import X.Mk2;
import X.Mk3;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.android.livesdkapi.depend.model.live.RoomInfo;
import com.bytedance.android.livesdkapi.session.EnterRoomConfig;
import com.bytedance.covode.number.Covode;
import java.util.ArrayList;
import java.util.List;

public class MultiRoomIdListProvider extends C3464Gsj implements 6Is {
    public List<Room> LIZ;
    public EnterRoomConfig LIZIZ;
    public List<RoomInfo> LIZJ = new ArrayList();
    public final List<EnterRoomConfig> LIZLLL = new ArrayList();
    public 2cN LJ;
    public List<Room> LJFF = new ArrayList();

    static {
        Covode.recordClassIndex(17535);
    }

    public final void LIZIZ(int i) {
    }

    public final Room LIZJ(int i) {
        return null;
    }

    public void onStateChanged(0CH r2, 0CB r3) {
        if (r3 == 0CB.ON_DESTROY) {
            onDestroy();
        }
    }

    public final List<Room> LJFF() {
        return this.LJFF;
    }

    public final int LIZ() {
        return this.LIZJ.size();
    }

    public final List<Room> LIZIZ() {
        return new ArrayList();
    }

    @0CN(LIZ = 0CB.ON_DESTROY)
    public void onDestroy() {
        2cN r0 = this.LJ;
        if (r0 != null) {
            r0.dispose();
            this.LJ = null;
        }
    }

    public final int LIZ(EnterRoomConfig enterRoomConfig) {
        return this.LIZJ.indexOf(Long.valueOf(enterRoomConfig.LIZLLL.LJJJJZI));
    }

    public final void LIZ(long j) {
        int i = 0;
        while (i < this.LIZJ.size()) {
            if (this.LIZJ.get(i) == null || this.LIZJ.get(i).getRoomId() != j) {
                i++;
            } else {
                this.LIZJ.remove(i);
                return;
            }
        }
    }

    public final void LIZ(List<Room> list) {
        this.LIZLLL.clear();
        if (!5Fn.LIZ(list)) {
            for (Room LIZ2 : list) {
                this.LIZLLL.add(C3023Glc.LIZ(LIZ2, false));
            }
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:30:0x00af, code lost:
        if (r7 >= 0) goto L_0x0052;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final com.bytedance.android.livesdkapi.session.EnterRoomConfig LIZ(int r7) {
        /*
            r6 = this;
            java.util.List<com.bytedance.android.livesdkapi.session.EnterRoomConfig> r0 = r6.LIZLLL
            boolean r0 = X.878.LIZ(r0)
            if (r0 != 0) goto L_0x0019
            java.util.List<com.bytedance.android.livesdkapi.session.EnterRoomConfig> r0 = r6.LIZLLL
            int r0 = r0.size()
            if (r0 <= r7) goto L_0x0019
            java.util.List<com.bytedance.android.livesdkapi.session.EnterRoomConfig> r0 = r6.LIZLLL
            java.lang.Object r0 = r0.get(r7)
            com.bytedance.android.livesdkapi.session.EnterRoomConfig r0 = (com.bytedance.android.livesdkapi.session.EnterRoomConfig) r0
            return r0
        L_0x0019:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig r3 = new com.bytedance.android.livesdkapi.session.EnterRoomConfig
            r3.<init>()
            com.bytedance.android.livesdkapi.session.EnterRoomConfig r0 = r6.LIZIZ
            if (r0 == 0) goto L_0x00af
            if (r7 < 0) goto L_0x00ae
            java.util.List<com.bytedance.android.livesdkapi.depend.model.live.RoomInfo> r0 = r6.LIZJ
            int r0 = r0.size()
            if (r7 >= r0) goto L_0x0052
            com.bytedance.android.livesdkapi.session.EnterRoomConfig r0 = r6.LIZIZ
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r0.LIZLLL
            long r4 = r0.LJJJJZI
            r1 = 0
            int r0 = (r4 > r1 ? 1 : (r4 == r1 ? 0 : -1))
            if (r0 <= 0) goto L_0x0052
            java.util.List<com.bytedance.android.livesdkapi.depend.model.live.RoomInfo> r0 = r6.LIZJ
            java.lang.Object r0 = r0.get(r7)
            if (r0 == 0) goto L_0x0052
            java.util.List<com.bytedance.android.livesdkapi.depend.model.live.RoomInfo> r0 = r6.LIZJ
            java.lang.Object r0 = r0.get(r7)
            com.bytedance.android.livesdkapi.depend.model.live.RoomInfo r0 = (com.bytedance.android.livesdkapi.depend.model.live.RoomInfo) r0
            long r1 = r0.getRoomId()
            int r0 = (r4 > r1 ? 1 : (r4 == r1 ? 0 : -1))
            if (r0 != 0) goto L_0x0052
            com.bytedance.android.livesdkapi.session.EnterRoomConfig r3 = r6.LIZIZ
        L_0x0052:
            java.util.List<com.bytedance.android.livesdkapi.depend.model.live.RoomInfo> r0 = r6.LIZJ
            int r0 = r0.size()
            if (r7 >= r0) goto L_0x00ae
            java.util.List<com.bytedance.android.livesdkapi.depend.model.live.RoomInfo> r0 = r6.LIZJ
            java.lang.Object r0 = r0.get(r7)
            if (r0 == 0) goto L_0x00ae
            com.bytedance.android.livesdkapi.session.EnterRoomConfig r0 = r6.LIZIZ
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$LogData r0 = r0.LIZJ
            java.lang.String r0 = r0.LIZ
            boolean r0 = android.text.TextUtils.isEmpty(r0)
            if (r0 != 0) goto L_0x0078
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$LogData r1 = r3.LIZJ
            com.bytedance.android.livesdkapi.session.EnterRoomConfig r0 = r6.LIZIZ
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$LogData r0 = r0.LIZJ
            java.lang.String r0 = r0.LIZ
            r1.LIZ = r0
        L_0x0078:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig r0 = r6.LIZIZ
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$LogData r0 = r0.LIZJ
            java.lang.String r0 = r0.LJI
            boolean r0 = android.text.TextUtils.isEmpty(r0)
            if (r0 != 0) goto L_0x008e
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$LogData r1 = r3.LIZJ
            com.bytedance.android.livesdkapi.session.EnterRoomConfig r0 = r6.LIZIZ
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$LogData r0 = r0.LIZJ
            java.lang.String r0 = r0.LJI
            r1.LJI = r0
        L_0x008e:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r2 = r3.LIZLLL
            java.util.List<com.bytedance.android.livesdkapi.depend.model.live.RoomInfo> r0 = r6.LIZJ
            java.lang.Object r0 = r0.get(r7)
            com.bytedance.android.livesdkapi.depend.model.live.RoomInfo r0 = (com.bytedance.android.livesdkapi.depend.model.live.RoomInfo) r0
            long r0 = r0.getRoomId()
            r2.LJJJJZI = r0
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$LogData r1 = r3.LIZJ
            java.util.List<com.bytedance.android.livesdkapi.depend.model.live.RoomInfo> r0 = r6.LIZJ
            java.lang.Object r0 = r0.get(r7)
            com.bytedance.android.livesdkapi.depend.model.live.RoomInfo r0 = (com.bytedance.android.livesdkapi.depend.model.live.RoomInfo) r0
            java.lang.String r0 = r0.getAnchorId()
            r1.LIZIZ = r0
        L_0x00ae:
            return r3
        L_0x00af:
            if (r7 < 0) goto L_0x00ae
            goto L_0x0052
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.android.livesdk.list.MultiRoomIdListProvider.LIZ(int):com.bytedance.android.livesdkapi.session.EnterRoomConfig");
    }

    public MultiRoomIdListProvider(0CD r5, List<RoomInfo> list, EnterRoomConfig enterRoomConfig) {
        this.LIZIZ = enterRoomConfig;
        this.LIZJ.addAll(list);
        long[] jArr = new long[list.size()];
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i) != null) {
                jArr[i] = list.get(i).getRoomId();
            } else {
                jArr[i] = 0;
            }
        }
        r5.LIZ(this);
        this.LJ = GRC.LIZ.LIZ(jArr).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZ(new C3466Gsl(this, list), C3631GvQ.LIZ);
    }
}
