WeChat.apk(点击下载) / c0.java


package v3;

import dh4.f;
import dh4.j;
import gk4.h;
import gk4.h0;
import gk4.n0;
import gk4.s1;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;
import kh4.p;
import kotlin.ResultKt;
import lh4.f0;
import lh4.l;
import lh4.m;
import lh4.o;
import v3.q1;
import v3.r;
import wg4.b0;
import xg4.u;

public final class c0<Key, Value> extends q1<Key, Value> {

    /* renamed from: c  reason: collision with root package name */
    public int f322246c = Integer.MIN_VALUE;

    /* renamed from: d  reason: collision with root package name */
    public final h0 f322247d;

    /* renamed from: e  reason: collision with root package name */
    public final r<Key, Value> f322248e;

    public static final /* synthetic */ class a extends l implements kh4.a<b0> {
        public a(c0 c0Var) {
            super(0, c0Var, c0.class, "invalidate", "invalidate()V", 0);
        }

        /* Return type fixed from 'java.lang.Object' to match base method */
        @Override // kh4.a
        public b0 invoke() {
            ((c0) this.receiver).c();
            return b0.f332794a;
        }
    }

    public static final class b extends o implements kh4.a<b0> {

        /* renamed from: d  reason: collision with root package name */
        public final /* synthetic */ c0 f322249d;

        /* JADX INFO: super call moved to the top of the method (can break code semantics) */
        public b(c0 c0Var) {
            super(0);
            this.f322249d = c0Var;
        }

        /* Return type fixed from 'java.lang.Object' to match base method */
        @Override // kh4.a
        public b0 invoke() {
            r<Key, Value> rVar = this.f322249d.f322248e;
            e0 e0Var = new e0(new d0(this.f322249d));
            rVar.getClass();
            rVar.f322629a.remove(e0Var);
            r<Key, Value> rVar2 = this.f322249d.f322248e;
            if (rVar2.f322630b.compareAndSet(false, true)) {
                Iterator<r.c> it = rVar2.f322629a.iterator();
                while (it.hasNext()) {
                    it.next().b();
                }
            }
            return b0.f332794a;
        }
    }

    @f(c = "androidx.paging.LegacyPagingSource$3", f = "LegacyPagingSource.kt", l = {}, m = "invokeSuspend")
    public static final class c extends j implements p<n0, bh4.d<? super b0>, Object> {

        /* renamed from: d  reason: collision with root package name */
        public final /* synthetic */ c0 f322250d;

        /* JADX INFO: super call moved to the top of the method (can break code semantics) */
        public c(c0 c0Var, bh4.d dVar) {
            super(2, dVar);
            this.f322250d = c0Var;
        }

        @Override // dh4.a
        public final bh4.d<b0> create(Object obj, bh4.d<?> dVar) {
            m.g(dVar, "completion");
            return new c(this.f322250d, dVar);
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object] */
        @Override // kh4.p
        public final Object invoke(n0 n0Var, bh4.d<? super b0> dVar) {
            return ((c) create(n0Var, dVar)).invokeSuspend(b0.f332794a);
        }

        @Override // dh4.a
        public final Object invokeSuspend(Object obj) {
            ResultKt.throwOnFailure(obj);
            if (!this.f322250d.f322617b.get() && this.f322250d.f322248e.f322630b.get()) {
                this.f322250d.c();
            }
            return b0.f332794a;
        }
    }

    @f(c = "androidx.paging.LegacyPagingSource$load$2", f = "LegacyPagingSource.kt", l = {116}, m = "invokeSuspend")
    public static final class d extends j implements p<n0, bh4.d<? super q1.b.C5663b<Key, Value>>, Object> {

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

        /* renamed from: e  reason: collision with root package name */
        public final /* synthetic */ c0 f322252e;

        /* renamed from: f  reason: collision with root package name */
        public final /* synthetic */ f0 f322253f;

        /* renamed from: g  reason: collision with root package name */
        public final /* synthetic */ q1.a f322254g;

