Rabbit-R1/original r1/java/sources/androidx/compose/foundation/gestures/ScrollingLogic.java
2024-05-21 17:08:36 -04:00

320 lines
20 KiB
Java

package androidx.compose.foundation.gestures;
import androidx.compose.foundation.OverscrollEffect;
import androidx.compose.runtime.MutableState;
import androidx.compose.runtime.SnapshotStateKt__SnapshotStateKt;
import androidx.compose.runtime.State;
import androidx.compose.ui.geometry.Offset;
import androidx.compose.ui.geometry.OffsetKt;
import androidx.compose.ui.input.nestedscroll.NestedScrollDispatcher;
import androidx.compose.ui.unit.Velocity;
import io.sentry.protocol.Device;
import io.sentry.protocol.TransactionInfo;
import kotlin.Metadata;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
/* JADX INFO: Access modifiers changed from: package-private */
/* compiled from: Scrollable.kt */
@Metadata(d1 = {"\u0000l\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\r\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0007\n\u0002\b\u0010\b\u0002\u0018\u00002\u00020\u0001B=\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\f\u0010\u0006\u001a\b\u0012\u0004\u0012\u00020\b0\u0007\u0012\u0006\u0010\t\u001a\u00020\n\u0012\u0006\u0010\u000b\u001a\u00020\f\u0012\b\u0010\r\u001a\u0004\u0018\u00010\u000e¢\u0006\u0002\u0010\u000fJ!\u0010 \u001a\u00020!2\u0006\u0010\"\u001a\u00020!H\u0086@ø\u0001\u0000ø\u0001\u0001ø\u0001\u0001¢\u0006\u0004\b#\u0010$J!\u0010%\u001a\u00020&2\u0006\u0010'\u001a\u00020!H\u0086@ø\u0001\u0000ø\u0001\u0001ø\u0001\u0001¢\u0006\u0004\b(\u0010$J\u001b\u0010)\u001a\u00020*2\u0006\u0010+\u001a\u00020*ø\u0001\u0000ø\u0001\u0001¢\u0006\u0004\b,\u0010-J\u000e\u0010.\u001a\u00020&2\u0006\u0010/\u001a\u00020\u0005J\u0006\u00100\u001a\u00020\u0005J'\u00101\u001a\u00020**\u0002022\u0006\u00103\u001a\u00020*2\u0006\u00104\u001a\u000205ø\u0001\u0000ø\u0001\u0001¢\u0006\u0004\b6\u00107J\u0017\u00108\u001a\u00020**\u00020*ø\u0001\u0000ø\u0001\u0001¢\u0006\u0004\b9\u0010-J\n\u00108\u001a\u00020:*\u00020:J\u0017\u0010;\u001a\u00020**\u00020*ø\u0001\u0000ø\u0001\u0001¢\u0006\u0004\b<\u0010-J\u0017\u0010=\u001a\u00020!*\u00020!ø\u0001\u0000ø\u0001\u0001¢\u0006\u0004\b>\u0010-J\u0017\u0010?\u001a\u00020:*\u00020*ø\u0001\u0000ø\u0001\u0001¢\u0006\u0004\b@\u0010AJ\u0017\u0010?\u001a\u00020:*\u00020!ø\u0001\u0000ø\u0001\u0001¢\u0006\u0004\bB\u0010AJ\u001a\u0010C\u001a\u00020**\u00020:ø\u0001\u0002ø\u0001\u0000ø\u0001\u0001¢\u0006\u0004\bD\u0010EJ\u001f\u0010F\u001a\u00020!*\u00020!2\u0006\u0010G\u001a\u00020:ø\u0001\u0000ø\u0001\u0001¢\u0006\u0004\bH\u0010IR\u0011\u0010\u000b\u001a\u00020\\u0006\b\n\u0000\u001a\u0004\b\u0010\u0010\u0011R\u0014\u0010\u0012\u001a\b\u0012\u0004\u0012\u00020\u00050\u0013X\u0082\u0004¢\u0006\u0002\n\u0000R\u0017\u0010\u0006\u001a\b\u0012\u0004\u0012\u00020\b0\u0007¢\u0006\b\n\u0000\u001a\u0004\b\u0014\u0010\u0015R\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\u0016\u0010\u0017R\u0013\u0010\r\u001a\u0004\u0018\u00010\u000e¢\u0006\b\n\u0000\u001a\u0004\b\u0018\u0010\u0019R\u0011\u0010\u0004\u001a\u00020\u0005¢\u0006\b\n\u0000\u001a\u0004\b\u001a\u0010\u001bR\u0011\u0010\t\u001a\u00020\\u0006\b\n\u0000\u001a\u0004\b\u001c\u0010\u001dR\u0014\u0010\u001e\u001a\u00020\u00058BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u001f\u0010\u001b\u0082\u0002\u000f\n\u0005\\u001e0\u0001\n\u0002\b\u0019\n\u0002\b!¨\u0006J"}, d2 = {"Landroidx/compose/foundation/gestures/ScrollingLogic;", "", Device.JsonKeys.ORIENTATION, "Landroidx/compose/foundation/gestures/Orientation;", "reverseDirection", "", "nestedScrollDispatcher", "Landroidx/compose/runtime/State;", "Landroidx/compose/ui/input/nestedscroll/NestedScrollDispatcher;", "scrollableState", "Landroidx/compose/foundation/gestures/ScrollableState;", "flingBehavior", "Landroidx/compose/foundation/gestures/FlingBehavior;", "overscrollEffect", "Landroidx/compose/foundation/OverscrollEffect;", "(Landroidx/compose/foundation/gestures/Orientation;ZLandroidx/compose/runtime/State;Landroidx/compose/foundation/gestures/ScrollableState;Landroidx/compose/foundation/gestures/FlingBehavior;Landroidx/compose/foundation/OverscrollEffect;)V", "getFlingBehavior", "()Landroidx/compose/foundation/gestures/FlingBehavior;", "isNestedFlinging", "Landroidx/compose/runtime/MutableState;", "getNestedScrollDispatcher", "()Landroidx/compose/runtime/State;", "getOrientation", "()Landroidx/compose/foundation/gestures/Orientation;", "getOverscrollEffect", "()Landroidx/compose/foundation/OverscrollEffect;", "getReverseDirection", "()Z", "getScrollableState", "()Landroidx/compose/foundation/gestures/ScrollableState;", "shouldDispatchOverscroll", "getShouldDispatchOverscroll", "doFlingAnimation", "Landroidx/compose/ui/unit/Velocity;", "available", "doFlingAnimation-QWom1Mo", "(JLkotlin/coroutines/Continuation;)Ljava/lang/Object;", "onDragStopped", "", "initialVelocity", "onDragStopped-sF-c-tU", "performRawScroll", "Landroidx/compose/ui/geometry/Offset;", "scroll", "performRawScroll-MK-Hz9U", "(J)J", "registerNestedFling", "isFlinging", "shouldScrollImmediately", "dispatchScroll", "Landroidx/compose/foundation/gestures/ScrollScope;", "availableDelta", TransactionInfo.JsonKeys.SOURCE, "Landroidx/compose/ui/input/nestedscroll/NestedScrollSource;", "dispatchScroll-3eAAhYA", "(Landroidx/compose/foundation/gestures/ScrollScope;JI)J", "reverseIfNeeded", "reverseIfNeeded-MK-Hz9U", "", "singleAxisOffset", "singleAxisOffset-MK-Hz9U", "singleAxisVelocity", "singleAxisVelocity-AH228Gc", "toFloat", "toFloat-k-4lQ0M", "(J)F", "toFloat-TH1AsA0", "toOffset", "toOffset-tuRUvjQ", "(F)J", "update", "newValue", "update-QWom1Mo", "(JF)J", "foundation_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public final class ScrollingLogic {
private final FlingBehavior flingBehavior;
private final MutableState<Boolean> isNestedFlinging;
private final State<NestedScrollDispatcher> nestedScrollDispatcher;
private final Orientation orientation;
private final OverscrollEffect overscrollEffect;
private final boolean reverseDirection;
private final ScrollableState scrollableState;
public final FlingBehavior getFlingBehavior() {
return this.flingBehavior;
}
public final State<NestedScrollDispatcher> getNestedScrollDispatcher() {
return this.nestedScrollDispatcher;
}
public final Orientation getOrientation() {
return this.orientation;
}
public final OverscrollEffect getOverscrollEffect() {
return this.overscrollEffect;
}
public final boolean getReverseDirection() {
return this.reverseDirection;
}
public final ScrollableState getScrollableState() {
return this.scrollableState;
}
public final float reverseIfNeeded(float f) {
return this.reverseDirection ? f * (-1) : f;
}
public ScrollingLogic(Orientation orientation, boolean z, State<NestedScrollDispatcher> nestedScrollDispatcher, ScrollableState scrollableState, FlingBehavior flingBehavior, OverscrollEffect overscrollEffect) {
MutableState<Boolean> mutableStateOf$default;
Intrinsics.checkNotNullParameter(orientation, "orientation");
Intrinsics.checkNotNullParameter(nestedScrollDispatcher, "nestedScrollDispatcher");
Intrinsics.checkNotNullParameter(scrollableState, "scrollableState");
Intrinsics.checkNotNullParameter(flingBehavior, "flingBehavior");
this.orientation = orientation;
this.reverseDirection = z;
this.nestedScrollDispatcher = nestedScrollDispatcher;
this.scrollableState = scrollableState;
this.flingBehavior = flingBehavior;
this.overscrollEffect = overscrollEffect;
mutableStateOf$default = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(false, null, 2, null);
this.isNestedFlinging = mutableStateOf$default;
}
/* renamed from: toOffset-tuRUvjQ, reason: not valid java name */
public final long m354toOffsettuRUvjQ(float f) {
if (f == 0.0f) {
return Offset.INSTANCE.m2416getZeroF1C5BW0();
}
return this.orientation == Orientation.Horizontal ? OffsetKt.Offset(f, 0.0f) : OffsetKt.Offset(0.0f, f);
}
/* renamed from: singleAxisOffset-MK-Hz9U, reason: not valid java name */
public final long m350singleAxisOffsetMKHz9U(long j) {
return this.orientation == Orientation.Horizontal ? Offset.m2394copydBAh8RU$default(j, 0.0f, 0.0f, 1, null) : Offset.m2394copydBAh8RU$default(j, 0.0f, 0.0f, 2, null);
}
/* renamed from: toFloat-k-4lQ0M, reason: not valid java name */
public final float m353toFloatk4lQ0M(long j) {
return this.orientation == Orientation.Horizontal ? Offset.m2400getXimpl(j) : Offset.m2401getYimpl(j);
}
/* renamed from: toFloat-TH1AsA0, reason: not valid java name */
public final float m352toFloatTH1AsA0(long j) {
return this.orientation == Orientation.Horizontal ? Velocity.m5108getXimpl(j) : Velocity.m5109getYimpl(j);
}
/* renamed from: singleAxisVelocity-AH228Gc, reason: not valid java name */
public final long m351singleAxisVelocityAH228Gc(long j) {
return this.orientation == Orientation.Horizontal ? Velocity.m5104copyOhffZ5M$default(j, 0.0f, 0.0f, 1, null) : Velocity.m5104copyOhffZ5M$default(j, 0.0f, 0.0f, 2, null);
}
/* renamed from: update-QWom1Mo, reason: not valid java name */
public final long m355updateQWom1Mo(long j, float f) {
return this.orientation == Orientation.Horizontal ? Velocity.m5104copyOhffZ5M$default(j, f, 0.0f, 2, null) : Velocity.m5104copyOhffZ5M$default(j, 0.0f, f, 1, null);
}
/* renamed from: reverseIfNeeded-MK-Hz9U, reason: not valid java name */
public final long m349reverseIfNeededMKHz9U(long j) {
return this.reverseDirection ? Offset.m2407timestuRUvjQ(j, -1.0f) : j;
}
/* renamed from: dispatchScroll-3eAAhYA, reason: not valid java name */
public final long m345dispatchScroll3eAAhYA(final ScrollScope dispatchScroll, long j, final int i) {
Intrinsics.checkNotNullParameter(dispatchScroll, "$this$dispatchScroll");
long m350singleAxisOffsetMKHz9U = m350singleAxisOffsetMKHz9U(j);
Function1<Offset, Offset> function1 = new Function1<Offset, Offset>() { // from class: androidx.compose.foundation.gestures.ScrollingLogic$dispatchScroll$performScroll$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 */ Offset invoke(Offset offset) {
return Offset.m2389boximpl(m356invokeMKHz9U(offset.getPackedValue()));
}
/* renamed from: invoke-MK-Hz9U, reason: not valid java name */
public final long m356invokeMKHz9U(long j2) {
NestedScrollDispatcher value = ScrollingLogic.this.getNestedScrollDispatcher().getValue();
long m3646dispatchPreScrollOzD1aCk = value.m3646dispatchPreScrollOzD1aCk(j2, i);
long m2404minusMKHz9U = Offset.m2404minusMKHz9U(j2, m3646dispatchPreScrollOzD1aCk);
ScrollingLogic scrollingLogic = ScrollingLogic.this;
long m349reverseIfNeededMKHz9U = scrollingLogic.m349reverseIfNeededMKHz9U(scrollingLogic.m354toOffsettuRUvjQ(dispatchScroll.scrollBy(scrollingLogic.m353toFloatk4lQ0M(scrollingLogic.m349reverseIfNeededMKHz9U(m2404minusMKHz9U)))));
return Offset.m2405plusMKHz9U(Offset.m2405plusMKHz9U(m3646dispatchPreScrollOzD1aCk, m349reverseIfNeededMKHz9U), value.m3644dispatchPostScrollDzOQY0M(m349reverseIfNeededMKHz9U, Offset.m2404minusMKHz9U(m2404minusMKHz9U, m349reverseIfNeededMKHz9U), i));
}
};
if (this.overscrollEffect != null && getShouldDispatchOverscroll()) {
return this.overscrollEffect.mo164applyToScrollRhakbz0(m350singleAxisOffsetMKHz9U, i, function1);
}
return function1.invoke(Offset.m2389boximpl(m350singleAxisOffsetMKHz9U)).getPackedValue();
}
private final boolean getShouldDispatchOverscroll() {
return this.scrollableState.getCanScrollForward() || this.scrollableState.getCanScrollBackward();
}
/* renamed from: performRawScroll-MK-Hz9U, reason: not valid java name */
public final long m348performRawScrollMKHz9U(long scroll) {
if (this.scrollableState.isScrollInProgress()) {
return Offset.INSTANCE.m2416getZeroF1C5BW0();
}
return m354toOffsettuRUvjQ(reverseIfNeeded(this.scrollableState.dispatchRawDelta(reverseIfNeeded(m353toFloatk4lQ0M(scroll)))));
}
/* JADX WARN: Removed duplicated region for block: B:16:0x003a */
/* JADX WARN: Removed duplicated region for block: B:8:0x0025 */
/* renamed from: onDragStopped-sF-c-tU, reason: not valid java name */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final java.lang.Object m347onDragStoppedsFctU(long r6, kotlin.coroutines.Continuation<? super kotlin.Unit> r8) {
/*
r5 = this;
boolean r0 = r8 instanceof androidx.compose.foundation.gestures.ScrollingLogic$onDragStopped$1
if (r0 == 0) goto L14
r0 = r8
androidx.compose.foundation.gestures.ScrollingLogic$onDragStopped$1 r0 = (androidx.compose.foundation.gestures.ScrollingLogic$onDragStopped$1) r0
int r1 = r0.label
r2 = -2147483648(0xffffffff80000000, float:-0.0)
r1 = r1 & r2
if (r1 == 0) goto L14
int r8 = r0.label
int r8 = r8 - r2
r0.label = r8
goto L19
L14:
androidx.compose.foundation.gestures.ScrollingLogic$onDragStopped$1 r0 = new androidx.compose.foundation.gestures.ScrollingLogic$onDragStopped$1
r0.<init>(r5, r8)
L19:
java.lang.Object r8 = r0.result
java.lang.Object r1 = kotlin.coroutines.intrinsics.IntrinsicsKt.getCOROUTINE_SUSPENDED()
int r2 = r0.label
r3 = 2
r4 = 1
if (r2 == 0) goto L3a
if (r2 == r4) goto L32
if (r2 != r3) goto L2a
goto L32
L2a:
java.lang.IllegalStateException r5 = new java.lang.IllegalStateException
java.lang.String r6 = "call to 'resume' before 'invoke' with coroutine"
r5.<init>(r6)
throw r5
L32:
java.lang.Object r5 = r0.L$0
androidx.compose.foundation.gestures.ScrollingLogic r5 = (androidx.compose.foundation.gestures.ScrollingLogic) r5
kotlin.ResultKt.throwOnFailure(r8)
goto L72
L3a:
kotlin.ResultKt.throwOnFailure(r8)
r5.registerNestedFling(r4)
long r6 = r5.m351singleAxisVelocityAH228Gc(r6)
androidx.compose.foundation.gestures.ScrollingLogic$onDragStopped$performFling$1 r8 = new androidx.compose.foundation.gestures.ScrollingLogic$onDragStopped$performFling$1
r2 = 0
r8.<init>(r5, r2)
kotlin.jvm.functions.Function2 r8 = (kotlin.jvm.functions.Function2) r8
androidx.compose.foundation.OverscrollEffect r2 = r5.overscrollEffect
if (r2 == 0) goto L63
boolean r2 = r5.getShouldDispatchOverscroll()
if (r2 == 0) goto L63
androidx.compose.foundation.OverscrollEffect r2 = r5.overscrollEffect
r0.L$0 = r5
r0.label = r4
java.lang.Object r6 = r2.mo163applyToFlingBMRW4eQ(r6, r8, r0)
if (r6 != r1) goto L72
return r1
L63:
androidx.compose.ui.unit.Velocity r6 = androidx.compose.ui.unit.Velocity.m5099boximpl(r6)
r0.L$0 = r5
r0.label = r3
java.lang.Object r6 = r8.invoke(r6, r0)
if (r6 != r1) goto L72
return r1
L72:
r6 = 0
r5.registerNestedFling(r6)
kotlin.Unit r5 = kotlin.Unit.INSTANCE
return r5
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.compose.foundation.gestures.ScrollingLogic.m347onDragStoppedsFctU(long, kotlin.coroutines.Continuation):java.lang.Object");
}
/* JADX WARN: Removed duplicated region for block: B:15:0x0037 */
/* JADX WARN: Removed duplicated region for block: B:8:0x0025 */
/* renamed from: doFlingAnimation-QWom1Mo, reason: not valid java name */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final java.lang.Object m346doFlingAnimationQWom1Mo(long r13, kotlin.coroutines.Continuation<? super androidx.compose.ui.unit.Velocity> r15) {
/*
r12 = this;
boolean r0 = r15 instanceof androidx.compose.foundation.gestures.ScrollingLogic$doFlingAnimation$1
if (r0 == 0) goto L14
r0 = r15
androidx.compose.foundation.gestures.ScrollingLogic$doFlingAnimation$1 r0 = (androidx.compose.foundation.gestures.ScrollingLogic$doFlingAnimation$1) r0
int r1 = r0.label
r2 = -2147483648(0xffffffff80000000, float:-0.0)
r1 = r1 & r2
if (r1 == 0) goto L14
int r15 = r0.label
int r15 = r15 - r2
r0.label = r15
goto L19
L14:
androidx.compose.foundation.gestures.ScrollingLogic$doFlingAnimation$1 r0 = new androidx.compose.foundation.gestures.ScrollingLogic$doFlingAnimation$1
r0.<init>(r12, r15)
L19:
r4 = r0
java.lang.Object r15 = r4.result
java.lang.Object r0 = kotlin.coroutines.intrinsics.IntrinsicsKt.getCOROUTINE_SUSPENDED()
int r1 = r4.label
r2 = 1
if (r1 == 0) goto L37
if (r1 != r2) goto L2f
java.lang.Object r12 = r4.L$0
kotlin.jvm.internal.Ref$LongRef r12 = (kotlin.jvm.internal.Ref.LongRef) r12
kotlin.ResultKt.throwOnFailure(r15)
goto L61
L2f:
java.lang.IllegalStateException r12 = new java.lang.IllegalStateException
java.lang.String r13 = "call to 'resume' before 'invoke' with coroutine"
r12.<init>(r13)
throw r12
L37:
kotlin.ResultKt.throwOnFailure(r15)
kotlin.jvm.internal.Ref$LongRef r15 = new kotlin.jvm.internal.Ref$LongRef
r15.<init>()
r15.element = r13
androidx.compose.foundation.gestures.ScrollableState r1 = r12.scrollableState
r3 = 0
androidx.compose.foundation.gestures.ScrollingLogic$doFlingAnimation$2 r11 = new androidx.compose.foundation.gestures.ScrollingLogic$doFlingAnimation$2
r10 = 0
r5 = r11
r6 = r12
r7 = r15
r8 = r13
r5.<init>(r6, r7, r8, r10)
r12 = r11
kotlin.jvm.functions.Function2 r12 = (kotlin.jvm.functions.Function2) r12
r5 = 1
r6 = 0
r4.L$0 = r15
r4.label = r2
r2 = r3
r3 = r12
java.lang.Object r12 = androidx.compose.foundation.gestures.ScrollableState.scroll$default(r1, r2, r3, r4, r5, r6)
if (r12 != r0) goto L60
return r0
L60:
r12 = r15
L61:
long r12 = r12.element
androidx.compose.ui.unit.Velocity r12 = androidx.compose.ui.unit.Velocity.m5099boximpl(r12)
return r12
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.compose.foundation.gestures.ScrollingLogic.m346doFlingAnimationQWom1Mo(long, kotlin.coroutines.Continuation):java.lang.Object");
}
public final boolean shouldScrollImmediately() {
OverscrollEffect overscrollEffect;
return this.scrollableState.isScrollInProgress() || this.isNestedFlinging.getValue().booleanValue() || ((overscrollEffect = this.overscrollEffect) != null && overscrollEffect.isInProgress());
}
public final void registerNestedFling(boolean isFlinging) {
this.isNestedFlinging.setValue(Boolean.valueOf(isFlinging));
}
}