Java Code Examples for android.view.animation.AnimationSet#getDuration()
The following examples show how to use
android.view.animation.AnimationSet#getDuration() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnimationService.java From Twire with GNU General Public License v3.0 | 5 votes |
/** * Hides every view in a RecyclerView to simulate clearing the RecyclerView * returns how long the animation takes to complete. * Returns -1 if there is nothing to animate */ public static int animateFakeClearing(int lastVisibleItemPosition, int firstVisibleItemPosition, AutoSpanRecyclerView aRecyclerView, Animation.AnimationListener animationListener, boolean includeTranslation) { final int DELAY_BETWEEN = 50; int clearingDuration = 0; int startPositionCol = getColumnPosFromIndex(firstVisibleItemPosition, aRecyclerView); int startPositionRow = getRowPosFromIndex(firstVisibleItemPosition, aRecyclerView); for (int i = lastVisibleItemPosition; i >= firstVisibleItemPosition; i--) { final View VIEW = aRecyclerView.getChildAt(lastVisibleItemPosition - i); int positionColumnDistance = Math.abs(getColumnPosFromIndex(i, aRecyclerView) - startPositionCol); int positionRowDistance = Math.abs(getRowPosFromIndex(i, aRecyclerView) - startPositionRow); int delay = (positionColumnDistance + positionRowDistance) * DELAY_BETWEEN + 1; AnimationSet mHideAnimations = AnimationService.startAlphaHideAnimation(delay, VIEW, includeTranslation); if (mHideAnimations == null) { return -1; } int hideAnimationDuration = (int) mHideAnimations.getDuration(); if (hideAnimationDuration + delay > clearingDuration) { clearingDuration = hideAnimationDuration + delay; } // If the view is the last to animate, then start the intent when the animation finishes. if (i == lastVisibleItemPosition && animationListener != null) { mHideAnimations.setAnimationListener(animationListener); } } return clearingDuration; }
Example 2
Source File: AnimationService.java From Pocket-Plays-for-Twitch with GNU General Public License v3.0 | 5 votes |
/** * Hides every view in a RecyclerView to simulate clearing the RecyclerView * returns how long the animation takes to complete. * Returns -1 if there is nothing to animate */ public static int animateFakeClearing(int lastVisibleItemPosition, int firstVisibleItemPosition, AutoSpanRecyclerView aRecyclerView, Animation.AnimationListener animationListener, boolean includeTranslation) { final int DELAY_BETWEEN = 50; int clearingDuration = 0; int startPositionCol = getColumnPosFromIndex(firstVisibleItemPosition, aRecyclerView); int startPositionRow = getRowPosFromIndex(firstVisibleItemPosition, aRecyclerView); for(int i = lastVisibleItemPosition; i >= firstVisibleItemPosition; i--) { final View VIEW = aRecyclerView.getChildAt(lastVisibleItemPosition - i); int positionColumnDistance = Math.abs(getColumnPosFromIndex(i, aRecyclerView) - startPositionCol); int positionRowDistance = Math.abs(getRowPosFromIndex(i, aRecyclerView) - startPositionRow); int delay = (positionColumnDistance + positionRowDistance) * DELAY_BETWEEN + 1; AnimationSet mHideAnimations = AnimationService.startAlphaHideAnimation(delay, VIEW, includeTranslation); if (mHideAnimations == null) { return -1; } int hideAnimationDuration = (int) mHideAnimations.getDuration(); if (hideAnimationDuration + delay > clearingDuration) { clearingDuration = hideAnimationDuration + delay; } // If the view is the last to animate, then start the intent when the animation finishes. if(i == lastVisibleItemPosition && animationListener != null) { mHideAnimations.setAnimationListener(animationListener); } } return clearingDuration; }