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

The following examples show how to use android.view.animation.AnimationSet#setFillAfter() . 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: VoiceRecodingPanel.java    From bcm-android with GNU General Public License v3.0 6 votes vote down vote up
private void display(float x) {
    this.startPositionX = x;
    this.lastPositionX = x;

    recordButtonFab.setVisibility(VISIBLE);
    recordButtonFab.setX(getWidthAdjustment() + getOffset(x));

    AnimationSet animation = new AnimationSet(true);

    ScaleAnimation scaleAnimation = new ScaleAnimation(0.5f, 1f, 0.5f, 1f,
            Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    animation.addAnimation(scaleAnimation);
    animation.setFillBefore(true);
    animation.setFillAfter(true);
    animation.setDuration(ANIMATION_DURATION);
    animation.setInterpolator(new OvershootInterpolator());

    recordButtonFab.startAnimation(animation);
}
 
Example 2
Source File: AnimationService.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 6 votes vote down vote up
/**
 * For the Activity Circle Icon and text
 */

public static AnimationSet 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);

	return mAnimations;
}
 
Example 3
Source File: ArcLayout.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
private static Animation createShrinkAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta,
        long startOffset, long duration, Interpolator interpolator) {
    AnimationSet animationSet = new AnimationSet(false);
    animationSet.setFillAfter(true);

    final long preDuration = duration / 2;
    Animation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    rotateAnimation.setStartOffset(startOffset);
    rotateAnimation.setDuration(preDuration);
    rotateAnimation.setInterpolator(new LinearInterpolator());
    rotateAnimation.setFillAfter(true);

    animationSet.addAnimation(rotateAnimation);

    Animation translateAnimation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 360, 720);
    translateAnimation.setStartOffset(startOffset + preDuration);
    translateAnimation.setDuration(duration - preDuration);
    translateAnimation.setInterpolator(interpolator);
    translateAnimation.setFillAfter(true);

    animationSet.addAnimation(translateAnimation);

    return animationSet;
}
 
Example 4
Source File: AnimationService.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 6 votes vote down vote up
public static void setAdapterInsertAnimation(final View aCard, int row, int height) {
	final int ANIMATION_DURATION = 650;
	final int BASE_DELAY = 50;

	TranslateAnimation translationAnimation = new TranslateAnimation(0,0, height,0);

	AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);

	final AnimationSet animationSet = new AnimationSet(true);
	animationSet.addAnimation(translationAnimation);
	animationSet.addAnimation(alphaAnimation);
	animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
	animationSet.setFillAfter(true);
	animationSet.setFillBefore(true);
	animationSet.setDuration(ANIMATION_DURATION + row * BASE_DELAY);

	aCard.setAnimation(animationSet);
}
 
Example 5
Source File: RayLayout.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
private static Animation createShrinkAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta,
		long startOffset, long duration, Interpolator interpolator) {
	AnimationSet animationSet = new AnimationSet(false);
	animationSet.setFillAfter(true);

	final long preDuration = duration / 2;
	Animation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	rotateAnimation.setStartOffset(startOffset);
	rotateAnimation.setDuration(preDuration);
	rotateAnimation.setInterpolator(new LinearInterpolator());
	rotateAnimation.setFillAfter(true);

	animationSet.addAnimation(rotateAnimation);

	Animation translateAnimation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 360, 720);
	translateAnimation.setStartOffset(startOffset + preDuration);
	translateAnimation.setDuration(duration - preDuration);
	translateAnimation.setInterpolator(interpolator);
	translateAnimation.setFillAfter(true);

	animationSet.addAnimation(translateAnimation);

	return animationSet;
}
 
Example 6
Source File: AnimationService.java    From Twire with GNU General Public License v3.0 6 votes vote down vote up
private static AnimationSet startAlphaHideAnimation(final int DELAY, final View VIEW, boolean includeTransition) {
    final int ANIMATION_DURATION = 300;
    if (VIEW == null)
        return null;

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

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

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

        mHideAnimations.addAnimation(mTransitionAnimation);
    }

    new Handler().postDelayed(() -> VIEW.startAnimation(mHideAnimations), DELAY);

    return mHideAnimations;
}
 
