- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
123 lines
6.2 KiB
Java
123 lines
6.2 KiB
Java
package androidx.core.view;
|
|
|
|
import android.content.Context;
|
|
import android.view.MotionEvent;
|
|
import android.view.VelocityTracker;
|
|
import android.view.ViewConfiguration;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.VisibleForTesting;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class DifferentialMotionFlingController {
|
|
private final Context mContext;
|
|
private final int[] mFlingVelocityThresholds;
|
|
private float mLastFlingVelocity;
|
|
private int mLastProcessedAxis;
|
|
private int mLastProcessedDeviceId;
|
|
private int mLastProcessedSource;
|
|
private final DifferentialMotionFlingTarget mTarget;
|
|
private final DifferentialVelocityProvider mVelocityProvider;
|
|
private final FlingVelocityThresholdCalculator mVelocityThresholdCalculator;
|
|
|
|
@Nullable
|
|
private VelocityTracker mVelocityTracker;
|
|
|
|
@VisibleForTesting
|
|
public interface DifferentialVelocityProvider {
|
|
float getCurrentVelocity(VelocityTracker velocityTracker, MotionEvent motionEvent, int i);
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public interface FlingVelocityThresholdCalculator {
|
|
void calculateFlingVelocityThresholds(Context context, int[] iArr, MotionEvent motionEvent, int i);
|
|
}
|
|
|
|
public DifferentialMotionFlingController(@NonNull Context context, @NonNull DifferentialMotionFlingTarget differentialMotionFlingTarget) {
|
|
this(context, differentialMotionFlingTarget, new FlingVelocityThresholdCalculator() { // from class: androidx.core.view.DifferentialMotionFlingController$$ExternalSyntheticLambda0
|
|
@Override // androidx.core.view.DifferentialMotionFlingController.FlingVelocityThresholdCalculator
|
|
public final void calculateFlingVelocityThresholds(Context context2, int[] iArr, MotionEvent motionEvent, int i) {
|
|
DifferentialMotionFlingController.calculateFlingVelocityThresholds(context2, iArr, motionEvent, i);
|
|
}
|
|
}, new DifferentialVelocityProvider() { // from class: androidx.core.view.DifferentialMotionFlingController$$ExternalSyntheticLambda1
|
|
@Override // androidx.core.view.DifferentialMotionFlingController.DifferentialVelocityProvider
|
|
public final float getCurrentVelocity(VelocityTracker velocityTracker, MotionEvent motionEvent, int i) {
|
|
float currentVelocity;
|
|
currentVelocity = DifferentialMotionFlingController.getCurrentVelocity(velocityTracker, motionEvent, i);
|
|
return currentVelocity;
|
|
}
|
|
});
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public DifferentialMotionFlingController(Context context, DifferentialMotionFlingTarget differentialMotionFlingTarget, FlingVelocityThresholdCalculator flingVelocityThresholdCalculator, DifferentialVelocityProvider differentialVelocityProvider) {
|
|
this.mLastProcessedAxis = -1;
|
|
this.mLastProcessedSource = -1;
|
|
this.mLastProcessedDeviceId = -1;
|
|
this.mFlingVelocityThresholds = new int[]{Integer.MAX_VALUE, 0};
|
|
this.mContext = context;
|
|
this.mTarget = differentialMotionFlingTarget;
|
|
this.mVelocityThresholdCalculator = flingVelocityThresholdCalculator;
|
|
this.mVelocityProvider = differentialVelocityProvider;
|
|
}
|
|
|
|
public void onMotionEvent(@NonNull MotionEvent motionEvent, int i) {
|
|
boolean calculateFlingVelocityThresholds = calculateFlingVelocityThresholds(motionEvent, i);
|
|
if (this.mFlingVelocityThresholds[0] == Integer.MAX_VALUE) {
|
|
VelocityTracker velocityTracker = this.mVelocityTracker;
|
|
if (velocityTracker != null) {
|
|
velocityTracker.recycle();
|
|
this.mVelocityTracker = null;
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
float currentVelocity = getCurrentVelocity(motionEvent, i) * this.mTarget.getScaledScrollFactor();
|
|
float signum = Math.signum(currentVelocity);
|
|
if (calculateFlingVelocityThresholds || (signum != Math.signum(this.mLastFlingVelocity) && signum != 0.0f)) {
|
|
this.mTarget.stopDifferentialMotionFling();
|
|
}
|
|
float abs = Math.abs(currentVelocity);
|
|
int[] iArr = this.mFlingVelocityThresholds;
|
|
if (abs < iArr[0]) {
|
|
return;
|
|
}
|
|
float max = Math.max(-r6, Math.min(currentVelocity, iArr[1]));
|
|
this.mLastFlingVelocity = this.mTarget.startDifferentialMotionFling(max) ? max : 0.0f;
|
|
}
|
|
|
|
private boolean calculateFlingVelocityThresholds(MotionEvent motionEvent, int i) {
|
|
int source = motionEvent.getSource();
|
|
int deviceId = motionEvent.getDeviceId();
|
|
if (this.mLastProcessedSource == source && this.mLastProcessedDeviceId == deviceId && this.mLastProcessedAxis == i) {
|
|
return false;
|
|
}
|
|
this.mVelocityThresholdCalculator.calculateFlingVelocityThresholds(this.mContext, this.mFlingVelocityThresholds, motionEvent, i);
|
|
this.mLastProcessedSource = source;
|
|
this.mLastProcessedDeviceId = deviceId;
|
|
this.mLastProcessedAxis = i;
|
|
return true;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static void calculateFlingVelocityThresholds(Context context, int[] iArr, MotionEvent motionEvent, int i) {
|
|
ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
|
|
iArr[0] = ViewConfigurationCompat.getScaledMinimumFlingVelocity(context, viewConfiguration, motionEvent.getDeviceId(), i, motionEvent.getSource());
|
|
iArr[1] = ViewConfigurationCompat.getScaledMaximumFlingVelocity(context, viewConfiguration, motionEvent.getDeviceId(), i, motionEvent.getSource());
|
|
}
|
|
|
|
private float getCurrentVelocity(MotionEvent motionEvent, int i) {
|
|
if (this.mVelocityTracker == null) {
|
|
this.mVelocityTracker = VelocityTracker.obtain();
|
|
}
|
|
return this.mVelocityProvider.getCurrentVelocity(this.mVelocityTracker, motionEvent, i);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static float getCurrentVelocity(VelocityTracker velocityTracker, MotionEvent motionEvent, int i) {
|
|
VelocityTrackerCompat.addMovement(velocityTracker, motionEvent);
|
|
VelocityTrackerCompat.computeCurrentVelocity(velocityTracker, 1000);
|
|
return VelocityTrackerCompat.getAxisVelocity(velocityTracker, i);
|
|
}
|
|
}
|