static float getRotationY(View view) { return view.getRotationY(); }
@TargetApi(HONEYCOMB) public S hasRotationY(float rotation) { isNotNull(); float actualRotation = actual.getRotationY(); assertThat(actualRotation) // .overridingErrorMessage("Expected y rotation <%s> but was <%s>", rotation, actualRotation) // .isEqualTo(rotation); return myself; }
/** 初始化数据 */ private void prepare(CoordinatorLayout parent, View child, View dependency) { mDependStartX = (int) dependency.getX(); mDependStartY = (int) dependency.getY(); mDependStartWidth = dependency.getWidth(); mDependStartHeight = dependency.getHeight(); mStartX = (int) child.getX(); mStartY = (int) child.getY(); mStartWidth = child.getWidth(); mStartHeight = child.getHeight(); mStartAlpha = child.getAlpha(); mStartRotateX = child.getRotationX(); mStartRotateY = child.getRotationY(); //特殊处理y方向变化 if (mDependTargetY == UNSPECIFIED_INT && dependency instanceof AppBarLayout) { mDependTargetY = ((AppBarLayout) dependency).getTotalScrollRange(); } // 背景颜色渐变 if (child.getBackground() instanceof ColorDrawable) mStartBackgroundColor = ((ColorDrawable) child.getBackground()).getColor(); // 自定义动画 if (mAnimationId != 0) { mAnimation = AnimationUtils.loadAnimation(child.getContext(), mAnimationId); mAnimation.initialize(child.getWidth(), child.getHeight(), parent.getWidth(), parent.getHeight()); } // 兼容5.0以上的沉浸模式 if (Build.VERSION.SDK_INT > 16 && parent.getFitsSystemWindows() && targetY != UNSPECIFIED_INT) { targetY += getStatusBarHeight(parent.getContext()); } isPrepared = true; }
@Test public void rotationY() { view.setRotationY(20f); assertThat(view.getRotationY()).isEqualTo(20f); }
case ROTATION_Y: return v.getRotationY(); case SCALE_X:
public Transforms(View view) { translationX = view.getTranslationX(); translationY = view.getTranslationY(); translationZ = ViewUtils.getTranslationZ(view); scaleX = view.getScaleX(); scaleY = view.getScaleY(); rotationX = view.getRotationX(); rotationY = view.getRotationY(); rotationZ = view.getRotation(); }
static float getRotationY(View view) { return view.getRotationY(); }
@Override public final float getRotation(@NonNull final Axis axis, @NonNull final AbstractItem item) { Condition.INSTANCE.ensureNotNull(axis, "The axis may not be null"); Condition.INSTANCE.ensureNotNull(item, "The view may not be null"); View view = item.getView(); if (getOrientationInvariantAxis(axis) == Axis.DRAGGING_AXIS) { return view.getRotationY(); } else { return view.getRotationX(); } }
case ROTATION_Y: return v.getRotationY(); case SCALE_X:
@Override public float getRotationY(View view) { return view.getRotationY(); }
static float getRotationY(View view) { return view.getRotationY(); }
static float getRotationY(View view) { return view.getRotationY(); }
public static float getRotationY(View view) { return view.getRotationY(); }
@Override protected float setViewElevation(View itemView, float targetOffset) { final float ele = Math.max(Math.abs(itemView.getRotationX()), Math.abs(itemView.getRotationY())) * MAX_ELEVATION / 360; return MAX_ELEVATION - ele; }
private void updateRotationValues(boolean notifyListener) { currentXRotation = rootView.getRotationX(); currentYRotation = rootView.getRotationY(); if (notifyListener) { notifyListenerRotationChanged(); } }
@TargetApi(HONEYCOMB) public S hasRotationY(float rotation) { isNotNull(); float actualRotation = actual.getRotationY(); assertThat(actualRotation) // .overridingErrorMessage("Expected y rotation <%s> but was <%s>", rotation, actualRotation) // .isEqualTo(rotation); return myself; }
@Override public Animator getAnimationFor(AnimationBody animationBody, View view) { final float startRotation = view.getRotationY(); final float endRotation = startRotation + 180f; final PropertyValuesHolder rotationPVH = PropertyValuesHolder.ofFloat(View.ROTATION_Y, startRotation, endRotation); final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(view, rotationPVH); return animation; } }
private void fitRotation() { AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setDuration(FIT_ANIM_TIME); animatorSet.setInterpolator(new FastOutSlowInInterpolator()); ArrayList<Animator> animators = new ArrayList<>(); if (shouldRotateY()) { animators.add(ObjectAnimator.ofFloat(rootView, View.ROTATION_Y, getRequiredRotation(rootView.getRotationY()))); } if (shouldRotateX()) { animators.add(ObjectAnimator.ofFloat(rootView, View.ROTATION_X, getRequiredRotation(rootView.getRotationX()))); } animatorSet.playTogether(animators); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); updateRotationValues(true); } }); animatorSet.start(); // Reset max values to calculate again on touch down maxDistanceX = NULL_INT; maxDistanceY = NULL_INT; }
/** * Rotates once around in given direction */ public void rotateOnce() { float toDegree; if (rotation == ROTATE_X) { toDegree = rootView.getRotationX(); } else if (rotation == ROTATE_Y) { toDegree = rootView.getRotationY(); } else { toDegree = rootView.getRotation(); } toDegree += 180; rotate(rotation, toDegree); }
private void handleRotation() { if (shouldRotateX()) { float newXRotation = (rootView.getRotationX() + (oldY - currentY)) % 360; rootView.setRotationX(newXRotation); currentXRotation = newXRotation; oldY = currentY; } if (shouldRotateY()) { float newYRotation; if (isInFrontArea(currentXRotation)) { newYRotation = (rootView.getRotationY() + (currentX - oldX)) % 360; } else { newYRotation = (rootView.getRotationY() - (currentX - oldX)) % 360; } rootView.setRotationY(newYRotation); currentYRotation = newYRotation; oldX = currentX; } }