mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-21 21:33:21 +01:00
190 lines
6.5 KiB
Java
190 lines
6.5 KiB
Java
package androidx.transition;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.graphics.Matrix;
|
|
import android.util.Log;
|
|
import android.view.View;
|
|
import androidx.annotation.DoNotInline;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RequiresApi;
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.Method;
|
|
import okio.Buffer$$ExternalSyntheticBUOutline0;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes14.dex */
|
|
class ViewUtilsApi19 {
|
|
private static final String TAG = "ViewUtilsApi19";
|
|
private static final int VISIBILITY_MASK = 12;
|
|
private static boolean sSetFrameFetched = false;
|
|
private static Method sSetFrameMethod = null;
|
|
private static boolean sTryHiddenTransitionAlpha = true;
|
|
private static Field sViewFlagsField;
|
|
private static boolean sViewFlagsFieldFetched;
|
|
private float[] mMatrixValues;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@RequiresApi(29)
|
|
public static class Api29Impl {
|
|
private Api29Impl() {
|
|
}
|
|
|
|
@DoNotInline
|
|
public static float getTransitionAlpha(View view) {
|
|
return view.getTransitionAlpha();
|
|
}
|
|
|
|
@DoNotInline
|
|
public static void setTransitionAlpha(View view, float f) {
|
|
view.setTransitionAlpha(f);
|
|
}
|
|
}
|
|
|
|
@SuppressLint({"PrivateApi", "SoonBlockedPrivateApi"})
|
|
private void fetchSetFrame() {
|
|
if (sSetFrameFetched) {
|
|
return;
|
|
}
|
|
try {
|
|
Class cls = Integer.TYPE;
|
|
Method declaredMethod = View.class.getDeclaredMethod("setFrame", cls, cls, cls, cls);
|
|
sSetFrameMethod = declaredMethod;
|
|
declaredMethod.setAccessible(true);
|
|
} catch (NoSuchMethodException e) {
|
|
Log.i(TAG, "Failed to retrieve setFrame method", e);
|
|
}
|
|
sSetFrameFetched = true;
|
|
}
|
|
|
|
@SuppressLint({"NewApi"})
|
|
public float getTransitionAlpha(@NonNull View view) {
|
|
if (sTryHiddenTransitionAlpha) {
|
|
try {
|
|
return Api29Impl.getTransitionAlpha(view);
|
|
} catch (NoSuchMethodError unused) {
|
|
sTryHiddenTransitionAlpha = false;
|
|
}
|
|
}
|
|
return view.getAlpha();
|
|
}
|
|
|
|
public void setAnimationMatrix(@NonNull View view, @Nullable Matrix matrix) {
|
|
if (matrix == null || matrix.isIdentity()) {
|
|
view.setPivotX(view.getWidth() / 2);
|
|
view.setPivotY(view.getHeight() / 2);
|
|
view.setTranslationX(0.0f);
|
|
view.setTranslationY(0.0f);
|
|
view.setScaleX(1.0f);
|
|
view.setScaleY(1.0f);
|
|
view.setRotation(0.0f);
|
|
return;
|
|
}
|
|
float[] fArr = this.mMatrixValues;
|
|
if (fArr == null) {
|
|
fArr = new float[9];
|
|
this.mMatrixValues = fArr;
|
|
}
|
|
matrix.getValues(fArr);
|
|
float f = fArr[3];
|
|
float sqrt = ((float) Math.sqrt(1.0f - (f * f))) * (fArr[0] < 0.0f ? -1 : 1);
|
|
float degrees = (float) Math.toDegrees(Math.atan2(f, sqrt));
|
|
float f2 = fArr[0] / sqrt;
|
|
float f3 = fArr[4] / sqrt;
|
|
float f4 = fArr[2];
|
|
float f5 = fArr[5];
|
|
view.setPivotX(0.0f);
|
|
view.setPivotY(0.0f);
|
|
view.setTranslationX(f4);
|
|
view.setTranslationY(f5);
|
|
view.setRotation(degrees);
|
|
view.setScaleX(f2);
|
|
view.setScaleY(f3);
|
|
}
|
|
|
|
@SuppressLint({"BanUncheckedReflection"})
|
|
public void setLeftTopRightBottom(@NonNull View view, int i, int i2, int i3, int i4) {
|
|
fetchSetFrame();
|
|
Method method = sSetFrameMethod;
|
|
if (method != null) {
|
|
try {
|
|
method.invoke(view, Integer.valueOf(i), Integer.valueOf(i2), Integer.valueOf(i3), Integer.valueOf(i4));
|
|
} catch (IllegalAccessException unused) {
|
|
} catch (InvocationTargetException e) {
|
|
Buffer$$ExternalSyntheticBUOutline0.m(e.getCause());
|
|
}
|
|
}
|
|
}
|
|
|
|
@SuppressLint({"NewApi"})
|
|
public void setTransitionAlpha(@NonNull View view, float f) {
|
|
if (sTryHiddenTransitionAlpha) {
|
|
try {
|
|
Api29Impl.setTransitionAlpha(view, f);
|
|
return;
|
|
} catch (NoSuchMethodError unused) {
|
|
sTryHiddenTransitionAlpha = false;
|
|
}
|
|
}
|
|
view.setAlpha(f);
|
|
}
|
|
|
|
@SuppressLint({"SoonBlockedPrivateApi"})
|
|
public void setTransitionVisibility(@NonNull View view, int i) {
|
|
if (!sViewFlagsFieldFetched) {
|
|
try {
|
|
Field declaredField = View.class.getDeclaredField("mViewFlags");
|
|
sViewFlagsField = declaredField;
|
|
declaredField.setAccessible(true);
|
|
} catch (NoSuchFieldException unused) {
|
|
Log.i(TAG, "fetchViewFlagsField: ");
|
|
}
|
|
sViewFlagsFieldFetched = true;
|
|
}
|
|
Field field = sViewFlagsField;
|
|
if (field != null) {
|
|
try {
|
|
sViewFlagsField.setInt(view, (field.getInt(view) & (-13)) | i);
|
|
} catch (IllegalAccessException unused2) {
|
|
}
|
|
}
|
|
}
|
|
|
|
public void transformMatrixToGlobal(@NonNull View view, @NonNull Matrix matrix) {
|
|
Object parent = view.getParent();
|
|
if (parent instanceof View) {
|
|
transformMatrixToGlobal((View) parent, matrix);
|
|
matrix.preTranslate(-r0.getScrollX(), -r0.getScrollY());
|
|
}
|
|
matrix.preTranslate(view.getLeft(), view.getTop());
|
|
Matrix matrix2 = view.getMatrix();
|
|
if (matrix2.isIdentity()) {
|
|
return;
|
|
}
|
|
matrix.preConcat(matrix2);
|
|
}
|
|
|
|
public void transformMatrixToLocal(@NonNull View view, @NonNull Matrix matrix) {
|
|
Object parent = view.getParent();
|
|
if (parent instanceof View) {
|
|
transformMatrixToLocal((View) parent, matrix);
|
|
matrix.postTranslate(r0.getScrollX(), r0.getScrollY());
|
|
}
|
|
matrix.postTranslate(-view.getLeft(), -view.getTop());
|
|
Matrix matrix2 = view.getMatrix();
|
|
if (matrix2.isIdentity()) {
|
|
return;
|
|
}
|
|
Matrix matrix3 = new Matrix();
|
|
if (matrix2.invert(matrix3)) {
|
|
matrix.postConcat(matrix3);
|
|
}
|
|
}
|
|
|
|
public void clearNonTransitionAlpha(@NonNull View view) {
|
|
}
|
|
|
|
public void saveNonTransitionAlpha(@NonNull View view) {
|
|
}
|
|
}
|