discord-jadx/app/src/main/java/com/discord/utilities/recycler/SpeedOnScrollListener.java

111 lines
4.1 KiB
Java

package com.discord.utilities.recycler;
import androidx.recyclerview.widget.RecyclerView;
import com.discord.utilities.time.Clock;
import com.discord.utilities.time.ClockFactory;
import d0.z.d.m;
import d0.z.d.o;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
/* compiled from: SpeedOnScrollListener.kt */
public final class SpeedOnScrollListener extends RecyclerView.OnScrollListener {
public static final Companion Companion = new Companion(null);
private static final long INIT_TIMESTAMP = -1;
private final Clock clock;
private final long maxScrolledPxPerMs;
private final int orientation;
private final Function1<Boolean, Unit> thresholdCallback;
private long timeStamp;
/* compiled from: SpeedOnScrollListener.kt */
/* renamed from: com.discord.utilities.recycler.SpeedOnScrollListener$1 reason: invalid class name */
public static final class AnonymousClass1 extends o implements Function1<Boolean, Unit> {
public static final AnonymousClass1 INSTANCE = new AnonymousClass1();
public AnonymousClass1() {
super(1);
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Unit invoke(Boolean bool) {
invoke(bool.booleanValue());
return Unit.a;
}
public final void invoke(boolean z2) {
}
}
/* compiled from: SpeedOnScrollListener.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
public SpeedOnScrollListener() {
this(0, null, 0, null, 15, null);
}
/* JADX DEBUG: Multi-variable search result rejected for r4v0, resolved type: kotlin.jvm.functions.Function1<? super java.lang.Boolean, kotlin.Unit> */
/* JADX WARN: Multi-variable type inference failed */
public SpeedOnScrollListener(long j, Function1<? super Boolean, Unit> function1, int i, Clock clock) {
m.checkNotNullParameter(function1, "thresholdCallback");
m.checkNotNullParameter(clock, "clock");
this.maxScrolledPxPerMs = j;
this.thresholdCallback = function1;
this.orientation = i;
this.clock = clock;
this.timeStamp = -1;
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ SpeedOnScrollListener(long j, Function1 function1, int i, Clock clock, int i2, DefaultConstructorMarker defaultConstructorMarker) {
this((i2 & 1) != 0 ? 1 : j, (i2 & 2) != 0 ? AnonymousClass1.INSTANCE : function1, (i2 & 4) != 0 ? 1 : i, (i2 & 8) != 0 ? ClockFactory.get() : clock);
}
public final Clock getClock() {
return this.clock;
}
public final long getMaxScrolledPxPerMs() {
return this.maxScrolledPxPerMs;
}
public final int getOrientation() {
return this.orientation;
}
public final Function1<Boolean, Unit> getThresholdCallback() {
return this.thresholdCallback;
}
@Override // androidx.recyclerview.widget.RecyclerView.OnScrollListener
public void onScrolled(RecyclerView recyclerView, int i, int i2) {
m.checkNotNullParameter(recyclerView, "recyclerView");
long currentTimeMillis = this.clock.currentTimeMillis();
long j = this.timeStamp;
if (j == -1) {
this.timeStamp = currentTimeMillis;
return;
}
boolean z2 = true;
if (this.orientation == 1) {
i = i2;
}
float abs = Math.abs(((float) i) / ((float) (currentTimeMillis - j)));
this.timeStamp = currentTimeMillis;
Function1<Boolean, Unit> function1 = this.thresholdCallback;
if (abs > ((float) this.maxScrolledPxPerMs)) {
z2 = false;
}
function1.invoke(Boolean.valueOf(z2));
}
}