discord-jadx/app/src/main/java/c/c/a/b0/g.java

124 lines
3.9 KiB
Java

package c.c.a.b0;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.RectF;
import android.os.Build;
import c.c.a.c;
import java.io.Closeable;
/* compiled from: Utils */
public final class g {
public static final PathMeasure a = new PathMeasure();
public static final Path b = new Path();
/* renamed from: c reason: collision with root package name */
public static final Path f258c = new Path();
public static final float[] d = new float[4];
public static final float e = ((float) (Math.sqrt(2.0d) / 2.0d));
public static float f = -1.0f;
public static void a(Path path, float f2, float f3, float f4) {
PathMeasure pathMeasure = a;
pathMeasure.setPath(path, false);
float length = pathMeasure.getLength();
if (f2 == 1.0f && f3 == 0.0f) {
c.a("applyTrimPathIfNeeded");
} else if (length < 1.0f || ((double) Math.abs((f3 - f2) - 1.0f)) < 0.01d) {
c.a("applyTrimPathIfNeeded");
} else {
float f5 = f2 * length;
float f6 = f3 * length;
float f7 = f4 * length;
float min = Math.min(f5, f6) + f7;
float max = Math.max(f5, f6) + f7;
if (min >= length && max >= length) {
min = (float) f.d(min, length);
max = (float) f.d(max, length);
}
if (min < 0.0f) {
min = (float) f.d(min, length);
}
if (max < 0.0f) {
max = (float) f.d(max, length);
}
int i = (min > max ? 1 : (min == max ? 0 : -1));
if (i == 0) {
path.reset();
c.a("applyTrimPathIfNeeded");
return;
}
if (i >= 0) {
min -= length;
}
Path path2 = b;
path2.reset();
pathMeasure.getSegment(min, max, path2, true);
if (max > length) {
Path path3 = f258c;
path3.reset();
pathMeasure.getSegment(0.0f, max % length, path3, true);
path2.addPath(path3);
} else if (min < 0.0f) {
Path path4 = f258c;
path4.reset();
pathMeasure.getSegment(min + length, length, path4, true);
path2.addPath(path4);
}
path.set(path2);
c.a("applyTrimPathIfNeeded");
}
}
public static void b(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (RuntimeException e2) {
throw e2;
} catch (Exception unused) {
}
}
}
public static float c() {
if (f == -1.0f) {
f = Resources.getSystem().getDisplayMetrics().density;
}
return f;
}
public static float d(Matrix matrix) {
float[] fArr = d;
fArr[0] = 0.0f;
fArr[1] = 0.0f;
float f2 = e;
fArr[2] = f2;
fArr[3] = f2;
matrix.mapPoints(fArr);
return (float) Math.hypot((double) (fArr[2] - fArr[0]), (double) (fArr[3] - fArr[1]));
}
public static Bitmap e(Bitmap bitmap, int i, int i2) {
if (bitmap.getWidth() == i && bitmap.getHeight() == i2) {
return bitmap;
}
Bitmap createScaledBitmap = Bitmap.createScaledBitmap(bitmap, i, i2, true);
bitmap.recycle();
return createScaledBitmap;
}
public static void f(Canvas canvas, RectF rectF, Paint paint, int i) {
if (Build.VERSION.SDK_INT < 23) {
canvas.saveLayer(rectF, paint, i);
} else {
canvas.saveLayer(rectF, paint);
}
c.a("Utils#saveLayer");
}
}