content: package androidx.transition;
  
  import android.graphics.Matrix;
  import android.util.Log;
  import android.view.View;
  import android.view.ViewParent;
  import java.lang.reflect.Field;
  import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.Method;
  
  class ViewUtilsBase {
      private static final String TAG = "ViewUtilsBase";
      private static final int VISIBILITY_MASK = 12;
      private static boolean sSetFrameFetched;
      private static Method sSetFrameMethod;
      private static Field sViewFlagsField;
      private static boolean sViewFlagsFieldFetched;
      private float[] mMatrixValues;
  
      ViewUtilsBase() {
      }
  
      private void fetchSetFrame() {
          if (!sSetFrameFetched) {
              Class<View> cls = View.class;
              try {
                  Method declaredMethod = cls.getDeclaredMethod("setFrame", new Class[]{Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE});
                  sSetFrameMethod = declaredMethod;
                  declaredMethod.setAccessible(true);
              } catch (NoSuchMethodException e) {
                  Log.i(TAG, "Failed to retrieve setFrame method", e);
              }
              sSetFrameFetched = true;
          }
      }
  
      public void clearNonTransitionAlpha(View view) {
          if (view.getVisibility() == 0) {
              view.setTag(R.id.save_non_transition_alpha, (Object) null);
          }
      }
  
      public float getTransitionAlpha(View view) {
          Float f = (Float) view.getTag(R.id.save_non_transition_alpha);
          return f != null ? view.getAlpha() / f.floatValue() : view.getAlpha();
      }
  
      public void saveNonTransitionAlpha(View view) {
          if (view.getTag(R.id.save_non_transition_alpha) == null) {
              view.setTag(R.id.save_non_transition_alpha, Float.valueOf(view.getAlpha()));
          }
      }
  
      public void setAnimationMatrix(View view, Matrix matrix) {
          if (matrix == null || matrix.isIdentity()) {
              view.setPivotX((float) (view.getWidth() / 2));
              view.setPivotY((float) (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) {
              float[] fArr2 = new float[9];
              fArr = fArr2;
              this.mMatrixValues = fArr2;
          }
          matrix.getValues(fArr);
          float f = fArr[3];
          float sqrt = ((float) Math.sqrt((double) (1.0f - (f * f)))) * ((float) (fArr[0] < 0.0f ? -1 : 1));
          float f2 = fArr[2];
          float f3 = fArr[5];
          view.setPivotX(0.0f);
          view.setPivotY(0.0f);
          view.setTranslationX(f2);
          view.setTranslationY(f3);
          view.setRotation((float) Math.toDegrees(Math.atan2((double) f, (double) sqrt)));
          view.setScaleX(fArr[0] / sqrt);
          view.setScaleY(fArr[4] / sqrt);
      }
  
      public void setLeftTopRightBottom(View v, int left, int top, int right, int bottom) {
          fetchSetFrame();
          Method method = sSetFrameMethod;
          if (method != null) {
              try {
                  method.invoke(v, new Object[]{Integer.valueOf(left), Integer.valueOf(top), Integer.valueOf(right), Integer.valueOf(bottom)});
              } catch (IllegalAccessException e) {
              } catch (InvocationTargetException e2) {
                  throw new RuntimeException(e2.getCause());
              }
          }
      }
  
      public void setTransitionAlpha(View view, float alpha) {
          Float f = (Float) view.getTag(R.id.save_non_transition_alpha);
          if (f != null) {
              view.setAlpha(f.floatValue() * alpha);
          } else {
              view.setAlpha(alpha);
          }
      }
  
      public void setTransitionVisibility(View view, int visibility) {
          if (!sViewFlagsFieldFetched) {
              try {
                  Field declaredField = View.class.getDeclaredField("mViewFlags");
                  sViewFlagsField = declaredField;
                  declaredField.setAccessible(true);
              } catch (NoSuchFieldException e) {
                  Log.i(TAG, "fetchViewFlagsField: ");
              }
              sViewFlagsFieldFetched = true;
          }
          Field field = sViewFlagsField;
          if (field != null) {
              try {
                  sViewFlagsField.setInt(view, (field.getInt(view) & -13) | visibility);
              } catch (IllegalAccessException e2) {
              }
          }
      }
  
      public void transformMatrixToGlobal(View view, Matrix matrix) {
          ViewParent parent = view.getParent();
          if (parent instanceof View) {
              View view2 = (View) parent;
              transformMatrixToGlobal(view2, matrix);
              matrix.preTranslate((float) (-view2.getScrollX()), (float) (-view2.getScrollY()));
          }
          matrix.preTranslate((float) view.getLeft(), (float) view.getTop());
          Matrix matrix2 = view.getMatrix();
          if (!matrix2.isIdentity()) {
              matrix.preConcat(matrix2);
          }
      }
  
      public void transformMatrixToLocal(View view, Matrix matrix) {
          ViewParent parent = view.getParent();
          if (parent instanceof View) {
              View view2 = (View) parent;
              transformMatrixToLocal(view2, matrix);
              matrix.postTranslate((float) view2.getScrollX(), (float) view2.getScrollY());
          }
          matrix.postTranslate((float) (-view.getLeft()), (float) (-view.getTop()));
          Matrix matrix2 = view.getMatrix();
          if (!matrix2.isIdentity()) {
              Matrix matrix3 = new Matrix();
              if (matrix2.invert(matrix3)) {
                  matrix.postConcat(matrix3);
              }
          }
      }
  }
  