Java Code Examples for android.view.animation.Animation#AnimationListener

The following examples show how to use android.view.animation.Animation#AnimationListener . 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: LingjuSwipeUpLoadRefreshLayout.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
private void startScaleDownReturnToStartAnimation(final CircleImageView view, int from,
                                                  Animation.AnimationListener listener) {
    mFrom = from;
    if (isAlphaUsedForScale()) {
        mStartingScale = bProgress.getAlpha();
    } else {
        mStartingScale = ViewCompat.getScaleX(view);
    }
    mScaleDownToStartAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            float targetScale = (mStartingScale + (-mStartingScale * interpolatedTime));
            setAnimationProgress(view, targetScale);
            moveToStart(interpolatedTime);
        }
    };
    mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
    if (listener != null) {
        view.setAnimationListener(listener);
    }
    view.clearAnimation();
    view.startAnimation(mScaleDownToStartAnimation);
}
 
Example 2
Source File: CommonUtils.java    From CommonUtils with Apache License 2.0 6 votes vote down vote up
public static void collapse(@NonNull final View v, @Nullable Animation.AnimationListener listener) {
    final int initialHeight = v.getMeasuredHeight();

    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
                v.setVisibility(View.GONE);
            } else {
                v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    if (listener != null) a.setAnimationListener(listener);

    a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
 
Example 3
Source File: SwipeRefresh.java    From Android-Application-ZJB with Apache License 2.0 6 votes vote down vote up
private void animateOffsetToStartPosition(int from, Animation.AnimationListener listener) {
    if (mScale) {
        // Scale the item back down
        startScaleDownReturnToStartAnimation(from, listener);
    } else {
        mFrom = from;
        mAnimateToStartPosition.reset();
        mAnimateToStartPosition.setDuration(ANIMATE_TO_START_DURATION);
        mAnimateToStartPosition.setInterpolator(mDecelerateInterpolator);
        if (listener != null) {
            mCircleView.setAnimationListener(listener);
        }
        mCircleView.clearAnimation();
        mCircleView.startAnimation(mAnimateToStartPosition);
    }
}
 
Example 4
Source File: MySwipeRefreshLayout.java    From Cotable with Apache License 2.0 5 votes vote down vote up
private void animateOffsetToCorrectPosition(int from, Animation.AnimationListener listener) {
    mFrom = from;
    mAnimateToCorrectPosition.reset();
    mAnimateToCorrectPosition.setDuration(ANIMATE_TO_TRIGGER_DURATION);
    mAnimateToCorrectPosition.setInterpolator(mDecelerateInterpolator);
    if (listener != null) {
        mCircleView.setAnimationListener(listener);
    }
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mAnimateToCorrectPosition);
}
 
Example 5
Source File: MaterialRefreshLayout.java    From NestRefreshLayout with MIT License 5 votes vote down vote up
private void animateOffsetToCorrectPosition(Animation.AnimationListener listener) {
    mAnimateToCorrectPosition.reset();
    mAnimateToCorrectPosition.setDuration(ANIMATE_TO_TRIGGER_DURATION);
    mAnimateToCorrectPosition.setInterpolator(mDecelerateInterpolator);
    if (listener != null)
        mCircleView.setAnimationListener(listener);
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mAnimateToCorrectPosition);
}
 
Example 6
Source File: AnimationUtils.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
/**
 * 获取一个缩小动画
 *
 * @param durationMillis    时间
 * @param animationListener 监听
 * @return 一个缩小动画
 */
public static ScaleAnimation getLessenScaleAnimation(long durationMillis, Animation.AnimationListener animationListener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.0f, 1.0f,
            0.0f, ScaleAnimation.RELATIVE_TO_SELF,
            ScaleAnimation.RELATIVE_TO_SELF);
    scaleAnimation.setDuration(durationMillis);
    scaleAnimation.setAnimationListener(animationListener);

    return scaleAnimation;
}
 
