小红书.apk(点击下载) / y.java


package qb1;

import android.util.LruCache;
import com.xingin.matrix.followfeed.entities.NoteFeed;
import gb1.a;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import k61.b;
import kotlin.Metadata;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.collections.CollectionsKt___CollectionsKt;
import kotlin.jvm.internal.Intrinsics;
import yb1.c;
import z60.h;

@Metadata(bv = {}, d1 = {"\u0000N\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u000b\bÆ\u0002\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b!\u0010\"JB\u0010\u000b\u001a\b\u0012\u0004\u0012\u00020\u00010\u00042\u0006\u0010\u0003\u001a\u00020\u00022\f\u0010\u0005\u001a\b\u0012\u0004\u0012\u00020\u00010\u00042\f\u0010\u0006\u001a\b\u0012\u0004\u0012\u00020\u00010\u00042\u0006\u0010\b\u001a\u00020\u00072\b\b\u0002\u0010\n\u001a\u00020\tJ\u000e\u0010\u000f\u001a\u00020\u000e2\u0006\u0010\r\u001a\u00020\fJ\u001e\u0010\u0014\u001a\u00020\u000e2\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0011\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u0012J4\u0010\u001a\u001a\u00020\f2\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0016\u001a\u00020\u00152\n\b\u0002\u0010\u0017\u001a\u0004\u0018\u00010\u00152\u0006\u0010\b\u001a\u00020\u00072\u0006\u0010\u0019\u001a\u00020\u0018H\u0002J\u001e\u0010\u001b\u001a\u00020\u000e2\f\u0010\u0006\u001a\b\u0012\u0004\u0012\u00020\u00010\u00042\u0006\u0010\n\u001a\u00020\tH\u0002JF\u0010\u001e\u001a\u00020\t2\u0006\u0010\u0003\u001a\u00020\u00022\f\u0010\u001c\u001a\b\u0012\u0004\u0012\u00020\u00010\u00042\f\u0010\u0006\u001a\b\u0012\u0004\u0012\u00020\u00010\u00042\b\u0010\u001d\u001a\u0004\u0018\u00010\u00152\u0006\u0010\r\u001a\u00020\f2\u0006\u0010\n\u001a\u00020\tH\u0002J\u0010\u0010\u001f\u001a\u00020\t2\u0006\u0010\r\u001a\u00020\fH\u0002J\u0010\u0010 \u001a\u00020\t2\u0006\u0010\r\u001a\u00020\fH\u0002¨\u0006#"}, d2 = {"Lqb1/y;", "", "Lk61/b;", "pageIntentImpl", "", "newList", "currentDataList", "", "firstNoteId", "", "isLoadData", "e", "Lqb1/h;", "repeatNoteInfoBean", "", h.f160753a, "Lgb1/a;", "detailFeedRepoImpl", "Lob1/a;", "pageTrackHelper", "i", "Lcom/xingin/matrix/followfeed/entities/NoteFeed;", "currentNoteFeed", "olderNoteFeed", "", "position", "a", "g", "resultList", "noteFeed", "d", "c", "b", "<init>", "()V", "matrix_detail_feed_library_release"}, k = 1, mv = {1, 6, 0})
/* compiled from: VideoFeedRepeatNoteRemoveHelper.kt */
public final class y {

    /* renamed from: a  reason: collision with root package name */
    public static final y f121141a = new y();

    /* renamed from: b  reason: collision with root package name */
    public static LruCache<String, h> f121142b = new LruCache<>(30);

    /* renamed from: c  reason: collision with root package name */
    public static NoteFeed f121143c;

    /* renamed from: d  reason: collision with root package name */
    public static int f121144d;

    public static /* synthetic */ List f(y yVar, b bVar, List list, List list2, String str, boolean z14, int i10, Object obj) {
        return yVar.e(bVar, list, list2, str, (i10 & 16) != 0 ? false : z14);
    }

    public final h a(b bVar, NoteFeed noteFeed, NoteFeed noteFeed2, String str, int i10) {
        String trackId;
        String cursorScore;
        String id3;
        return new h(bVar.getSource(), "video_feed", i10, noteFeed.getId(), bVar.p() ? str : bVar.l(), noteFeed.getCursorScore(), noteFeed.getTrackId(), (noteFeed2 == null || (id3 = noteFeed2.getId()) == null) ? null : id3, (noteFeed2 == null || (cursorScore = noteFeed2.getCursorScore()) == null) ? null : cursorScore, (noteFeed2 == null || (trackId = noteFeed2.getTrackId()) == null) ? null : trackId);
    }

    public final boolean b(h hVar) {
        h hVar2 = f121142b.get(hVar.c());
        if (hVar2 != null) {
            return Intrinsics.areEqual(hVar2.i(), hVar.i());
        }
        return false;
    }

