mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2025-01-09 13:43:22 +00:00
151 lines
8.3 KiB
Java
151 lines
8.3 KiB
Java
package androidx.compose.foundation.gestures;
|
|
|
|
import androidx.compose.foundation.gestures.ContentInViewModifier;
|
|
import androidx.compose.runtime.collection.MutableVector;
|
|
import androidx.compose.ui.geometry.Rect;
|
|
import io.sentry.SentryBaseEvent;
|
|
import java.util.concurrent.CancellationException;
|
|
import kotlin.Metadata;
|
|
import kotlin.Result;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.ranges.IntRange;
|
|
import kotlinx.coroutines.CancellableContinuation;
|
|
|
|
/* compiled from: BringIntoViewRequestPriorityQueue.kt */
|
|
@Metadata(d1 = {"\u0000B\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u0003\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0000\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0010\u0010\n\u001a\u00020\u000b2\b\u0010\f\u001a\u0004\u0018\u00010\rJ\u000e\u0010\u000e\u001a\u00020\u000f2\u0006\u0010\u0010\u001a\u00020\u0005J<\u0010\u0011\u001a\u00020\u000b2#\u0010\u0012\u001a\u001f\u0012\u0015\u0012\u0013\u0018\u00010\u0014¢\u0006\f\b\u0015\u0012\b\b\u0016\u0012\u0004\b\b(\u0017\u0012\u0004\u0012\u00020\u000b0\u0013H\u0086\bø\u0001\u0000\u0082\u0002\b\n\u0006\b\u0001\u0012\u0002\u0010\u0001J\u0006\u0010\u0018\u001a\u00020\u000fJ\u0006\u0010\u0019\u001a\u00020\u000bJ<\u0010\u001a\u001a\u00020\u000b2#\u0010\u0012\u001a\u001f\u0012\u0015\u0012\u0013\u0018\u00010\u0014¢\u0006\f\b\u0015\u0012\b\b\u0016\u0012\u0004\b\b(\u0017\u0012\u0004\u0012\u00020\u000f0\u0013H\u0086\bø\u0001\u0000\u0082\u0002\b\n\u0006\b\u0001\u0012\u0002\u0010\u0001R\u0014\u0010\u0003\u001a\b\u0012\u0004\u0012\u00020\u00050\u0004X\u0082\u0004¢\u0006\u0002\n\u0000R\u0011\u0010\u0006\u001a\u00020\u00078F¢\u0006\u0006\u001a\u0004\b\b\u0010\t\u0082\u0002\u0007\n\u0005\b\u009920\u0001¨\u0006\u001b"}, d2 = {"Landroidx/compose/foundation/gestures/BringIntoViewRequestPriorityQueue;", "", "()V", "requests", "Landroidx/compose/runtime/collection/MutableVector;", "Landroidx/compose/foundation/gestures/ContentInViewModifier$Request;", "size", "", "getSize", "()I", "cancelAndRemoveAll", "", "cause", "", "enqueue", "", SentryBaseEvent.JsonKeys.REQUEST, "forEachFromSmallest", "block", "Lkotlin/Function1;", "Landroidx/compose/ui/geometry/Rect;", "Lkotlin/ParameterName;", "name", "bounds", "isEmpty", "resumeAndRemoveAll", "resumeAndRemoveWhile", "foundation_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
|
/* loaded from: classes.dex */
|
|
public final class BringIntoViewRequestPriorityQueue {
|
|
private final MutableVector<ContentInViewModifier.Request> requests = new MutableVector<>(new ContentInViewModifier.Request[16], 0);
|
|
|
|
public final int getSize() {
|
|
return this.requests.getSize();
|
|
}
|
|
|
|
public final boolean isEmpty() {
|
|
return this.requests.isEmpty();
|
|
}
|
|
|
|
public final boolean enqueue(final ContentInViewModifier.Request request) {
|
|
Intrinsics.checkNotNullParameter(request, "request");
|
|
Rect invoke = request.getCurrentBounds().invoke();
|
|
if (invoke == null) {
|
|
CancellableContinuation<Unit> continuation = request.getContinuation();
|
|
Result.Companion companion = Result.INSTANCE;
|
|
continuation.resumeWith(Result.m5698constructorimpl(Unit.INSTANCE));
|
|
return false;
|
|
}
|
|
request.getContinuation().invokeOnCancellation(new Function1<Throwable, Unit>() { // from class: androidx.compose.foundation.gestures.BringIntoViewRequestPriorityQueue$enqueue$1
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
{
|
|
super(1);
|
|
}
|
|
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public /* bridge */ /* synthetic */ Unit invoke(Throwable th) {
|
|
invoke2(th);
|
|
return Unit.INSTANCE;
|
|
}
|
|
|
|
/* renamed from: invoke, reason: avoid collision after fix types in other method */
|
|
public final void invoke2(Throwable th) {
|
|
BringIntoViewRequestPriorityQueue.this.requests.remove(request);
|
|
}
|
|
});
|
|
IntRange intRange = new IntRange(0, this.requests.getSize() - 1);
|
|
int first = intRange.getFirst();
|
|
int last = intRange.getLast();
|
|
if (first <= last) {
|
|
while (true) {
|
|
Rect invoke2 = this.requests.getContent()[last].getCurrentBounds().invoke();
|
|
if (invoke2 != null) {
|
|
Rect intersect = invoke.intersect(invoke2);
|
|
if (Intrinsics.areEqual(intersect, invoke)) {
|
|
this.requests.add(last + 1, request);
|
|
return true;
|
|
}
|
|
if (!Intrinsics.areEqual(intersect, invoke2)) {
|
|
CancellationException cancellationException = new CancellationException("bringIntoView call interrupted by a newer, non-overlapping call");
|
|
int size = this.requests.getSize() - 1;
|
|
if (size <= last) {
|
|
while (true) {
|
|
this.requests.getContent()[last].getContinuation().cancel(cancellationException);
|
|
if (size == last) {
|
|
break;
|
|
}
|
|
size++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (last == first) {
|
|
break;
|
|
}
|
|
last--;
|
|
}
|
|
}
|
|
this.requests.add(0, request);
|
|
return true;
|
|
}
|
|
|
|
public final void forEachFromSmallest(Function1<? super Rect, Unit> block) {
|
|
Intrinsics.checkNotNullParameter(block, "block");
|
|
MutableVector mutableVector = this.requests;
|
|
int size = mutableVector.getSize();
|
|
if (size > 0) {
|
|
int i = size - 1;
|
|
Object[] content = mutableVector.getContent();
|
|
do {
|
|
block.invoke(((ContentInViewModifier.Request) content[i]).getCurrentBounds().invoke());
|
|
i--;
|
|
} while (i >= 0);
|
|
}
|
|
}
|
|
|
|
public final void resumeAndRemoveWhile(Function1<? super Rect, Boolean> block) {
|
|
Intrinsics.checkNotNullParameter(block, "block");
|
|
while (this.requests.isNotEmpty() && block.invoke(((ContentInViewModifier.Request) this.requests.last()).getCurrentBounds().invoke()).booleanValue()) {
|
|
CancellableContinuation<Unit> continuation = ((ContentInViewModifier.Request) this.requests.removeAt(this.requests.getSize() - 1)).getContinuation();
|
|
Unit unit = Unit.INSTANCE;
|
|
Result.Companion companion = Result.INSTANCE;
|
|
continuation.resumeWith(Result.m5698constructorimpl(unit));
|
|
}
|
|
}
|
|
|
|
public final void resumeAndRemoveAll() {
|
|
IntRange intRange = new IntRange(0, this.requests.getSize() - 1);
|
|
int first = intRange.getFirst();
|
|
int last = intRange.getLast();
|
|
if (first <= last) {
|
|
while (true) {
|
|
CancellableContinuation<Unit> continuation = this.requests.getContent()[first].getContinuation();
|
|
Unit unit = Unit.INSTANCE;
|
|
Result.Companion companion = Result.INSTANCE;
|
|
continuation.resumeWith(Result.m5698constructorimpl(unit));
|
|
if (first == last) {
|
|
break;
|
|
} else {
|
|
first++;
|
|
}
|
|
}
|
|
}
|
|
this.requests.clear();
|
|
}
|
|
|
|
public final void cancelAndRemoveAll(Throwable cause) {
|
|
MutableVector<ContentInViewModifier.Request> mutableVector = this.requests;
|
|
int size = mutableVector.getSize();
|
|
CancellableContinuation[] cancellableContinuationArr = new CancellableContinuation[size];
|
|
for (int i = 0; i < size; i++) {
|
|
cancellableContinuationArr[i] = mutableVector.getContent()[i].getContinuation();
|
|
}
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
cancellableContinuationArr[i2].cancel(cause);
|
|
}
|
|
if (!this.requests.isEmpty()) {
|
|
throw new IllegalStateException("Check failed.".toString());
|
|
}
|
|
}
|
|
}
|