Example 7
Source File: SwipeRefreshLayout.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
private void startScaleDownAnimation(Animation.AnimationListener listener) {
    mScaleDownAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(1 - interpolatedTime);
        }
    };
    mScaleDownAnimation.setDuration(SCALE_DOWN_DURATION);
    mCircleView.setAnimationListener(listener);
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mScaleDownAnimation);
}
 
Example 8
Source File: SwipeRefreshLayout.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
private void startScaleDownAnimation(Animation.AnimationListener listener) {
    mScaleDownAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(1 - interpolatedTime);
        }
    };
    mScaleDownAnimation.setDuration(SCALE_DOWN_DURATION);
    mCircleView.setAnimationListener(listener);
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mScaleDownAnimation);
}
 
Example 9
Source File: ExpandableLayout.java    From BaseProject with Apache License 2.0 4 votes vote down vote up
@Override
public void setLayoutAnimationListener(Animation.AnimationListener animationListener) {
    animation.setAnimationListener(animationListener);
}
 
Example 10
Source File: CircleImageView.java    From fangzhuishushenqi with Apache License 2.0 4 votes vote down vote up
public void setAnimationListener(Animation.AnimationListener listener) {
    mListener = listener;
}
 
Example 11
Source File: ShadowAnimation.java    From materialistic with Apache License 2.0 4 votes vote down vote up
public Animation.AnimationListener getAnimationListener() {
    return listener;
}
 
Example 12
Source File: GoogleCircleProgressView.java    From PicKing with Apache License 2.0 4 votes vote down vote up
public void setAnimationListener(Animation.AnimationListener listener) {
    mListener = listener;
}
 
Example 13
Source File: MaterialProgressBar.java    From KUAS-AP-Material with MIT License 4 votes vote down vote up
public void setAnimationListener(Animation.AnimationListener listener) {
	mListener = listener;
}
 
Example 14
Source File: CircleProgressBar.java    From MousePaint with MIT License 4 votes vote down vote up
public void setAnimationListener(Animation.AnimationListener listener) {
    mListener = listener;
}
 
Example 15
Source File: CircleProgressBar.java    From styT with Apache License 2.0 4 votes vote down vote up
public void setAnimationListener(Animation.AnimationListener listener) {
    mListener = listener;
}
 
Example 16
Source File: CircleImageView.java    From AndroidStudyDemo with GNU General Public License v2.0 4 votes vote down vote up
public void setAnimationListener(Animation.AnimationListener listener) {
    mListener = listener;
}
 
Example 17
Source File: SwipyCircleImageView.java    From AndroidStudyDemo with GNU General Public License v2.0 4 votes vote down vote up
public void setAnimationListener(Animation.AnimationListener listener) {
    mListener = listener;
}
 
Example 18
Source File: RevealLayout.java    From RevealLayout with Apache License 2.0 4 votes vote down vote up
public void hide(@Nullable Animation.AnimationListener listener) {
    hide(DEFAULT_DURATION, listener);
}
 
Example 19
Source File: AnimationUtils.java    From SprintNBA with Apache License 2.0 2 votes vote down vote up
/**
 * 获取一个根据视图自身中心点旋转的动画
 *
 * @param durationMillis    动画持续时间
 * @param animationListener 动画监听器
 * @return 一个根据中心点旋转的动画
 */
public static RotateAnimation getRotateAnimationByCenter(long durationMillis, Animation.AnimationListener animationListener) {
    return getRotateAnimation(0f, 359f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f, durationMillis,
            animationListener);
}
 
Example 20
Source File: AnimationUtils.java    From SprintNBA with Apache License 2.0 2 votes vote down vote up
/**
 * 获取一个由完全显示变为不可见的透明度渐变动画
 *
 * @param durationMillis    持续时间
 * @param animationListener 动画监听器
 * @return 一个由完全显示变为不可见的透明度渐变动画
 */
public static AlphaAnimation getHiddenAlphaAnimation(long durationMillis, Animation.AnimationListener animationListener) {
    return getAlphaAnimation(1.0f, 0.0f, durationMillis, animationListener);
}