Java Code Examples for android.view.animation.AnimationSet#setInterpolator()

The following examples show how to use android.view.animation.AnimationSet#setInterpolator() . 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 Pocket-Plays-for-Twitch with GNU General Public License v3.0 6 votes vote down vote up
public static AnimationSet startAlphaHideAnimation(final View VIEW) {
	final int ANIMATION_DURATION = 350;

	final Animation mHideViewAnimation = new AlphaAnimation(1f, 0f);

	AnimationSet mAnimations = new AnimationSet(true);
	mAnimations.setDuration(ANIMATION_DURATION);
	mAnimations.setInterpolator(new AccelerateDecelerateInterpolator());
	mAnimations.addAnimation(mHideViewAnimation);
	mAnimations.setFillAfter(true);

       if(VIEW != null)
	    VIEW.startAnimation(mAnimations);

	return mAnimations;
}
 
Example 2
Source File: WelcomeActivity.java    From Twire with GNU General Public License v3.0 6 votes vote down vote up
private void startShowContinueIconAnimations() {
    Animation mScaleAnimation = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    Animation mRotateAnimation = new RotateAnimation(
            0, 360,
            Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f
    );
    mRotateAnimation.setRepeatCount(0);

    AnimationSet mAnimations = new AnimationSet(true);
    mAnimations.setDuration(REVEAL_ANIMATION_DURATION);
    mAnimations.setFillAfter(true);
    mAnimations.setInterpolator(new OvershootInterpolator(1.5f));
    mAnimations.addAnimation(mScaleAnimation);
    mAnimations.addAnimation(mRotateAnimation);

    mContinueIcon.startAnimation(mAnimations);
}
 
Example 3
Source File: CommonViewAnimationActivity.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
private Animation getAnimationSet(boolean fromXML) {
    if (fromXML) {
        Animation animation = AnimationUtils.loadAnimation(this, R.anim.view_animation);
        return animation;
    } else {
        AnimationSet innerAnimationSet = new AnimationSet(true);
        innerAnimationSet.setInterpolator(new BounceInterpolator());
        innerAnimationSet.setStartOffset(1000);
        innerAnimationSet.addAnimation(getScaleAnimation());
        innerAnimationSet.addAnimation(getTranslateAnimation());

        AnimationSet animationSet = new AnimationSet(true);
        animationSet.setInterpolator(new LinearInterpolator());

        animationSet.addAnimation(getAlphaAnimation());
        animationSet.addAnimation(getRotateAnimation());
        animationSet.addAnimation(innerAnimationSet);

        return animationSet;
    }
}
 
Example 4
Source File: AnimationService.java    From Twire with GNU General Public License v3.0 6 votes vote down vote up
/**
 * For the Activity Circle Icon and text
 */

public static void startAlphaRevealAnimation(final View VIEW) {
    final int ANIMATION_DURATION = 1000;

    final Animation mShowViewAnimation = new AlphaAnimation(0f, 1f);
    mShowViewAnimation.setDuration(ANIMATION_DURATION);

    AnimationSet mAnimations = new AnimationSet(true);
    mAnimations.setInterpolator(new AccelerateDecelerateInterpolator());
    mAnimations.addAnimation(mShowViewAnimation);
    mAnimations.setFillAfter(true);

    if (VIEW != null)
        VIEW.startAnimation(mAnimations);

}
 
Example 5
Source File: MicrophoneRecorderView.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
public void display(float x) {
  this.startPositionX = x;
  this.lastPositionX  = x;

  recordButtonFab.setVisibility(View.VISIBLE);

  AnimationSet animation = new AnimationSet(true);
  animation.addAnimation(new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,
                                                Animation.RELATIVE_TO_SELF, 0,
                                                Animation.RELATIVE_TO_SELF, -.25f,
                                                Animation.RELATIVE_TO_SELF, -.25f));

  animation.addAnimation(new ScaleAnimation(.5f, 1f, .5f, 1f,
                                            Animation.RELATIVE_TO_SELF, .5f,
                                            Animation.RELATIVE_TO_SELF, .5f));

  animation.setFillBefore(true);
  animation.setFillAfter(true);
  animation.setDuration(ANIMATION_DURATION);
  animation.setInterpolator(new OvershootInterpolator());

  recordButtonFab.startAnimation(animation);
}
 
