Rabbit-R1/android (non root)/java/sources/androidx/constraintlayout/motion/utils/Easing.java

180 lines
5.8 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package androidx.constraintlayout.motion.utils;
import android.util.Log;
import java.util.Arrays;
import tech.rabbit.r1launcher.BuildConfig;
/* loaded from: classes.dex */
public class Easing {
private static final String ACCELERATE = "cubic(0.4, 0.05, 0.8, 0.7)";
private static final String DECELERATE = "cubic(0.0, 0.0, 0.2, 0.95)";
private static final String LINEAR = "cubic(1, 1, 0, 0)";
private static final String STANDARD = "cubic(0.4, 0.0, 0.2, 1)";
String str = "identity";
static Easing sDefault = new Easing();
private static final String STANDARD_NAME = "standard";
private static final String ACCELERATE_NAME = "accelerate";
private static final String DECELERATE_NAME = "decelerate";
private static final String LINEAR_NAME = "linear";
public static String[] NAMED_EASING = {STANDARD_NAME, ACCELERATE_NAME, DECELERATE_NAME, LINEAR_NAME};
public double get(double d) {
return d;
}
public double getDiff(double d) {
return 1.0d;
}
public String toString() {
return this.str;
}
public static Easing getInterpolator(String str) {
if (str == null) {
return null;
}
if (str.startsWith("cubic")) {
return new CubicEasing(str);
}
str.hashCode();
char c = 65535;
switch (str.hashCode()) {
case -1354466595:
if (str.equals(ACCELERATE_NAME)) {
c = 0;
break;
}
break;
case -1263948740:
if (str.equals(DECELERATE_NAME)) {
c = 1;
break;
}
break;
case -1102672091:
if (str.equals(LINEAR_NAME)) {
c = 2;
break;
}
break;
case 1312628413:
if (str.equals(STANDARD_NAME)) {
c = 3;
break;
}
break;
}
switch (c) {
case 0:
return new CubicEasing(ACCELERATE);
case 1:
return new CubicEasing(DECELERATE);
case 2:
return new CubicEasing(LINEAR);
case 3:
return new CubicEasing(STANDARD);
default:
Log.e("ConstraintSet", "transitionEasing syntax error syntax:transitionEasing=\"cubic(1.0,0.5,0.0,0.6)\" or " + Arrays.toString(NAMED_EASING));
return sDefault;
}
}
/* loaded from: classes.dex */
static class CubicEasing extends Easing {
private static double d_error = 1.0E-4d;
private static double error = 0.01d;
double x1;
double x2;
double y1;
double y2;
private double getDiffX(double d) {
double d2 = 1.0d - d;
double d3 = this.x1;
double d4 = this.x2;
return (d2 * 3.0d * d2 * d3) + (d2 * 6.0d * d * (d4 - d3)) + (3.0d * d * d * (1.0d - d4));
}
private double getDiffY(double d) {
double d2 = 1.0d - d;
double d3 = this.y1;
double d4 = this.y2;
return (d2 * 3.0d * d2 * d3) + (d2 * 6.0d * d * (d4 - d3)) + (3.0d * d * d * (1.0d - d4));
}
private double getX(double d) {
double d2 = 1.0d - d;
double d3 = 3.0d * d2;
return (this.x1 * d2 * d3 * d) + (this.x2 * d3 * d * d) + (d * d * d);
}
private double getY(double d) {
double d2 = 1.0d - d;
double d3 = 3.0d * d2;
return (this.y1 * d2 * d3 * d) + (this.y2 * d3 * d * d) + (d * d * d);
}
void setup(double d, double d2, double d3, double d4) {
this.x1 = d;
this.y1 = d2;
this.x2 = d3;
this.y2 = d4;
}
CubicEasing(String str) {
this.str = str;
int indexOf = str.indexOf(40);
int indexOf2 = str.indexOf(44, indexOf);
this.x1 = Double.parseDouble(str.substring(indexOf + 1, indexOf2).trim());
int i = indexOf2 + 1;
int indexOf3 = str.indexOf(44, i);
this.y1 = Double.parseDouble(str.substring(i, indexOf3).trim());
int i2 = indexOf3 + 1;
int indexOf4 = str.indexOf(44, i2);
this.x2 = Double.parseDouble(str.substring(i2, indexOf4).trim());
int i3 = indexOf4 + 1;
this.y2 = Double.parseDouble(str.substring(i3, str.indexOf(41, i3)).trim());
}
public CubicEasing(double d, double d2, double d3, double d4) {
setup(d, d2, d3, d4);
}
@Override // androidx.constraintlayout.motion.utils.Easing
public double getDiff(double d) {
double d2 = 0.5d;
double d3 = 0.5d;
while (d2 > d_error) {
d2 *= 0.5d;
d3 = getX(d3) < d ? d3 + d2 : d3 - d2;
}
double d4 = d3 - d2;
double d5 = d3 + d2;
return (getY(d5) - getY(d4)) / (getX(d5) - getX(d4));
}
@Override // androidx.constraintlayout.motion.utils.Easing
public double get(double d) {
if (d <= BuildConfig.SENTRY_SAMPLE_RATE) {
return BuildConfig.SENTRY_SAMPLE_RATE;
}
if (d >= 1.0d) {
return 1.0d;
}
double d2 = 0.5d;
double d3 = 0.5d;
while (d2 > error) {
d2 *= 0.5d;
d3 = getX(d3) < d ? d3 + d2 : d3 - d2;
}
double d4 = d3 - d2;
double x = getX(d4);
double d5 = d3 + d2;
double x2 = getX(d5);
double y = getY(d4);
return (((getY(d5) - y) * (d - x)) / (x2 - x)) + y;
}
}
}