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

The following examples show how to use android.view.animation.AnimationSet#setFillBefore() . 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: InputPanel.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
public ListenableFuture<Void> hide() {
  final SettableFuture<Void> future = new SettableFuture<>();

  AnimationSet animation = new AnimationSet(true);
  animation.addAnimation(new TranslateAnimation(Animation.ABSOLUTE, slideToCancelView.getTranslationX(),
                                                Animation.ABSOLUTE, 0,
                                                Animation.RELATIVE_TO_SELF, 0,
                                                Animation.RELATIVE_TO_SELF, 0));
  animation.addAnimation(new AlphaAnimation(1, 0));

  animation.setDuration(MicrophoneRecorderView.ANIMATION_DURATION);
  animation.setFillBefore(true);
  animation.setFillAfter(false);

  slideToCancelView.postDelayed(() -> future.set(null), MicrophoneRecorderView.ANIMATION_DURATION);
  slideToCancelView.setVisibility(View.GONE);
  slideToCancelView.startAnimation(animation);

  return future;
}
 
Example 2
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 3
Source File: AnimationService.java    From Twire 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 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: LoginActivity.java    From LLApp with Apache License 2.0 6 votes vote down vote up
private void start() {
    AnimationSet animationSet = new AnimationSet(true);
    ScaleAnimation scaleAnimation = new ScaleAnimation(
            1, 0.1f, 1, 0.1f,
            Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    scaleAnimation.setDuration(500);
    animationSet.addAnimation(scaleAnimation);
    animationSet.setFillAfter(true);
    animationSet.setFillBefore(false);
    animationSet.setRepeatCount(0);//设置重复次数
    portrait.startAnimation(scaleAnimation);
    new Handler().postDelayed(
            () -> portrait.setVisibility(View.GONE)
            , 500);
}
 
Example 6
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 7
Source File: InputPanel.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
public ListenableFuture<Void> hide(float x) {
  final SettableFuture<Void> future = new SettableFuture<>();
  float offset = getOffset(x);

  AnimationSet animation = new AnimationSet(true);
  animation.addAnimation(new TranslateAnimation(Animation.ABSOLUTE, offset,
                                                Animation.ABSOLUTE, 0,
                                                Animation.RELATIVE_TO_SELF, 0,
                                                Animation.RELATIVE_TO_SELF, 0));
  animation.addAnimation(new AlphaAnimation(1, 0));

  animation.setDuration(MicrophoneRecorderView.ANIMATION_DURATION);
  animation.setFillBefore(true);
  animation.setFillAfter(false);

  slideToCancelView.postDelayed(() -> future.set(null), MicrophoneRecorderView.ANIMATION_DURATION);
  slideToCancelView.setVisibility(View.GONE);
  slideToCancelView.startAnimation(animation);

  return future;
}
 
Example 8
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 9
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 10
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 11
Source File: ShowFullScreenQrView.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public void showPicFromPosition(final String content,
		final Bitmap placeHolder, final int x, final int y, final int width) {
	initView();
	setVisibility(View.VISIBLE);
	iv.setVisibility(View.INVISIBLE);
	ivPlaceHolder.setImageBitmap(placeHolder);
	final int size = Math.min(screenHeight, screenWidth);
	new Thread() {
		public void run() {
			final Bitmap bmp = Qr.bitmap(content, size);
			post(new Runnable() {
				@Override
				public void run() {
					iv.setImageBitmap(bmp);
					iv.setVisibility(View.VISIBLE);
				}
			});
		};
	}.start();
	AlphaAnimation animAlpha = new AlphaAnimation(0, 1);
	animAlpha.setDuration(AnimationDuration);
	vMask.startAnimation(animAlpha);
	int toX = 0;
	int toY = (screenHeight - statusBarHeight - screenWidth) / 2
			+ statusBarHeight;
	int toWidth = UIUtil.getScreenWidth();
	float scale = (float) width / (float) toWidth;
	ScaleAnimation animScale = new ScaleAnimation(scale, 1, scale, 1);
	animScale.setDuration(AnimationDuration);
	TranslateAnimation animTrans = new TranslateAnimation(x - toX, 0, y
			- toY, 0);
	animTrans.setDuration(AnimationDuration);
	AnimationSet animSet = new AnimationSet(true);
	animSet.setFillBefore(true);
	animSet.setDuration(AnimationDuration);
	animSet.addAnimation(animScale);
	animSet.addAnimation(animTrans);
	flImages.startAnimation(animSet);
}
 
Example 12
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 13
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;
}