List of usage examples for android.view View getRotation
@ViewDebug.ExportedProperty(category = "drawing") public float getRotation()
From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java
private HashMap<Integer, String> processStickerAnnotations(ViewGroup viewGroup) { HashMap<Integer, String> allStickerAnnotations = new HashMap<>(); if (viewGroup != null) { for (int i = 0; i < viewGroup.getChildCount(); ++i) { View child = viewGroup.getChildAt(i); if (child instanceof StickerAnnotationImageView) { StickerAnnotationImageView stickerAnnotationImageView = (StickerAnnotationImageView) child; int annotationImageResource = stickerAnnotationImageView.getImageResourceId(); float getX = child.getX(); float getY = child.getY(); int width = child.getWidth(); int height = child.getHeight(); float rotation = child.getRotation(); String value = annotationImageResource + Utils.SEPARATOR + getX + Utils.SEPARATOR + getY + Utils.SEPARATOR + width + Utils.SEPARATOR + height + Utils.SEPARATOR + rotation; allStickerAnnotations.put(i, value); }//from w ww. j a va 2s . co m } } return allStickerAnnotations; }
From source file:app.umitems.greenclock.widget.sgv.StaggeredGridView.java
/** * Handle setting up the animators of child views when the animation is invoked by a change * in the adapter. This method has a side effect of translating view positions in preparation * for the animations.//from ww w .j a v a 2 s .c o m */ private List<Animator> addFlyInAllViewsAnimators(List<Animator> animators) { final int childCount = getChildCount(); if (childCount == 0) { return null; } if (animators == null) { animators = new ArrayList<Animator>(); } for (int i = 0; i < childCount; i++) { final int animationDelay = i * ANIMATION_DELAY_IN_MS; final View childToAnimate = getChildAt(i); // Start all views from below the bottom of this grid and animate them upwards. This // is done simply by translating the current view's vertical position by the height // of the entire grid. float yTranslation = getHeight(); float rotation = SgvAnimationHelper.ANIMATION_ROTATION_DEGREES; if (mIsCurrentAnimationCanceled) { // If mIsAnimationCanceled is true, then this is not the first time that this // animation is running. For this particular case, we should resume from where // the previous animation left off, rather than resetting translation and rotation. yTranslation = childToAnimate.getTranslationY(); rotation = childToAnimate.getRotation(); } SgvAnimationHelper.addTranslationRotationAnimators(animators, childToAnimate, 0 /* xTranslation */, (int) yTranslation, rotation, animationDelay); } return animators; }
From source file:app.umitems.greenclock.widget.sgv.StaggeredGridView.java
/** * Animations to update the views on screen to their new positions. For new views that aren't * currently on screen, animate them in using the specified animationInMode. *//*from w w w . j a v a2 s .c o m*/ private List<Animator> addUpdateViewPositionsAnimators(List<Animator> animators, boolean cascadeAnimation, AnimationIn animationInMode, int startDelay) { final int childCount = getChildCount(); if (childCount == 0) { return null; } if (animators == null) { animators = new ArrayList<Animator>(); } int viewsAnimated = 0; for (int i = 0; i < childCount; i++) { final View childToAnimate = getChildAt(i); if (mViewsToAnimateOut.contains(childToAnimate)) { // If the stale views are still animating, then they are still laid out, so // getChildCount() would've accounted for them. Since they have their own set // of animations to play, we'll skip over them in this loop. continue; } // Use progressive animation delay to create the staggered effect of animating // views. This is done by having each view delay their animation by // ANIMATION_DELAY_IN_MS after the animation of the previous view. int animationDelay = startDelay + (cascadeAnimation ? viewsAnimated * ANIMATION_DELAY_IN_MS : 0); // Figure out whether a view with this item ID existed before final LayoutParams lp = (LayoutParams) childToAnimate.getLayoutParams(); final ViewRectPair viewRectPair = mChildRectsForAnimation.get(lp.id); final int xTranslation; final int yTranslation; // If there is a valid {@link Rect} for the view with this newId, then // setup an animation. if (viewRectPair != null && viewRectPair.rect != null) { // In the special case where the items are explicitly fading, we don't want to do // any of the translations. if (animationInMode == AnimationIn.FADE) { SgvAnimationHelper.addFadeAnimators(animators, childToAnimate, 0 /* start alpha */, 1.0f /* end alpha */, animationDelay); continue; } final Rect oldRect = viewRectPair.rect; // Since the view already exists, translate it to its new position. // Reset the child back to its previous position given by oldRect if the child // has not already been translated. If the child has been translated, use the // current translated values, as this child may be in the middle of a previous // animation, so we don't want to simply force it to new location. xTranslation = oldRect.left - childToAnimate.getLeft(); yTranslation = oldRect.top - childToAnimate.getTop(); final float rotation = childToAnimate.getRotation(); // First set the translation X and Y. The current translation might be out of date. childToAnimate.setTranslationX(xTranslation); childToAnimate.setTranslationY(yTranslation); if (xTranslation == 0 && yTranslation == 0 && rotation == 0) { // Bail early if this view doesn't need to be translated. continue; } SgvAnimationHelper.addTranslationRotationAnimators(animators, childToAnimate, xTranslation, yTranslation, rotation, animationDelay); } else { // If this view was not present before the data updated, rather than just flashing // the view into its designated position, fly it up from the bottom. xTranslation = 0; yTranslation = (animationInMode == AnimationIn.FLY_IN_NEW_VIEWS) ? getHeight() : 0; // Since this is a new view coming in, add additional delays so that these IN // animations start after all the OUT animations have been played. animationDelay += SgvAnimationHelper.getDefaultAnimationDuration(); childToAnimate.setTranslationX(xTranslation); childToAnimate.setTranslationY(yTranslation); switch (animationInMode) { case FLY_IN_NEW_VIEWS: SgvAnimationHelper.addTranslationRotationAnimators(animators, childToAnimate, xTranslation, yTranslation, SgvAnimationHelper.ANIMATION_ROTATION_DEGREES, animationDelay); break; case SLIDE_IN_NEW_VIEWS: // Bias towards sliding right, but depending on the column that this view // is laid out in, slide towards the nearest side edge. int startTranslation = (int) (childToAnimate.getWidth() * 1.5); if (lp.column < (mColCount / 2)) { startTranslation = -startTranslation; } SgvAnimationHelper.addSlideInFromRightAnimators(animators, childToAnimate, startTranslation, animationDelay); break; case EXPAND_NEW_VIEWS: case EXPAND_NEW_VIEWS_NO_CASCADE: if (i == 0) { // Initially set the alpha of this view to be invisible, then fade in. childToAnimate.setAlpha(0); // Create animators that translate the view back to translation = 0 // which would be its new layout position final int offset = -1 * childToAnimate.getHeight(); SgvAnimationHelper.addXYTranslationAnimators(animators, childToAnimate, 0 /* xTranslation */, offset, animationDelay); SgvAnimationHelper.addFadeAnimators(animators, childToAnimate, 0 /* start alpha */, 1.0f /* end alpha */, animationDelay); } else { SgvAnimationHelper.addExpandInAnimators(animators, childToAnimate, animationDelay); } break; case FADE: SgvAnimationHelper.addFadeAnimators(animators, childToAnimate, 0 /* start alpha */, 1.0f /* end alpha */, animationDelay); break; default: continue; } } viewsAnimated++; } return animators; }
From source file:com.deepak.myclock.widget.sgv.StaggeredGridView.java
/** * Animations to update the views on screen to their new positions. For new views that aren't * currently on screen, animate them in using the specified animationInMode. *///from w w w .j av a 2 s . co m private List<Animator> addUpdateViewPositionsAnimators(List<Animator> animators, boolean cascadeAnimation, SgvAnimationHelper.AnimationIn animationInMode, int startDelay) { final int childCount = getChildCount(); if (childCount == 0) { return null; } if (animators == null) { animators = new ArrayList<Animator>(); } int viewsAnimated = 0; for (int i = 0; i < childCount; i++) { final View childToAnimate = getChildAt(i); if (mViewsToAnimateOut.contains(childToAnimate)) { // If the stale views are still animating, then they are still laid out, so // getChildCount() would've accounted for them. Since they have their own set // of animations to play, we'll skip over them in this loop. continue; } // Use progressive animation delay to create the staggered effect of animating // views. This is done by having each view delay their animation by // ANIMATION_DELAY_IN_MS after the animation of the previous view. int animationDelay = startDelay + (cascadeAnimation ? viewsAnimated * ANIMATION_DELAY_IN_MS : 0); // Figure out whether a view with this item ID existed before final LayoutParams lp = (LayoutParams) childToAnimate.getLayoutParams(); final ViewRectPair viewRectPair = mChildRectsForAnimation.get(lp.id); final int xTranslation; final int yTranslation; // If there is a valid {@link Rect} for the view with this newId, then // setup an animation. if (viewRectPair != null && viewRectPair.rect != null) { // In the special case where the items are explicitly fading, we don't want to do // any of the translations. if (animationInMode == SgvAnimationHelper.AnimationIn.FADE) { SgvAnimationHelper.addFadeAnimators(animators, childToAnimate, 0 /* start alpha */, 1.0f /* end alpha */, animationDelay); continue; } final Rect oldRect = viewRectPair.rect; // Since the view already exists, translate it to its new position. // Reset the child back to its previous position given by oldRect if the child // has not already been translated. If the child has been translated, use the // current translated values, as this child may be in the middle of a previous // animation, so we don't want to simply force it to new location. xTranslation = oldRect.left - childToAnimate.getLeft(); yTranslation = oldRect.top - childToAnimate.getTop(); final float rotation = childToAnimate.getRotation(); // First set the translation X and Y. The current translation might be out of date. childToAnimate.setTranslationX(xTranslation); childToAnimate.setTranslationY(yTranslation); if (xTranslation == 0 && yTranslation == 0 && rotation == 0) { // Bail early if this view doesn't need to be translated. continue; } SgvAnimationHelper.addTranslationRotationAnimators(animators, childToAnimate, xTranslation, yTranslation, rotation, animationDelay); } else { // If this view was not present before the data updated, rather than just flashing // the view into its designated position, fly it up from the bottom. xTranslation = 0; yTranslation = (animationInMode == SgvAnimationHelper.AnimationIn.FLY_IN_NEW_VIEWS) ? getHeight() : 0; // Since this is a new view coming in, add additional delays so that these IN // animations start after all the OUT animations have been played. animationDelay += SgvAnimationHelper.getDefaultAnimationDuration(); childToAnimate.setTranslationX(xTranslation); childToAnimate.setTranslationY(yTranslation); switch (animationInMode) { case FLY_IN_NEW_VIEWS: SgvAnimationHelper.addTranslationRotationAnimators(animators, childToAnimate, xTranslation, yTranslation, SgvAnimationHelper.ANIMATION_ROTATION_DEGREES, animationDelay); break; case SLIDE_IN_NEW_VIEWS: // Bias towards sliding right, but depending on the column that this view // is laid out in, slide towards the nearest side edge. int startTranslation = (int) (childToAnimate.getWidth() * 1.5); if (lp.column < (mColCount / 2)) { startTranslation = -startTranslation; } SgvAnimationHelper.addSlideInFromRightAnimators(animators, childToAnimate, startTranslation, animationDelay); break; case EXPAND_NEW_VIEWS: case EXPAND_NEW_VIEWS_NO_CASCADE: if (i == 0) { // Initially set the alpha of this view to be invisible, then fade in. childToAnimate.setAlpha(0); // Create animators that translate the view back to translation = 0 // which would be its new layout position final int offset = -1 * childToAnimate.getHeight(); SgvAnimationHelper.addXYTranslationAnimators(animators, childToAnimate, 0 /* xTranslation */, offset, animationDelay); SgvAnimationHelper.addFadeAnimators(animators, childToAnimate, 0 /* start alpha */, 1.0f /* end alpha */, animationDelay); } else { SgvAnimationHelper.addExpandInAnimators(animators, childToAnimate, animationDelay); } break; case FADE: SgvAnimationHelper.addFadeAnimators(animators, childToAnimate, 0 /* start alpha */, 1.0f /* end alpha */, animationDelay); break; default: continue; } } viewsAnimated++; } return animators; }