        /* JADX INFO: super call moved to the top of the method (can break code semantics) */
        public d(c0 c0Var, f0 f0Var, q1.a aVar, bh4.d dVar) {
            super(2, dVar);
            this.f322252e = c0Var;
            this.f322253f = f0Var;
            this.f322254g = aVar;
        }

        @Override // dh4.a
        public final bh4.d<b0> create(Object obj, bh4.d<?> dVar) {
            m.g(dVar, "completion");
            return new d(this.f322252e, this.f322253f, this.f322254g, dVar);
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object] */
        @Override // kh4.p
        public final Object invoke(n0 n0Var, Object obj) {
            return ((d) create(n0Var, (bh4.d) obj)).invokeSuspend(b0.f332794a);
        }

        @Override // dh4.a
        public final Object invokeSuspend(Object obj) {
            Object obj2;
            Object obj3;
            ch4.a aVar = ch4.a.COROUTINE_SUSPENDED;
            int i15 = this.f322251d;
            if (i15 == 0) {
                ResultKt.throwOnFailure(obj);
                this.f322251d = 1;
                obj = this.f322252e.f322248e.b(this.f322253f.f253292d, this);
                if (obj == aVar) {
                    return aVar;
                }
            } else if (i15 == 1) {
                ResultKt.throwOnFailure(obj);
            } else {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            r.a aVar2 = (r.a) obj;
            List<Value> list = aVar2.f322632a;
            if (!list.isEmpty() || !(this.f322254g instanceof q1.a.b)) {
                obj2 = aVar2.f322633b;
            } else {
                obj2 = null;
            }
            if (!aVar2.f322632a.isEmpty() || !(this.f322254g instanceof q1.a.C5662a)) {
                obj3 = aVar2.f322634c;
            } else {
                obj3 = null;
            }
            return new q1.b.C5663b(list, obj2, obj3, aVar2.f322635d, aVar2.f322636e);
        }
    }

    public c0(h0 h0Var, r<Key, Value> rVar) {
        m.g(h0Var, "fetchDispatcher");
        m.g(rVar, "dataSource");
        this.f322247d = h0Var;
        this.f322248e = rVar;
        rVar.f322629a.add(new e0(new a(this)));
        this.f322616a.add(new b(this));
        h.d(s1.f221256d, h0Var, null, new c(this, null), 2, null);
    }

    @Override // v3.q1
    public boolean a() {
        if (this.f322248e.f322631c == r.d.f322637d) {
            return true;
        }
        return false;
    }

