List of usage examples for android.view.animation Animation setDuration
public void setDuration(long durationMillis)
From source file:com.box.myview.MyTopSnackBar.TSnackbar.java
private void animateViewIn() { Animation anim; if (appearDirection == APPEAR_FROM_TOP_TO_DOWN) { anim = getAnimationInFromTopToDown(); } else {/* w w w .j av a 2 s .c om*/ anim = getAnimationInFromBottomToTop(); } anim.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR); anim.setDuration(ANIMATION_DURATION); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation animation) { onViewShown(); } @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); mView.startAnimation(anim); }
From source file:com.box.myview.MyTopSnackBar.TSnackbar.java
private void animateViewOut(final int event) { Animation anim; if (appearDirection == APPEAR_FROM_TOP_TO_DOWN) { anim = getAnimationOutFromTopToDown(); } else {//from w ww . j a va2 s . c om anim = getAnimationOutFromBottomToTop(); } anim.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR); anim.setDuration(ANIMATION_DURATION); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation animation) { onViewHidden(event); } @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); mView.startAnimation(anim); }
From source file:com.hp.hoopeasy.widget.swipeRefresh.SwipeRefreshLayout.java
private Animation startAlphaAnimation(final int startingAlpha, final int endingAlpha) { // Pre API 11, alpha is used in place of scale. Don't also use it to // type the trigger point. if (mScale && isAlphaUsedForScale()) { return null; }//from www. j av a 2 s .co m Animation alpha = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { mProgress.setAlpha((int) (startingAlpha + ((endingAlpha - startingAlpha) * interpolatedTime))); } }; alpha.setDuration(ALPHA_ANIMATION_DURATION); // Clear out the previous animation listeners. mCircleView.setAnimationListener(null); mCircleView.clearAnimation(); mCircleView.startAnimation(alpha); return alpha; }
From source file:android.support.v7.app.MediaRouteControllerDialog.java
void clearGroupListAnimation(boolean exceptAddedRoutes) { int first = mVolumeGroupList.getFirstVisiblePosition(); for (int i = 0; i < mVolumeGroupList.getChildCount(); ++i) { View view = mVolumeGroupList.getChildAt(i); int position = first + i; MediaRouter.RouteInfo route = mVolumeGroupAdapter.getItem(position); if (exceptAddedRoutes && mGroupMemberRoutesAdded != null && mGroupMemberRoutesAdded.contains(route)) { continue; }//from w w w .ja va 2 s. c o m LinearLayout container = (LinearLayout) view.findViewById(R.id.volume_item_container); container.setVisibility(View.VISIBLE); AnimationSet animSet = new AnimationSet(true); Animation alphaAnim = new AlphaAnimation(1.0f, 1.0f); alphaAnim.setDuration(0); animSet.addAnimation(alphaAnim); Animation translationAnim = new TranslateAnimation(0, 0, 0, 0); translationAnim.setDuration(0); animSet.setFillAfter(true); animSet.setFillEnabled(true); view.clearAnimation(); view.startAnimation(animSet); } mVolumeGroupList.stopAnimationAll(); if (!exceptAddedRoutes) { finishAnimation(false); } }
From source file:android.support.v7.app.MediaRouteControllerDialog.java
private void fadeInAddedRoutes() { Animation.AnimationListener listener = new Animation.AnimationListener() { @Override/*from ww w . java 2 s .c om*/ public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { finishAnimation(true); } @Override public void onAnimationRepeat(Animation animation) { } }; boolean listenerRegistered = false; int first = mVolumeGroupList.getFirstVisiblePosition(); for (int i = 0; i < mVolumeGroupList.getChildCount(); ++i) { View view = mVolumeGroupList.getChildAt(i); int position = first + i; MediaRouter.RouteInfo route = mVolumeGroupAdapter.getItem(position); if (mGroupMemberRoutesAdded.contains(route)) { Animation alphaAnim = new AlphaAnimation(0.0f, 1.0f); alphaAnim.setDuration(mGroupListFadeInDurationMs); alphaAnim.setFillEnabled(true); alphaAnim.setFillAfter(true); if (!listenerRegistered) { listenerRegistered = true; alphaAnim.setAnimationListener(listener); } view.clearAnimation(); view.startAnimation(alphaAnim); } } }
From source file:com.kectech.android.wyslink.thirdparty.SwipeRefreshLayout.java
private Animation startAlphaAnimation(final int startingAlpha, final int endingAlpha) { // Pre API 11, alpha is used in place of scale. Don't also use it to // tab_main_show the trigger point. if (mScale && isAlphaUsedForScale()) { return null; }/*w w w. j av a 2 s. com*/ Animation alpha = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { mProgress.setAlpha((int) (startingAlpha + ((endingAlpha - startingAlpha) * interpolatedTime))); } }; alpha.setDuration(ALPHA_ANIMATION_DURATION); // Clear out the previous animation listeners. mCircleView.setAnimationListener(null); mCircleView.clearAnimation(); mCircleView.startAnimation(alpha); return alpha; }
From source file:bhav.swipeaction.SwipeAction.java
private Animation startAlphaAnimation(final int startingAlpha, final int endingAlpha) { // Pre API 11, alpha is used in place of scale. Don't also use it to // show the trigger point. if (mScale) { return null; }/*from w ww . ja va 2 s . c om*/ Animation alpha = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { // icon // .setAlpha((int) (startingAlpha + ((endingAlpha - startingAlpha) // * interpolatedTime))); } }; alpha.setDuration(ALPHA_ANIMATION_DURATION); // Clear out the previous animation listeners. mCircleView.setAnimationListener(null); mCircleView.clearAnimation(); mCircleView.startAnimation(alpha); return alpha; }
From source file:android.support.v7.app.MediaRouteControllerDialog.java
private void animateGroupListItemsInternal(Map<MediaRouter.RouteInfo, Rect> previousRouteBoundMap, Map<MediaRouter.RouteInfo, BitmapDrawable> previousRouteBitmapMap) { if (mGroupMemberRoutesAdded == null || mGroupMemberRoutesRemoved == null) { return;/* w ww .ja v a 2 s . c o m*/ } int groupSizeDelta = mGroupMemberRoutesAdded.size() - mGroupMemberRoutesRemoved.size(); boolean listenerRegistered = false; Animation.AnimationListener listener = new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mVolumeGroupList.startAnimationAll(); mVolumeGroupList.postDelayed(mGroupListFadeInAnimation, mGroupListAnimationDurationMs); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }; // Animate visible items from previous positions to current positions except routes added // just before. Added routes will remain hidden until translate animation finishes. int first = mVolumeGroupList.getFirstVisiblePosition(); for (int i = 0; i < mVolumeGroupList.getChildCount(); ++i) { View view = mVolumeGroupList.getChildAt(i); int position = first + i; MediaRouter.RouteInfo route = mVolumeGroupAdapter.getItem(position); Rect previousBounds = previousRouteBoundMap.get(route); int currentTop = view.getTop(); int previousTop = previousBounds != null ? previousBounds.top : (currentTop + mVolumeGroupListItemHeight * groupSizeDelta); AnimationSet animSet = new AnimationSet(true); if (mGroupMemberRoutesAdded != null && mGroupMemberRoutesAdded.contains(route)) { previousTop = currentTop; Animation alphaAnim = new AlphaAnimation(0.0f, 0.0f); alphaAnim.setDuration(mGroupListFadeInDurationMs); animSet.addAnimation(alphaAnim); } Animation translationAnim = new TranslateAnimation(0, 0, previousTop - currentTop, 0); translationAnim.setDuration(mGroupListAnimationDurationMs); animSet.addAnimation(translationAnim); animSet.setFillAfter(true); animSet.setFillEnabled(true); animSet.setInterpolator(mInterpolator); if (!listenerRegistered) { listenerRegistered = true; animSet.setAnimationListener(listener); } view.clearAnimation(); view.startAnimation(animSet); previousRouteBoundMap.remove(route); previousRouteBitmapMap.remove(route); } // If a member route doesn't exist any longer, it can be either removed or moved out of the // ListView layout boundary. In this case, use the previously captured bitmaps for // animation. for (Map.Entry<MediaRouter.RouteInfo, BitmapDrawable> item : previousRouteBitmapMap.entrySet()) { final MediaRouter.RouteInfo route = item.getKey(); final BitmapDrawable bitmap = item.getValue(); final Rect bounds = previousRouteBoundMap.get(route); OverlayObject object = null; if (mGroupMemberRoutesRemoved.contains(route)) { object = new OverlayObject(bitmap, bounds).setAlphaAnimation(1.0f, 0.0f) .setDuration(mGroupListFadeOutDurationMs).setInterpolator(mInterpolator); } else { int deltaY = groupSizeDelta * mVolumeGroupListItemHeight; object = new OverlayObject(bitmap, bounds).setTranslateYAnimation(deltaY) .setDuration(mGroupListAnimationDurationMs).setInterpolator(mInterpolator) .setAnimationEndListener(new OverlayObject.OnAnimationEndListener() { @Override public void onAnimationEnd() { mGroupMemberRoutesAnimatingWithBitmap.remove(route); mVolumeGroupAdapter.notifyDataSetChanged(); } }); mGroupMemberRoutesAnimatingWithBitmap.add(route); } mVolumeGroupList.addOverlayObject(object); } }
From source file:com.oginotihiro.snackbar.Snackbar.java
private void animateViewOut(final int event) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { ViewPropertyAnimatorCompat vpac = ViewCompat.animate(mView); if (mDirection == LEFT_RIGHT) { vpac.translationX(-mView.getWidth()); } else if (mDirection == TOP_BOTTOM) { vpac.translationY(-mView.getHeight()); } else if (mDirection == RIGHT_LEFT) { vpac.translationX(mView.getWidth()); } else if (mDirection == BOTTOM_TOP) { vpac.translationY(mView.getHeight()); }/*from ww w. j av a 2 s .c om*/ vpac.setInterpolator(new FastOutSlowInInterpolator()).setDuration(mAnimDuration) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationStart(View view) { mView.animateChildrenOut(0, mAnimFadeDuration); } @Override public void onAnimationEnd(View view) { onViewHidden(event); } }).start(); } else { Animation anim = null; if (mDirection == LEFT_RIGHT) { anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_left_out); } else if (mDirection == TOP_BOTTOM) { anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_top_out); } else if (mDirection == RIGHT_LEFT) { anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_right_out); } else if (mDirection == BOTTOM_TOP) { anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_bottom_out); } if (anim == null) return; anim.setInterpolator(new FastOutSlowInInterpolator()); anim.setDuration(ANIMATION_DURATION); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { onViewHidden(event); } @Override public void onAnimationRepeat(Animation animation) { } }); mView.startAnimation(anim); } }
From source file:com.oginotihiro.snackbar.Snackbar.java
private void animateViewIn() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { ViewPropertyAnimatorCompat vpac = ViewCompat.animate(mView); if (mDirection == LEFT_RIGHT) { ViewCompat.setTranslationX(mView, -mView.getWidth()); vpac.translationX(0f);//w w w.j av a2 s . co m } else if (mDirection == TOP_BOTTOM) { ViewCompat.setTranslationY(mView, -mView.getHeight()); vpac.translationY(0f); } else if (mDirection == RIGHT_LEFT) { ViewCompat.setTranslationX(mView, mView.getWidth()); vpac.translationX(0f); } else if (mDirection == BOTTOM_TOP) { ViewCompat.setTranslationY(mView, mView.getHeight()); vpac.translationY(0f); } vpac.setInterpolator(new FastOutSlowInInterpolator()).setDuration(mAnimDuration) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationStart(View view) { mView.animateChildrenIn(mAnimDuration - mAnimFadeDuration, mAnimFadeDuration); } @Override public void onAnimationEnd(View view) { if (mCallback != null) { mCallback.onShow(Snackbar.this); } SnackbarManager.getInstance().onShown(mManagerCallback); } }).start(); } else { Animation anim = null; if (mDirection == LEFT_RIGHT) { anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_left_in); } else if (mDirection == TOP_BOTTOM) { anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_top_in); } else if (mDirection == RIGHT_LEFT) { anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_right_in); } else if (mDirection == BOTTOM_TOP) { anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_bottom_in); } if (anim == null) return; anim.setInterpolator(new FastOutSlowInInterpolator()); anim.setDuration(mAnimDuration); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (mCallback != null) { mCallback.onShow(Snackbar.this); } SnackbarManager.getInstance().onShown(mManagerCallback); } @Override public void onAnimationRepeat(Animation animation) { } }); mView.setAnimation(anim); } }