Example 6
Source File: FadeScaleViewAnimProvider.java    From stateLayout with Apache License 2.0 5 votes vote down vote up
@Override
public Animation hideAnimation() {
    AnimationSet set = new AnimationSet(true);
    Animation alphaAnimation = new AlphaAnimation(1.0f, 0.0f);
    Animation scaleAnimation = new ScaleAnimation(1.0f, 0.1f, 1.0f, 0.1f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);

    set.setDuration(200);
    set.setInterpolator(new DecelerateInterpolator());
    set.addAnimation(alphaAnimation);
    set.addAnimation(scaleAnimation);
    return set;
}
 
Example 7
Source File: AnimationController.java    From FamilyChat with Apache License 2.0 5 votes vote down vote up
public void slideTranslateOutToTop(View view, long durationMillis, long delayMillis)
{
	TranslateAnimation animation1 = new TranslateAnimation(rela1, 0, rela1, 0, rela1, 0, rela1, -1);
	AnimationSet animation = new AnimationSet(false);
	animation.addAnimation(animation1);
	animation.setInterpolator(new LinearInterpolator());
	baseOut(view, animation, durationMillis, delayMillis);
}
 
Example 8
Source File: AnimUtils.java    From Dagger2-Sample with MIT License 5 votes vote down vote up
public static Animation createBgImageInAnimation(int fromX, int toX, int transitionDuration) {
    TranslateAnimation translate = new TranslateAnimation(fromX, toX, 0, 0);
    translate.setDuration(transitionDuration);

    AnimationSet set = new AnimationSet(true);
    set.setInterpolator(new DecelerateInterpolator());
    set.addAnimation(translate);
    return set;
}
 
Example 9
Source File: ArcMenu.java    From timecat with Apache License 2.0 5 votes vote down vote up
private static Animation createItemDisappearAnimation(final long duration, final boolean isClicked) {
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(new ScaleAnimation(1.0f, isClicked ? 2.0f : 0.0f, 1.0f, isClicked ? 2.0f : 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
    animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f));

    animationSet.setDuration(duration);
    animationSet.setInterpolator(new DecelerateInterpolator());
    animationSet.setFillAfter(true);

    return animationSet;
}
 
Example 10
Source File: ArcMenu.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private static Animation createItemDisapperAnimation(final long duration, final boolean isClicked) {
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(new ScaleAnimation(1.0f, isClicked ? 2.0f : 0.0f, 1.0f, isClicked ? 2.0f : 0.0f,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
    animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f));

    animationSet.setDuration(duration);
    animationSet.setInterpolator(new DecelerateInterpolator());
    animationSet.setFillAfter(true);

    return animationSet;
}
 
Example 11
Source File: AnimationController.java    From FamilyChat with Apache License 2.0 5 votes vote down vote up
public void slideTranslateOutToBottom(View view, long durationMillis, long delayMillis)
{
	TranslateAnimation animation1 = new TranslateAnimation(rela1, 0, rela1, 0, rela1, 0, rela1,1);
	AnimationSet animation = new AnimationSet(false);
	animation.addAnimation(animation1);
	animation.setInterpolator(new LinearInterpolator());
	baseOut(view, animation, durationMillis, delayMillis);
}
 
Example 12
Source File: CustomAnimationDialogFragment.java    From AndroidNavigation with MIT License 5 votes vote down vote up
private void animateScaleIn() {
    if (mContentView == null) {
        return;
    }
    ScaleAnimation scaleAnimation = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    AlphaAnimation alpha = new AlphaAnimation(0, 1);
    AnimationSet set = new AnimationSet(true);
    set.addAnimation(scaleAnimation);
    set.addAnimation(alpha);
    set.setInterpolator(new DecelerateInterpolator());
    set.setDuration(mAnimationDuration );
    set.setFillAfter(true);
    mContentView.startAnimation(set);
}
 
