ADD week 5
This commit is contained in:
57
02-Easy5/E5/sources/androidx/transition/ImageViewUtils.java
Normal file
57
02-Easy5/E5/sources/androidx/transition/ImageViewUtils.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package androidx.transition;
|
||||
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.widget.ImageView;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ImageViewUtils {
|
||||
private static Field sDrawMatrixField = null;
|
||||
private static boolean sDrawMatrixFieldFetched = false;
|
||||
private static boolean sTryHiddenAnimateTransform = true;
|
||||
|
||||
static void animateTransform(ImageView imageView, Matrix matrix) {
|
||||
if (Build.VERSION.SDK_INT >= 29) {
|
||||
imageView.animateTransform(matrix);
|
||||
return;
|
||||
}
|
||||
if (matrix == null) {
|
||||
Drawable drawable = imageView.getDrawable();
|
||||
if (drawable != null) {
|
||||
drawable.setBounds(0, 0, (imageView.getWidth() - imageView.getPaddingLeft()) - imageView.getPaddingRight(), (imageView.getHeight() - imageView.getPaddingTop()) - imageView.getPaddingBottom());
|
||||
imageView.invalidate();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
hiddenAnimateTransform(imageView, matrix);
|
||||
}
|
||||
|
||||
private static void hiddenAnimateTransform(ImageView imageView, Matrix matrix) {
|
||||
if (sTryHiddenAnimateTransform) {
|
||||
try {
|
||||
imageView.animateTransform(matrix);
|
||||
} catch (NoSuchMethodError unused) {
|
||||
sTryHiddenAnimateTransform = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void fetchDrawMatrixField() {
|
||||
if (sDrawMatrixFieldFetched) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Field declaredField = ImageView.class.getDeclaredField("mDrawMatrix");
|
||||
sDrawMatrixField = declaredField;
|
||||
declaredField.setAccessible(true);
|
||||
} catch (NoSuchFieldException unused) {
|
||||
}
|
||||
sDrawMatrixFieldFetched = true;
|
||||
}
|
||||
|
||||
private ImageViewUtils() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user