Java Code Examples for android.view.animation.AnimationSet.setAnimationListener()

The following are Jave code examples for showing how to use setAnimationListener() of the android.view.animation.AnimationSet class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: ExpandButton   File: ExpandButtonLayout.java   Source Code and License Vote up 7 votes
public void open() {

        AnimationSet animationSet = new AnimationSet(true);
        animationSet.setDuration(duration);
        animationSet.setAnimationListener(this);
        animationSet.setFillAfter(true);

        RotateAnimation rotateAnimation = new RotateAnimation(270, 360,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        animationSet.addAnimation(rotateAnimation);
        Animation scaleAnimation = new ScaleAnimation(1.25f, 1f, 1.25f, 1f,
                ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
        animationSet.addAnimation(scaleAnimation);
        imageView.startAnimation(animationSet);


        AnimatorSet animatorSet = new AnimatorSet();
        ObjectAnimator animator1 = ObjectAnimator.ofInt(mLinearLayout, "width", 0, mLinearLayoutWidth);
        ObjectAnimator animator2 = ObjectAnimator.ofInt(mLinearLayout, "paddingLeft", 0, savePaddingLeft);
        ObjectAnimator animator3 = ObjectAnimator.ofInt(mLinearLayout, "paddingRight", 0, savePaddingRight);
        ObjectAnimator animator4 = ObjectAnimator.ofInt(mLinearLayout, "marginLeft", 0, saveMarginLeft);
        ObjectAnimator animator5 = ObjectAnimator.ofInt(mLinearLayout, "marginRight", 0, saveMarginRight);
        animatorSet.playTogether(animator1, animator2, animator3, animator4, animator5);
        animatorSet.setDuration(duration).start();

    }
 
Example 2
Project: JewelryUI   File: MainActivity.java   Source Code and License Vote up 6 votes
private void slideInUp(View view, Animation.AnimationListener animationListener) {
    AlphaAnimation fadeIn = new AlphaAnimation(0.0f, 1.0f);
    TranslateAnimation transIn = new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.0f);

    final AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(fadeIn);
    animationSet.addAnimation(transIn);
    animationSet.setDuration(200);

    if (animationListener != null) {
        animationSet.setAnimationListener(animationListener);
    }

    view.setVisibility(View.VISIBLE);
    view.clearAnimation();
    view.startAnimation(animationSet);
}
 
Example 3
Project: Pocket-Plays-for-Twitch   File: AnimationService.java   Source Code and License Vote up 5 votes
/**
 * Hides every view in a RecyclerView to simulate clearing the RecyclerView
 * returns how long the animation takes to complete.
 * Returns -1 if there is nothing to animate
 */
public static int animateFakeClearing(int lastVisibleItemPosition, int firstVisibleItemPosition, AutoSpanRecyclerView aRecyclerView, Animation.AnimationListener animationListener, boolean includeTranslation) {
	final int DELAY_BETWEEN = 50;
	int clearingDuration = 0;

	int startPositionCol = getColumnPosFromIndex(firstVisibleItemPosition, aRecyclerView);
	int startPositionRow = getRowPosFromIndex(firstVisibleItemPosition, aRecyclerView);

	for(int i = lastVisibleItemPosition; i >= firstVisibleItemPosition; i--) {
		final View VIEW = aRecyclerView.getChildAt(lastVisibleItemPosition - i);

		int positionColumnDistance = Math.abs(getColumnPosFromIndex(i, aRecyclerView) - startPositionCol);
		int positionRowDistance = Math.abs(getRowPosFromIndex(i, aRecyclerView) - startPositionRow);
		int delay = (positionColumnDistance + positionRowDistance) * DELAY_BETWEEN + 1;

		AnimationSet mHideAnimations = AnimationService.startAlphaHideAnimation(delay, VIEW, includeTranslation);
		if (mHideAnimations == null) {
			return -1;
		}
		int hideAnimationDuration = (int) mHideAnimations.getDuration();

		if (hideAnimationDuration + delay > clearingDuration) {
			clearingDuration = hideAnimationDuration + delay;
		}

		// If the view is the last to animate, then start the intent when the animation finishes.
		if(i == lastVisibleItemPosition && animationListener != null) {
			mHideAnimations.setAnimationListener(animationListener);
		}
	}

	return clearingDuration;
}
 
Example 4
Project: ExpandButton   File: ExpandButtonLayout.java   Source Code and License Vote up 5 votes
public void close() {

        AnimationSet animationSet = new AnimationSet(true);
        animationSet.setDuration(duration);
        animationSet.setAnimationListener(this);
        animationSet.setFillAfter(true);

        RotateAnimation rotateAnimation = new RotateAnimation(360, 270,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        animationSet.addAnimation(rotateAnimation);
        Animation scaleAnimation = new ScaleAnimation(1f, 1.25f, 1f, 1.25f,
                ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
        animationSet.addAnimation(scaleAnimation);
        imageView.startAnimation(animationSet);
        AnimatorSet animatorSet = new AnimatorSet();
        ObjectAnimator animator1 = ObjectAnimator.ofInt(mLinearLayout, "width", mLinearLayoutWidth, 0);
        ObjectAnimator animator2 = ObjectAnimator.ofInt(mLinearLayout, "paddingLeft", savePaddingLeft, 0);
        ObjectAnimator animator3 = ObjectAnimator.ofInt(mLinearLayout, "paddingRight", savePaddingRight, 0);
        ObjectAnimator animator4 = ObjectAnimator.ofInt(mLinearLayout, "marginLeft", saveMarginLeft, 0);
        ObjectAnimator animator5 = ObjectAnimator.ofInt(mLinearLayout, "marginRight", saveMarginRight, 0);
        animatorSet.playTogether(animator1, animator2, animator3, animator4, animator5);
        animatorSet.setDuration(duration).start();

    }