Example 13
Source File: RayMenu.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private static Animation createItemDisapperAnimation(final long duration, final boolean isClicked) {
	AnimationSet animationSet = new AnimationSet(true);
	animationSet.addAnimation(new ScaleAnimation(1.0f, isClicked ? 2.0f : 0.0f, 1.0f, isClicked ? 2.0f : 0.0f,
			Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
	animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f));

	animationSet.setDuration(duration);
	animationSet.setInterpolator(new DecelerateInterpolator());
	animationSet.setFillAfter(true);

	return animationSet;
}
 
Example 14
Source File: AnimationService.java    From Twire with GNU General Public License v3.0 5 votes vote down vote up
/**
 * For the Card Views
 */
public static void startAlphaRevealAnimation(int delay, final View VIEW, boolean includeTransition) {
    final int ANIMATION_DURATION = 300;

    final Animation mAlphaAnimation = new AlphaAnimation(0f, 1f);
    mAlphaAnimation.setDuration(ANIMATION_DURATION);
    mAlphaAnimation.setFillAfter(true);

    final AnimationSet mRevealAnimations = new AnimationSet(true);
    mRevealAnimations.setInterpolator(new AccelerateDecelerateInterpolator());
    mRevealAnimations.addAnimation(mAlphaAnimation);
    mRevealAnimations.setFillAfter(true);

    if (includeTransition) {
        final Animation mTransitionAnimation = new TranslateAnimation(0, 0, VIEW.getHeight() / 2, 0);
        mTransitionAnimation.setDuration(ANIMATION_DURATION);
        mTransitionAnimation.setFillAfter(false);

        mRevealAnimations.addAnimation(mTransitionAnimation);
    }

    new Handler().postDelayed(() -> {
        if (VIEW != null)
            VIEW.startAnimation(mRevealAnimations);
    }, delay);

}
 
Example 15
Source File: AnimationHelper.java    From AnimatedPullToRefresh-master with Apache License 2.0 5 votes vote down vote up
private void addTextFadeAnimations(AnimationSet set) {
    AlphaAnimation mFadeInAnim = new AlphaAnimation(1, FADE_MOUNT);
    mFadeInAnim.setDuration(CHARACTER_ANIM_DURATION);
    set.addAnimation(mFadeInAnim);
    AlphaAnimation mFadeOutAnim = new AlphaAnimation(FADE_MOUNT, 1);
    mFadeOutAnim.setDuration(CHARACTER_ANIM_DURATION);
    mFadeOutAnim.setStartOffset(CHARACTER_ANIM_DURATION + 20);
    mFadeOutAnim.setFillAfter(true);
    set.addAnimation(mFadeOutAnim);
    set.setInterpolator(interpolator);
}
 
Example 16
Source File: VoiceRecodingPanel.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
private void hide(float x) {
    this.lastPositionX = x;

    float offset = getOffset(x);
    int widthAdjustment = getWidthAdjustment();

    AnimationSet animation = new AnimationSet(false);
    Animation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);

    Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, offset + widthAdjustment,
            Animation.ABSOLUTE, widthAdjustment,
            Animation.RELATIVE_TO_SELF, -.25f,
            Animation.RELATIVE_TO_SELF, -.25f);

    scaleAnimation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));
    translateAnimation.setInterpolator(new DecelerateInterpolator());
    animation.addAnimation(scaleAnimation);
    animation.addAnimation(translateAnimation);
    animation.setDuration(ANIMATION_DURATION);
    animation.setFillBefore(true);
    animation.setFillAfter(false);
    animation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));

    recordButtonFab.setVisibility(View.GONE);
    recordButtonFab.clearAnimation();
    recordButtonFab.startAnimation(animation);
}
 