Example 7
Source File: WelcomeActivity.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 6 votes vote down vote up
private AnimationSet startHideContinueIconAnimations() {
	Animation mScaleAnimation = new ScaleAnimation(1, 0, 1, 0, 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);
	return mAnimations;
}
 
Example 8
Source File: WelcomeActivity.java    From Twire with GNU General Public License v3.0 6 votes vote down vote up
private void startHideContinueIconAnimations() {
    Animation mScaleAnimation = new ScaleAnimation(1, 0, 1, 0, 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 9
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 10
Source File: DraggableGridViewPager.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
private void animateDragged() {
	if (mLastDragged >= 0) {
		final View v = getChildAt(mLastDragged);

		final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
		r.inset(-r.width() / 20, -r.height() / 20);
		v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY),
				MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY));
		v.layout(r.left, r.top, r.right, r.bottom);

		AnimationSet animSet = new AnimationSet(true);
		ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2);
		scale.setDuration(ANIMATION_DURATION);
		AlphaAnimation alpha = new AlphaAnimation(1, .5f);
		alpha.setDuration(ANIMATION_DURATION);

		animSet.addAnimation(scale);
		animSet.addAnimation(alpha);
		animSet.setFillEnabled(true);
		animSet.setFillAfter(true);

		v.clearAnimation();
		v.startAnimation(animSet);
	}
}
 
Example 11
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 12
Source File: AnimationFactory.java    From Android-Notification with Apache License 2.0 5 votes vote down vote up
/**
 * Create push up animation for leaving.
 *
 * @return Animation
 */
public static Animation pushUpOut() {
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.setFillAfter(true);
    animationSet.addAnimation(new TranslateAnimation(0, 0, 0, -100));
    animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f));
    return animationSet;
}
 
Example 13
Source File: SplashActivity.java    From ZhihuDaily with MIT License 5 votes vote down vote up
private Animation createLogoAnim() {
    final ScaleAnimation tvScaleAnim = new ScaleAnimation(1.0f, 1.3f, 1.0f, 1.3f
            , Animation.RELATIVE_TO_SELF, 0.5F, Animation.RELATIVE_TO_SELF, 0.5f);
    final TranslateAnimation tvTranslateAnim = new TranslateAnimation(0, 0, 0, -40);
    final AnimationSet tvAnimationSet = new AnimationSet(true);
    tvAnimationSet.addAnimation(tvScaleAnim);
    tvAnimationSet.addAnimation(tvTranslateAnim);
    tvAnimationSet.setDuration(3000);
    tvAnimationSet.setFillAfter(true);
    return tvAnimationSet;
}
 
Example 14
Source File: PayView.java    From HandstandPay with GNU General Public License v2.0 5 votes vote down vote up
private AnimationSet newAnimationSet() {
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.setFillEnabled(true);
    animationSet.setFillBefore(true);
    animationSet.setFillAfter(true);
    return animationSet;
}
 
Example 15
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 16
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 17
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 18
Source File: AnnularMenu.java    From AnnularMenuView with Apache License 2.0 5 votes vote down vote up
private Animation scaleSmallAnimation(int duration) {
    AnimationSet animationSet = new AnimationSet(true);
    ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5F);
    AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.0f);
    animationSet.addAnimation(scaleAnimation);
    animationSet.addAnimation(alphaAnimation);
    animationSet.setDuration(duration);
    animationSet.setFillAfter(true);
    return animationSet;
}
 
Example 19
Source File: AnimationFactory.java    From Android-Notification with Apache License 2.0 5 votes vote down vote up
/**
 * Create push down animation for entering.
 *
 * @return Animation
 */
public static Animation pushDownIn() {
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.setFillAfter(true);
    animationSet.addAnimation(new TranslateAnimation(0, 0, -100, 0));
    animationSet.addAnimation(new AlphaAnimation(0.0f, 1.0f));
    return animationSet;
}
 
Example 20
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;
}