    public final boolean c(h hVar) {
        h hVar2 = f121142b.get(hVar.c());
        if (hVar2 == null || !Intrinsics.areEqual(hVar2.c(), hVar.c()) || Intrinsics.areEqual(hVar2, hVar)) {
            return false;
        }
        return true;
    }

    public final boolean d(b bVar, List<? extends Object> list, List<? extends Object> list2, NoteFeed noteFeed, h hVar, boolean z14) {
        String str;
        if (!z14) {
            list = CollectionsKt___CollectionsKt.plus((Collection) list2, (Iterable) list);
        }
        ArrayList<NoteFeed> arrayList = new ArrayList();
        for (T t14 : list) {
            if (t14 instanceof NoteFeed) {
                arrayList.add(t14);
            }
        }
        for (NoteFeed noteFeed2 : arrayList) {
            String str2 = null;
            if (!(noteFeed2 instanceof NoteFeed)) {
                noteFeed2 = null;
            }
            if (noteFeed2 == null || (str = noteFeed2.getId()) == null) {
                str = null;
            }
            if (noteFeed != null) {
                str2 = noteFeed.getId();
            }
            if (Intrinsics.areEqual(str, str2)) {
                return true;
            }
        }
        if (!(bVar.t().length() > 0) || !c(hVar)) {
            return false;
        }
        return true;
    }

    public final List<Object> e(b bVar, List<? extends Object> list, List<? extends Object> list2, String str, boolean z14) {
        Intrinsics.checkNotNullParameter(bVar, "pageIntentImpl");
        Intrinsics.checkNotNullParameter(list, "newList");
        Intrinsics.checkNotNullParameter(list2, "currentDataList");
        Intrinsics.checkNotNullParameter(str, "firstNoteId");
        ArrayList arrayList = new ArrayList(list.size());
        g(list2, z14);
        int i10 = 0;
        for (T t14 : list) {
            int i14 = i10 + 1;
            if (i10 < 0) {
                CollectionsKt__CollectionsKt.throwIndexOverflow();
            }
            if (t14 instanceof c) {
                arrayList.add(t14);
            } else {
                NoteFeed noteFeed = null;
                T t15 = t14 instanceof NoteFeed ? t14 : null;
                if (t15 != null) {
                    y yVar = f121141a;
                    h a14 = yVar.a(bVar, t15, f121143c, str, f121144d + i10);
                    if (yVar.d(bVar, arrayList, list2, t15, a14, z14)) {
                        if (i10 == 0 && z14) {
                            arrayList.add(t15);
                        }
                        x.f121138a.b(a14, !yVar.b(a14));
                    } else {
                        arrayList.add(t15);
                    }
                    Object obj = CollectionsKt___CollectionsKt.getOrNull(list, i10);
                    if (obj instanceof NoteFeed) {
                        noteFeed = (NoteFeed) obj;
                    }
                    f121143c = noteFeed;
                }
            }
            i10 = i14;
        }
        return arrayList;
    }

    public final void g(List<? extends Object> list, boolean z14) {
        int i10;
        NoteFeed noteFeed = null;
        if (!z14) {
            Object obj = CollectionsKt___CollectionsKt.getOrNull(list, list.size() - 2);
            if (obj instanceof NoteFeed) {
                noteFeed = (NoteFeed) obj;
            }
        }
        f121143c = noteFeed;
        if (z14) {
            i10 = 0;
        } else {
            i10 = list.size() - 2;
        }
        f121144d = i10;
    }

    public final void h(h hVar) {
        Intrinsics.checkNotNullParameter(hVar, "repeatNoteInfoBean");
        f121142b.put(hVar.c(), hVar);
    }

    public final void i(b bVar, a aVar, ob1.a aVar2) {
        Intrinsics.checkNotNullParameter(bVar, "pageIntentImpl");
        Intrinsics.checkNotNullParameter(aVar, "detailFeedRepoImpl");
        Intrinsics.checkNotNullParameter(aVar2, "pageTrackHelper");
        if (bVar.t().length() > 0) {
            List<Object> f14 = aVar.f();
            ArrayList arrayList = new ArrayList();
            for (T t14 : f14) {
                if (t14 instanceof NoteFeed) {
                    arrayList.add(t14);
                }
            }
            NoteFeed noteFeed = null;
            int i10 = 0;
            for (Object obj : arrayList) {
                int i14 = i10 + 1;
                if (i10 < 0) {
                    CollectionsKt__CollectionsKt.throwIndexOverflow();
                }
                NoteFeed noteFeed2 = (NoteFeed) obj;
                if (i10 < aVar2.f().size()) {
                    y yVar = f121141a;
                    yVar.h(yVar.a(bVar, noteFeed2, noteFeed, aVar.d(), i10));
                    noteFeed = noteFeed2;
                }
                i10 = i14;
            }
        }
    }
}