Example 17
Source File: MicrophoneRecorderView.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
public void hide(float x) {
  this.lastPositionX = x;

  float offset = getOffset(x);

  AnimationSet animation = new AnimationSet(false);
  Animation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 0.5f,
                                                Animation.RELATIVE_TO_SELF, 0.5f,
                                                Animation.RELATIVE_TO_SELF, 0.5f);

  Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, offset,
                                                        Animation.ABSOLUTE, 0,
                                                        Animation.RELATIVE_TO_SELF, -.25f,
                                                        Animation.RELATIVE_TO_SELF, -.25f);

  scaleAnimation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));
  translateAnimation.setInterpolator(new DecelerateInterpolator());
  animation.addAnimation(scaleAnimation);
  animation.addAnimation(translateAnimation);
  animation.setDuration(ANIMATION_DURATION);
  animation.setFillBefore(true);
  animation.setFillAfter(false);
  animation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));

  recordButtonFab.setVisibility(View.GONE);
  recordButtonFab.clearAnimation();
  recordButtonFab.startAnimation(animation);
}
 
Example 18
Source File: MainActivityAdapter.java    From Twire with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Hides every currently shown element in the recyclerview. When the last view has been hidden
 * clearNoAnimation() is called
 *
 * @return The time is takes for the last element to hide
 */
public int clear() {
    final int ANIMATION_DURATION = 300;
    final int BASE_DELAY = 50;

    int startPosition = mRecyclerView.getManager().findFirstVisibleItemPosition();
    int endPosition = mRecyclerView.getManager().findLastVisibleItemPosition();

    int timeBeforeLastAnimIsDone = ANIMATION_DURATION;
    for (int i = startPosition; i <= endPosition; i++) {
        int delay = (i - startPosition) * BASE_DELAY;
        final int finalI = i;

        final int TRANSLATE_LENGTH = context.getResources().getDisplayMetrics().heightPixels;
        Animation mTranslateAnim = new TranslateAnimation(0, 0, 0, TRANSLATE_LENGTH);
        Animation mAlphaAnim = new AlphaAnimation(1f, 0f);

        final AnimationSet mAnimSet = new AnimationSet(true);
        mAnimSet.addAnimation(mTranslateAnim);
        mAnimSet.addAnimation(mAlphaAnim);
        mAnimSet.setDuration(ANIMATION_DURATION);
        mAnimSet.setInterpolator(new AccelerateDecelerateInterpolator());
        mAnimSet.setFillAfter(true);
        mAnimSet.setFillBefore(true);

        new Handler().postDelayed(() -> {
            View v = mRecyclerView.getManager().getChildAt(finalI);
            if (v != null) {
                v.startAnimation(mAnimSet);
            }
        }, delay);

        if (i == endPosition) {
            timeBeforeLastAnimIsDone = ANIMATION_DURATION + delay;
        }
    }

    new Handler().postDelayed(this::clearNoAnimation, timeBeforeLastAnimIsDone);

    return timeBeforeLastAnimIsDone;
}
 
Example 19
Source File: MainActivityAdapter.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Hides every currently shown element in the recyclerview. When the last view has been hidden
 * clearNoAnimation() is called
 * @return The time is takes for the last element to hide
 */
public int clear() {
	final int ANIMATION_DURATION = 300;
	final int BASE_DELAY = 50;

	int startPosition = mRecyclerView.getManager().findFirstVisibleItemPosition();
	int endPosition = mRecyclerView.getManager().findLastVisibleItemPosition();

	int timeBeforeLastAnimIsDone = ANIMATION_DURATION;
	for(int i = startPosition; i <= endPosition; i++) {
		int delay = (i - startPosition) * BASE_DELAY;
		final int finalI = i;

		final int TRANSLATE_LENGTH = context.getResources().getDisplayMetrics().heightPixels;
		Animation mTranslateAnim = new TranslateAnimation(0, 0, 0, TRANSLATE_LENGTH);
		Animation mAlphaAnim = new AlphaAnimation(1f, 0f);

		final AnimationSet mAnimSet = new AnimationSet(true);
		mAnimSet.addAnimation(mTranslateAnim);
		mAnimSet.addAnimation(mAlphaAnim);
		mAnimSet.setDuration(ANIMATION_DURATION);
		mAnimSet.setInterpolator(new AccelerateDecelerateInterpolator());
		mAnimSet.setFillAfter(true);
		mAnimSet.setFillBefore(true);

		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {
				View v = mRecyclerView.getManager().getChildAt(finalI);
				if(v != null) {
					v.startAnimation(mAnimSet);
				}
			}
		}, delay);

		if(i == endPosition) {
			timeBeforeLastAnimIsDone = ANIMATION_DURATION + delay;
		}
	}

	new Handler().postDelayed(new Runnable() {
		@Override
		public void run() {
			clearNoAnimation();
		}
	}, timeBeforeLastAnimIsDone);

	return timeBeforeLastAnimIsDone;
}
 
