List of usage examples for android.view.animation Animation setDuration
public void setDuration(long durationMillis)
From source file:com.callba.phone.widget.refreshlayout.RefreshLayout.java
private Animation startHeaderAlphaAnimation(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 (mHeaderScale && isAlphaUsedForScale()) { return null; }//from w w w . j av a2s . c o 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:eu.thedarken.rootvalidator.ValidatorFragment.java
private void animateFAB(boolean out) { Animation animation; if (out) {// w w w . j ava 2 s . com animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1.0f); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mFab.setVisibility(View.INVISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); } else { animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mFab.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); } animation.setDuration(600); animation.setInterpolator(new AnticipateOvershootInterpolator(1.2f)); mFab.startAnimation(animation); }
From source file:com.umeng.comm.ui.fragments.BaseFeedsFragment.java
/** * Float button</br>/*from www . j a va2s. c o m*/ * * @param show or ? */ private void executeAnimation(final boolean show) { if (isExecutingAnim || (show && currentStatus == STATUS_SHOW) || (!show && currentStatus == STATUS_DISMISS)) { return; } isExecutingAnim = true; int moveDis = ((FrameLayout.LayoutParams) (mPostBtn.getLayoutParams())).bottomMargin + mPostBtn.getHeight(); Animation animation = null; if (show) { animation = new TranslateAnimation(0, 0, moveDis, 0); } else { animation = new TranslateAnimation(0, 0, 0, moveDis); } animation.setDuration(300); animation.setFillAfter(true); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { isExecutingAnim = false; if (show) { currentStatus = STATUS_SHOW; } else { currentStatus = STATUS_DISMISS; } // 3.0???????Float // Button?layout? mPostBtn.setClickable(show); } }); mPostBtn.startAnimation(animation); }
From source file:android.wuliqing.com.mylibrary.header.MaterialProgressDrawable.java
private void setupAnimators() { final Ring ring = mRing; final Animation finishRingAnimation = new Animation() { public void applyTransformation(float interpolatedTime, Transformation t) { // shrink back down and complete a full rotation before starting other circles // Rotation goes between [0..1]. float targetRotation = (float) (Math.floor(ring.getStartingRotation() / MAX_PROGRESS_ARC) + 1f); final float startTrim = ring.getStartingStartTrim() + (ring.getStartingEndTrim() - ring.getStartingStartTrim()) * interpolatedTime; ring.setStartTrim(startTrim); final float rotation = ring.getStartingRotation() + ((targetRotation - ring.getStartingRotation()) * interpolatedTime); ring.setRotation(rotation);//from www . j ava 2 s.co m ring.setArrowScale(1 - interpolatedTime); } }; finishRingAnimation.setInterpolator(EASE_INTERPOLATOR); finishRingAnimation.setDuration(ANIMATION_DURATION / 2); finishRingAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { ring.goToNextColor(); ring.storeOriginals(); ring.setShowArrow(false); mParent.startAnimation(mAnimation); } @Override public void onAnimationRepeat(Animation animation) { } }); final Animation animation = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { // The minProgressArc is calculated from 0 to create an angle that // matches the stroke width. final float minProgressArc = (float) Math .toRadians(ring.getStrokeWidth() / (2 * Math.PI * ring.getCenterRadius())); final float startingEndTrim = ring.getStartingEndTrim(); final float startingTrim = ring.getStartingStartTrim(); final float startingRotation = ring.getStartingRotation(); // Offset the minProgressArc to where the endTrim is located. final float minArc = MAX_PROGRESS_ARC - minProgressArc; final float endTrim = startingEndTrim + (minArc * START_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime)); ring.setEndTrim(endTrim); final float startTrim = startingTrim + (MAX_PROGRESS_ARC * END_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime)); ring.setStartTrim(startTrim); final float rotation = startingRotation + (0.25f * interpolatedTime); ring.setRotation(rotation); float groupRotation = ((720.0f / NUM_POINTS) * interpolatedTime) + (720.0f * (mRotationCount / NUM_POINTS)); setRotation(groupRotation); } }; animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.RESTART); animation.setInterpolator(LINEAR_INTERPOLATOR); animation.setDuration(ANIMATION_DURATION); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mRotationCount = 0; } @Override public void onAnimationEnd(Animation animation) { // do nothing } @Override public void onAnimationRepeat(Animation animation) { ring.storeOriginals(); ring.goToNextColor(); ring.setStartTrim(ring.getEndTrim()); mRotationCount = (mRotationCount + 1) % (NUM_POINTS); } }); mFinishAnimation = finishRingAnimation; mAnimation = animation; }
From source file:com.google.android.apps.gutenberg.widget.TabLayout.java
private void animateToTab(int newPosition) { clearAnimation();//from ww w .j a va 2s . co m if (newPosition == Tab.INVALID_POSITION) { return; } if (getWindowToken() == null || !isViewLaidOut(this)) { // If we don't have a window token, or we haven't been laid out yet just draw the new // position now setScrollPosition(newPosition, 0f); return; } final int startScrollX = getScrollX(); final int targetScrollX = calculateScrollXForTab(newPosition, 0); final int duration = ANIMATION_DURATION; if (startScrollX != targetScrollX) { final Animation animation = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float value = lerp(startScrollX, targetScrollX, interpolatedTime); scrollTo((int) value, 0); } }; animation.setInterpolator(INTERPOLATOR); animation.setDuration(duration); startAnimation(animation); } // Now animate the indicator mTabStrip.animateIndicatorToPosition(newPosition, duration); }
From source file:net.rossharper.coloredtablayout.TabLayout.java
private void animateToTab(int newPosition) { clearAnimation();/*from w w w . j a va 2 s . com*/ if (newPosition == Tab.INVALID_POSITION) { return; } if (getWindowToken() == null || !ViewCompat.isLaidOut(this)) { // If we don't have a window token, or we haven't been laid out yet just draw the new // position now setScrollPosition(newPosition, 0f); return; } final int startScrollX = getScrollX(); final int targetScrollX = calculateScrollXForTab(newPosition, 0); final int duration = ANIMATION_DURATION; if (startScrollX != targetScrollX) { final Animation animation = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float value = lerp(startScrollX, targetScrollX, interpolatedTime); scrollTo((int) value, 0); } }; animation.setInterpolator(INTERPOLATOR); animation.setDuration(duration); startAnimation(animation); } // Now animate the indicator mTabStrip.animateIndicatorToPosition(newPosition, duration); }
From source file:cn.xiaocool.hongyunschool.view.MaterialProgressDrawable.java
private void setupAnimators() { final Ring ring = mRing; final Animation finishRingAnimation = new Animation() { public void applyTransformation(float interpolatedTime, Transformation t) { // shrink back down and complete a full rotation before starting // other circles // Rotation goes between [0..1]. float targetRotation = (float) (Math.floor(ring.getStartingRotation() / MAX_PROGRESS_ARC) + 1f); final float startTrim = ring.getStartingStartTrim() + (ring.getStartingEndTrim() - ring.getStartingStartTrim()) * interpolatedTime; ring.setStartTrim(startTrim); final float rotation = ring.getStartingRotation() + ((targetRotation - ring.getStartingRotation()) * interpolatedTime); ring.setRotation(rotation);//from ww w.ja v a 2 s . co m ring.setArrowScale(1 - interpolatedTime); } }; finishRingAnimation.setInterpolator(EASE_INTERPOLATOR); finishRingAnimation.setDuration(ANIMATION_DURATION / 2); finishRingAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { ring.goToNextColor(); ring.storeOriginals(); ring.setShowArrow(false); mParent.startAnimation(mAnimation); } @Override public void onAnimationRepeat(Animation animation) { } }); final Animation animation = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { // The minProgressArc is calculated from 0 to create an angle // that // matches the stroke width. final float minProgressArc = (float) Math .toRadians(ring.getStrokeWidth() / (2 * Math.PI * ring.getCenterRadius())); final float startingEndTrim = ring.getStartingEndTrim(); final float startingTrim = ring.getStartingStartTrim(); final float startingRotation = ring.getStartingRotation(); // Offset the minProgressArc to where the endTrim is located. final float minArc = MAX_PROGRESS_ARC - minProgressArc; final float endTrim = startingEndTrim + (minArc * START_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime)); ring.setEndTrim(endTrim); final float startTrim = startingTrim + (MAX_PROGRESS_ARC * END_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime)); ring.setStartTrim(startTrim); final float rotation = startingRotation + (0.25f * interpolatedTime); ring.setRotation(rotation); float groupRotation = ((720.0f / NUM_POINTS) * interpolatedTime) + (720.0f * (mRotationCount / NUM_POINTS)); setRotation(groupRotation); } }; animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.RESTART); animation.setInterpolator(LINEAR_INTERPOLATOR); animation.setDuration(ANIMATION_DURATION); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mRotationCount = 0; } @Override public void onAnimationEnd(Animation animation) { // do nothing } @Override public void onAnimationRepeat(Animation animation) { ring.storeOriginals(); ring.goToNextColor(); ring.setStartTrim(ring.getEndTrim()); mRotationCount = (mRotationCount + 1) % (NUM_POINTS); } }); mFinishAnimation = finishRingAnimation; mAnimation = animation; }
From source file:org.telegram.ui.GalleryImageViewer.java
private void startViewAnimation(final View panel, boolean up) { Animation animation; if (!up) {// w ww . j ava2 s . co m animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { panel.setVisibility(View.INVISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); animation.setDuration(400); } else { animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { panel.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); animation.setDuration(100); } panel.startAnimation(animation); }
From source file:cw.kop.autobackground.sources.SourceInfoFragment.java
@Override public void onStart() { super.onStart(); Animation animation; if (sourcePosition == -1) { animation = new Animation() { @Override//from w w w .ja v a 2 s. c om protected void applyTransformation(float interpolatedTime, Transformation t) { sourceSpinnerText.setAlpha(interpolatedTime); sourceSpinner.setAlpha(interpolatedTime); sourceTitle.setAlpha(interpolatedTime); settingsContainer.setAlpha(interpolatedTime); sourceUse.setAlpha(interpolatedTime); } }; } else { animation = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { settingsContainer.setAlpha(interpolatedTime); sourceUse.setAlpha(interpolatedTime); } }; } animation.setDuration(FADE_IN_TIME); animation.setInterpolator(new DecelerateInterpolator(3.0f)); settingsContainer.startAnimation(animation); }
From source file:glas.bbsystem.views.widgets.TabLayout.java
private void animateToTab(int newPosition) { clearAnimation();/*w ww . j a v a 2 s.c om*/ if (newPosition == Tab.INVALID_POSITION) { return; } if (getWindowToken() == null || !ViewCompat.isLaidOut(this)) { // If we don't have a window token, or we haven't been laid out yet // just draw the new // position now setScrollPosition(newPosition, 0f); return; } final int startScrollX = getScrollX(); final int targetScrollX = calculateScrollXForTab(newPosition, 0); final int duration = ANIMATION_DURATION; if (startScrollX != targetScrollX) { final Animation animation = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float value = lerp(startScrollX, targetScrollX, interpolatedTime); scrollTo((int) value, 0); } }; animation.setInterpolator(INTERPOLATOR); animation.setDuration(duration); startAnimation(animation); } // Now animate the indicator mTabStrip.animateIndicatorToPosition(newPosition, duration); }