    @Override // v3.q1
    public Key b(r1<Key, Value> r1Var) {
        int i15;
        boolean z15;
        Value value;
        m.g(r1Var, "state");
        int ordinal = this.f322248e.f322631c.ordinal();
        int i16 = 0;
        if (ordinal == 0) {
            Integer num = r1Var.f322653b;
            if (num == null) {
                return null;
            }
            int intValue = num.intValue();
            int i17 = intValue - r1Var.f322655d;
            int i18 = 0;
            while (i18 < u.e(r1Var.f322652a) && i17 > u.e(r1Var.f322652a.get(i18).f322624a)) {
                i17 -= r1Var.f322652a.get(i18).f322624a.size();
                i18++;
            }
            q1.b.C5663b<Key, Value> a15 = r1Var.a(intValue);
            if (a15 == null || (i15 = a15.f322625b) == null) {
                i15 = 0;
            }
            if (i15 != null) {
                return (Key) Integer.valueOf(i15.intValue() + i17);
            }
            throw new NullPointerException("null cannot be cast to non-null type kotlin.Int");
        } else if (ordinal == 1) {
            return null;
        } else {
            if (ordinal == 2) {
                Integer num2 = r1Var.f322653b;
                if (num2 == null) {
                    return null;
                }
                int intValue2 = num2.intValue();
                List<q1.b.C5663b<Key, Value>> list = r1Var.f322652a;
                if (!(list instanceof Collection) || !list.isEmpty()) {
                    Iterator<T> it = list.iterator();
                    while (true) {
                        if (it.hasNext()) {
                            if (!it.next().f322624a.isEmpty()) {
                                z15 = false;
                                break;
                            }
                        } else {
                            break;
                        }
                    }
                }
                z15 = true;
                if (z15) {
                    value = null;
                } else {
                    int i19 = intValue2 - r1Var.f322655d;
                    while (i16 < u.e(r1Var.f322652a) && i19 > u.e(r1Var.f322652a.get(i16).f322624a)) {
                        i19 -= r1Var.f322652a.get(i16).f322624a.size();
                        i16++;
                    }
                    for (T t15 : r1Var.f322652a) {
                        if (!t15.f322624a.isEmpty()) {
                            List<q1.b.C5663b<Key, Value>> list2 = r1Var.f322652a;
                            ListIterator<q1.b.C5663b<Key, Value>> listIterator = list2.listIterator(list2.size());
                            while (listIterator.hasPrevious()) {
                                q1.b.C5663b<Key, Value> previous = listIterator.previous();
                                if (!previous.f322624a.isEmpty()) {
                                    if (i19 < 0) {
                                        value = (Value) xg4.c0.O(t15.f322624a);
                                    } else {
                                        value = (i16 != u.e(r1Var.f322652a) || i19 <= u.e(((q1.b.C5663b) xg4.c0.X(r1Var.f322652a)).f322624a)) ? r1Var.f322652a.get(i16).f322624a.get(i19) : (Value) xg4.c0.X(previous.f322624a);
                                    }
                                }
                            }
                            throw new NoSuchElementException("List contains no element matching the predicate.");
                        }
                    }
                    throw new NoSuchElementException("Collection contains no element matching the predicate.");
                }
                if (value != null) {
                    return this.f322248e.a(value);
                }
                return null;
            }
            throw new wg4.j();
        }
    }

    @Override // v3.q1
    public Object d(q1.a<Key> aVar, bh4.d<? super q1.b<Key, Value>> dVar) {
        i0 i0Var;
        int i15;
        boolean z15 = aVar instanceof q1.a.c;
        if (z15) {
            i0Var = i0.REFRESH;
        } else if (aVar instanceof q1.a.C5662a) {
            i0Var = i0.APPEND;
        } else if (aVar instanceof q1.a.b) {
            i0Var = i0.PREPEND;
        } else {
            throw new wg4.j();
        }
        if (this.f322246c == Integer.MIN_VALUE) {
            System.out.println((Object) "WARNING: pageSize on the LegacyPagingSource is not set.\nWhen using legacy DataSource / DataSourceFactory with Paging3, page size\nshould've been set by the paging library but it is not set yet.\n\nIf you are seeing this message in tests where you are testing DataSource\nin isolation (without a Pager), it is expected and page size will be estimated\nbased on parameters.\n\nIf you are seeing this message despite using a Pager, please file a bug:\nhttps://issuetracker.google.com/issues/new?component=413106");
            if (z15) {
                int i16 = aVar.f322618a;
                if (i16 % 3 == 0) {
                    i15 = i16 / 3;
                    this.f322246c = i15;
                }
            }
            i15 = aVar.f322618a;
            this.f322246c = i15;
        }
        f0 f0Var = new f0();
        f0Var.f253292d = (T) new r.e(i0Var, aVar.a(), aVar.f322618a, aVar.f322619b, this.f322246c);
        return h.g(this.f322247d, new d(this, f0Var, aVar, null), dVar);
    }

    public final void e(int i15) {
        boolean z15;
        int i16 = this.f322246c;
        if (i16 == Integer.MIN_VALUE || i15 == i16) {
            z15 = true;
        } else {
            z15 = false;
        }
        if (z15) {
            this.f322246c = i15;
            return;
        }
        throw new IllegalStateException(("Page size is already set to " + this.f322246c + '.').toString());
    }
}