Example 20
Source File: HBButton.java    From Hamburger-Button with Apache License 2.0 4 votes vote down vote up
private void animateChangeDirection() {

		setClickable(false);
		final float origLeft;
		final float finalLeft;
		final float origRight;
		final float finalRight;
		final float rangeOfLeft;
		final float rangeOfRight;

		if (isSlideLeftToRight()) {

			origRight = mRFSlider.right;
			finalRight = mWidth;

			rangeOfRight = finalRight - origRight;
			rangeOfLeft = rangeOfRight + mWidth / 3;

			mRFSlider.left -= rangeOfRight;
			origLeft = mRFSlider.left;
		} else {
			origLeft = mRFSlider.left;
			finalLeft = 0;

			rangeOfLeft = finalLeft - origLeft;
			rangeOfRight = rangeOfLeft - mWidth / 3;

			mRFSlider.right += -rangeOfLeft;
			origRight = mRFSlider.right;
		}

		Animation animation = new Animation() {
			@Override
			protected void applyTransformation(float interpolatedTime, Transformation t) {
				super.applyTransformation(interpolatedTime, t);
				mRFSlider.set(origLeft + rangeOfLeft * interpolatedTime, mRFSlider.top, origRight + rangeOfRight * interpolatedTime, mRFSlider.bottom);
				invalidate();
			}
		};

		animation.setDuration(getAnimationDuration() / 2);

		AnimationSet animationSet = new AnimationSet(true);
		animationSet.addAnimation(animation);
		animationSet.setInterpolator(new AccelerateDecelerateInterpolator());

		Animation animationLineTop1;
		Animation animationLineCenter1;
		Animation animationLineBottom1;

		Animation animationLineTop2;
		Animation animationLineCenter2;
		Animation animationLineBottom2;

		if (isSlideLeftToRight()) {
			animationLineTop1 = generateLineBackLTRStep1(mLineTop);
			animationLineCenter1 = generateLineBackLTRStep1(mLineCenter);
			animationLineBottom1 = generateLineBackLTRStep1(mLineBottom);

			animationLineTop2 = generateLineBackLTRStep2(mLineTop);
			animationLineCenter2 = generateLineBackLTRStep2(mLineCenter);
			animationLineBottom2 = generateLineBackLTRStep2(mLineBottom);
		} else {
			animationLineTop1 = generateLineBackRTLStep1(mLineTop);
			animationLineCenter1 = generateLineBackRTLStep1(mLineCenter);
			animationLineBottom1 = generateLineBackRTLStep1(mLineBottom);

			animationLineTop2 = generateLineBackRTLStep2(mLineTop);
			animationLineCenter2 = generateLineBackRTLStep2(mLineCenter);
			animationLineBottom2 = generateLineBackRTLStep2(mLineBottom);
		}

		animationSet.addAnimation(animationLineTop1);
		animationSet.addAnimation(animationLineCenter1);
		animationSet.addAnimation(animationLineBottom1);

		animationSet.addAnimation(animationLineTop2);
		animationSet.addAnimation(animationLineCenter2);
		animationSet.addAnimation(animationLineBottom2);

		animationSet.setAnimationListener(directionChangeListener);

		startAnimation(animationSet);
	}