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

The following examples show how to use android.view.animation.Animation.AnimationListener. These examples are extracted from open source projects. 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
private void startScaleUpAnimation(AnimationListener listener) {
    mHeadViewContainer.setVisibility(View.VISIBLE);
    mScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime,
                                        Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        mHeadViewContainer.setAnimationListener(listener);
    }
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mScaleAnimation);
}
 
Example 2
private void animateOffsetToStartPosition(int from,
                                          AnimationListener listener) {
    if (mScale) {
        startScaleDownReturnToStartAnimation(from, listener);
    } else {
        mFrom = from;
        mAnimateToStartPosition.reset();
        mAnimateToStartPosition.setDuration(ANIMATE_TO_START_DURATION);
        mAnimateToStartPosition.setInterpolator(mDecelerateInterpolator);
        if (listener != null) {
            mHeadViewContainer.setAnimationListener(listener);
        }
        mHeadViewContainer.clearAnimation();
        mHeadViewContainer.startAnimation(mAnimateToStartPosition);
    }
    resetTargetLayoutDelay(ANIMATE_TO_START_DURATION);
}
 
Example 3
private void startScaleDownReturnToStartAnimation(int from,
                                                  AnimationListener listener) {
    mFrom = from;
    mStartingScale = ViewCompat.getScaleX(mHeadViewContainer);
    mScaleDownToStartAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime,
                                        Transformation t) {
            float targetScale = (mStartingScale + (-mStartingScale * interpolatedTime));
            setAnimationProgress(targetScale);
            moveToStart(interpolatedTime);
        }
    };
    mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
    if (listener != null) {
        mHeadViewContainer.setAnimationListener(listener);
    }
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mScaleDownToStartAnimation);
}
 
Example 4
Source Project: NewFastFrame   Source File: CustomSwipeRefreshLayout.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressLint("NewApi")
private void startScaleUpAnimation(AnimationListener listener) {
    mCircleView.setVisibility(View.VISIBLE);
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        // Pre API 11, alpha is used in place of scale up to show the
        // progress circle appearing.
        // Don't adjust the alpha during appearance otherwise.
        mProgress.setAlpha(MAX_ALPHA);
    }
    mScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        mCircleView.setAnimationListener(listener);
    }
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mScaleAnimation);
}
 
Example 5
private void startScaleDownReturnToStartAnimation(int from,
        Animation.AnimationListener listener) {
    mFrom = from;
    if (isAlphaUsedForScale()) {
        mStartingScale = mProgress.getAlpha();
    } else {
        mStartingScale = ViewCompat.getScaleX(mCircleView);
    }
    mScaleDownToStartAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            float targetScale = (mStartingScale + (-mStartingScale  * interpolatedTime));
            setAnimationProgress(targetScale);
            moveToStart(interpolatedTime);
        }
    };
    mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
    if (listener != null) {
        mCircleView.setAnimationListener(listener);
    }
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mScaleDownToStartAnimation);
}
 
Example 6
Source Project: NewFastFrame   Source File: CustomSwipeRefreshLayout.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressLint("NewApi")
private void startScaleDownReturnToStartAnimation(int from,
                                                  AnimationListener listener) {
    mFrom = from;
    if (isAlphaUsedForScale()) {
        mStartingScale = mProgress.getAlpha();
    } else {
        mStartingScale = ViewCompat.getScaleX(mCircleView);
    }
    mScaleDownToStartAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            float targetScale = (mStartingScale + (-mStartingScale * interpolatedTime));
            setAnimationProgress(targetScale);
            moveToStart(interpolatedTime);
        }
    };
    mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
    if (listener != null) {
        mCircleView.setAnimationListener(listener);
    }
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mScaleDownToStartAnimation);
}
 
Example 7
Source Project: fangzhuishushenqi   Source File: SwipeRefreshLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void startScaleUpAnimation(AnimationListener listener) {
    mCircleView.setVisibility(View.VISIBLE);
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        // Pre API 11, alpha is used in place of scale up to show the
        // progress circle appearing.
        // Don't adjust the alpha during appearance otherwise.
        mProgress.setAlpha(MAX_ALPHA);
    }
    mScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        mCircleView.setAnimationListener(listener);
    }
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mScaleAnimation);
}
 
Example 8
Source Project: fangzhuishushenqi   Source File: SwipeRefreshLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void animateOffsetToStartPosition(int from, 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 9
Source Project: fangzhuishushenqi   Source File: SwipeRefreshLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void startScaleDownReturnToStartAnimation(int from,
        AnimationListener listener) {
    mFrom = from;
    if (isAlphaUsedForScale()) {
        mStartingScale = mProgress.getAlpha();
    } else {
        mStartingScale = ViewCompat.getScaleX(mCircleView);
    }
    mScaleDownToStartAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            float targetScale = (mStartingScale + (-mStartingScale  * interpolatedTime));
            setAnimationProgress(targetScale);
            moveToStart(interpolatedTime);
        }
    };
    mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
    if (listener != null) {
        mCircleView.setAnimationListener(listener);
    }
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mScaleDownToStartAnimation);
}
 
Example 10
Source Project: Ticket-Analysis   Source File: SuperSwipeRefreshLayout.java    License: MIT License 6 votes vote down vote up
private void startScaleUpAnimation(AnimationListener listener) {
    mHeadViewContainer.setVisibility(View.VISIBLE);
    mScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime,
                                        Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        mHeadViewContainer.setAnimationListener(listener);
    }
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mScaleAnimation);
}
 
Example 11
Source Project: Ticket-Analysis   Source File: SuperSwipeRefreshLayout.java    License: MIT License 6 votes vote down vote up
private void animateOffsetToStartPosition(int from,
                                          AnimationListener listener) {
    if (mScale) {
        startScaleDownReturnToStartAnimation(from, listener);
    } else {
        mFrom = from;
        mAnimateToStartPosition.reset();
        mAnimateToStartPosition.setDuration(ANIMATE_TO_START_DURATION);
        mAnimateToStartPosition.setInterpolator(mDecelerateInterpolator);
        if (listener != null) {
            mHeadViewContainer.setAnimationListener(listener);
        }
        mHeadViewContainer.clearAnimation();
        mHeadViewContainer.startAnimation(mAnimateToStartPosition);
    }
    resetTargetLayoutDelay(ANIMATE_TO_START_DURATION);
}
 
Example 12
Source Project: Ticket-Analysis   Source File: SuperSwipeRefreshLayout.java    License: MIT License 6 votes vote down vote up
private void startScaleDownReturnToStartAnimation(int from,
                                                  AnimationListener listener) {
    mFrom = from;
    mStartingScale = ViewCompat.getScaleX(mHeadViewContainer);
    mScaleDownToStartAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime,
                                        Transformation t) {
            float targetScale = (mStartingScale + (-mStartingScale * interpolatedTime));
            setAnimationProgress(targetScale);
            moveToStart(interpolatedTime);
        }
    };
    mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
    if (listener != null) {
        mHeadViewContainer.setAnimationListener(listener);
    }
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mScaleDownToStartAnimation);
}
 
Example 13
Source Project: letv   Source File: SwipeRefreshLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void startScaleUpAnimation(AnimationListener listener) {
    this.mCircleView.setVisibility(0);
    if (VERSION.SDK_INT >= 11) {
        this.mProgress.setAlpha(255);
    }
    this.mScaleAnimation = new Animation() {
        public void applyTransformation(float interpolatedTime, Transformation t) {
            SwipeRefreshLayout.this.setAnimationProgress(interpolatedTime);
        }
    };
    this.mScaleAnimation.setDuration((long) this.mMediumAnimationDuration);
    if (listener != null) {
        this.mCircleView.setAnimationListener(listener);
    }
    this.mCircleView.clearAnimation();
    this.mCircleView.startAnimation(this.mScaleAnimation);
}
 
Example 14
Source Project: letv   Source File: SwipeRefreshLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void startScaleDownReturnToStartAnimation(int from, AnimationListener listener) {
    this.mFrom = from;
    if (isAlphaUsedForScale()) {
        this.mStartingScale = (float) this.mProgress.getAlpha();
    } else {
        this.mStartingScale = ViewCompat.getScaleX(this.mCircleView);
    }
    this.mScaleDownToStartAnimation = new Animation() {
        public void applyTransformation(float interpolatedTime, Transformation t) {
            SwipeRefreshLayout.this.setAnimationProgress(SwipeRefreshLayout.this.mStartingScale + ((-SwipeRefreshLayout.this.mStartingScale) * interpolatedTime));
            SwipeRefreshLayout.this.moveToStart(interpolatedTime);
        }
    };
    this.mScaleDownToStartAnimation.setDuration(150);
    if (listener != null) {
        this.mCircleView.setAnimationListener(listener);
    }
    this.mCircleView.clearAnimation();
    this.mCircleView.startAnimation(this.mScaleDownToStartAnimation);
}
 
Example 15
Source Project: AutoRecycleView   Source File: SuperSwipeRefreshLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void startScaleUpAnimation(AnimationListener listener) {
    mHeadViewContainer.setVisibility(View.VISIBLE);
    mScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime,
                                        Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        mHeadViewContainer.setAnimationListener(listener);
    }
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mScaleAnimation);
}
 
Example 16
Source Project: AutoRecycleView   Source File: SuperSwipeRefreshLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void animateOffsetToStartPosition(int from,
                                          AnimationListener listener) {
    if (mScale) {
        startScaleDownReturnToStartAnimation(from, listener);
    } else {
        mFrom = from;
        mAnimateToStartPosition.reset();
        mAnimateToStartPosition.setDuration(ANIMATE_TO_START_DURATION);
        mAnimateToStartPosition.setInterpolator(mDecelerateInterpolator);
        if (listener != null) {
            mHeadViewContainer.setAnimationListener(listener);
        }
        mHeadViewContainer.clearAnimation();
        mHeadViewContainer.startAnimation(mAnimateToStartPosition);
    }
    resetTargetLayoutDelay(ANIMATE_TO_START_DURATION);
}
 
Example 17
Source Project: AutoRecycleView   Source File: SuperSwipeRefreshLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void startScaleDownReturnToStartAnimation(int from,
                                                  Animation.AnimationListener listener) {
    mFrom = from;
    mStartingScale = ViewCompat.getScaleX(mHeadViewContainer);
    mScaleDownToStartAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime,
                                        Transformation t) {
            float targetScale = (mStartingScale + (-mStartingScale * interpolatedTime));
            setAnimationProgress(targetScale);
            moveToStart(interpolatedTime);
        }
    };
    mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
    if (listener != null) {
        mHeadViewContainer.setAnimationListener(listener);
    }
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mScaleDownToStartAnimation);
}
 
Example 18
private void startScaleUpAnimation(AnimationListener listener) {
    mCircleView.setVisibility(View.VISIBLE);
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        // Pre API 11, alpha is used in place of scale up to show the
        // progress circle appearing.
        // Don't adjust the alpha during appearance otherwise.
        mProgress.setAlpha(MAX_ALPHA);
    }
    mScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        mCircleView.setAnimationListener(listener);
    }
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mScaleAnimation);
}
 
Example 19
private void animateOffsetToStartPosition(int from, 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 20
private void startScaleDownAnimation(AnimationListener listener) {
    mScaleDownAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime,
                                        Transformation t) {
            setAnimationProgress(1 - interpolatedTime);
        }
    };
    mScaleDownAnimation.setDuration(SCALE_DOWN_DURATION);
    mHeadViewContainer.setAnimationListener(listener);
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mScaleDownAnimation);
}
 
Example 21
private void animateOffsetToCorrectPosition(int from,
                                            AnimationListener listener) {
    mFrom = from;
    mAnimateToCorrectPosition.reset();
    mAnimateToCorrectPosition.setDuration(ANIMATE_TO_TRIGGER_DURATION);
    mAnimateToCorrectPosition.setInterpolator(mDecelerateInterpolator);
    if (listener != null) {
        mHeadViewContainer.setAnimationListener(listener);
    }
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mAnimateToCorrectPosition);
}
 
Example 22
Source Project: DevUtils   Source File: AnimationUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取一个旋转动画
 * @param fromDegrees       开始角度
 * @param toDegrees         结束角度
 * @param durationMillis    动画持续时间
 * @param animationListener 动画监听器
 * @return 一个旋转动画
 */
public static RotateAnimation getRotateAnimation(final float fromDegrees, final float toDegrees, final long durationMillis,
                                                 final AnimationListener animationListener) {
    RotateAnimation rotateAnimation = new RotateAnimation(fromDegrees, toDegrees);
    rotateAnimation.setDuration(durationMillis);
    if (animationListener != null) {
        rotateAnimation.setAnimationListener(animationListener);
    }
    return rotateAnimation;
}
 
Example 23
Source Project: DevUtils   Source File: AnimationUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取一个透明度渐变动画
 * @param fromAlpha         开始时的透明度
 * @param toAlpha           结束时的透明度
 * @param durationMillis    动画持续时间
 * @param animationListener 动画监听器
 * @return 一个透明度渐变动画
 */
public static AlphaAnimation getAlphaAnimation(final float fromAlpha, final float toAlpha, final long durationMillis,
                                               final AnimationListener animationListener) {
    AlphaAnimation alphaAnimation = new AlphaAnimation(fromAlpha, toAlpha);
    alphaAnimation.setDuration(durationMillis);
    if (animationListener != null) {
        alphaAnimation.setAnimationListener(animationListener);
    }
    return alphaAnimation;
}
 
Example 24
Source Project: DevUtils   Source File: AnimationUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取一个中心点缩放动画
 * @param fromX             动画开始前在 X 坐标
 * @param toX               动画结束后在 X 坐标
 * @param fromY             动画开始前在 Y 坐标
 * @param toY               动画结束后在 Y 坐标
 * @param durationMillis    动画持续时间
 * @param animationListener 动画监听器
 * @return 一个中心点缩放动画
 */
public static ScaleAnimation getScaleAnimationCenter(final float fromX, final float toX, final float fromY, final float toY,
                                                     final long durationMillis, final AnimationListener animationListener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(fromX, toX, fromY, toY,
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
    scaleAnimation.setDuration(durationMillis);
    if (animationListener != null) {
        scaleAnimation.setAnimationListener(animationListener);
    }
    return scaleAnimation;
}
 
Example 25
Source Project: DevUtils   Source File: AnimationUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取一个缩小动画
 * @param durationMillis    动画持续时间
 * @param animationListener 动画监听器
 * @return 一个缩小动画
 */
public static ScaleAnimation getLessenScaleAnimation(final long durationMillis, final 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);
    if (animationListener != null) {
        scaleAnimation.setAnimationListener(animationListener);
    }
    return scaleAnimation;
}
 
Example 26
Source Project: DevUtils   Source File: AnimationUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取一个放大动画
 * @param durationMillis    动画持续时间
 * @param animationListener 动画监听器
 * @return 一个放大动画
 */
public static ScaleAnimation getAmplificationAnimation(final long durationMillis, final AnimationListener animationListener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f,
            ScaleAnimation.RELATIVE_TO_SELF, ScaleAnimation.RELATIVE_TO_SELF);
    scaleAnimation.setDuration(durationMillis);
    if (animationListener != null) {
        scaleAnimation.setAnimationListener(animationListener);
    }
    return scaleAnimation;
}
 
Example 27
void startScaleUpAnimation(AnimationListener listener) {
    mScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime,
                                        Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        mHeadViewContainer.setAnimationListener(listener);
    }
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mScaleAnimation);
}
 
Example 28
void animateOffsetToCorrectPosition(int from, AnimationListener listener) {
    mFrom = from;
    mAnimateToCorrectPosition.reset();
    mAnimateToCorrectPosition.setDuration(ANIMATE_TO_TRIGGER_DURATION);
    mAnimateToCorrectPosition.setInterpolator(mDecelerateInterpolator);
    if (listener != null) {
        mHeadViewContainer.setAnimationListener(listener);
    }
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mAnimateToCorrectPosition);
}
 
Example 29
void animateOffsetToStartPosition(int from, AnimationListener listener) {
    mFrom = from;
    mAnimateToStartPosition.reset();
    mAnimateToStartPosition.setDuration(ANIMATE_TO_START_DURATION);
    mAnimateToStartPosition.setInterpolator(mDecelerateInterpolator);
    if (listener != null) {
        mHeadViewContainer.setAnimationListener(listener);
    }
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mAnimateToStartPosition);
    resetTargetLayoutDelay(ANIMATE_TO_START_DURATION);
}
 
Example 30
Source Project: HaoReader   Source File: SwipeRefreshLayout.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void animateOffsetToStartPosition(int from, AnimationListener listener) {
    this.mFrom = from;
    this.mAnimateToStartPosition.reset();
    this.mAnimateToStartPosition.setDuration((long) this.mAnimationDuration);
    this.mAnimateToStartPosition.setAnimationListener(listener);
    this.mAnimateToStartPosition.setInterpolator(this.mDecelerateInterpolator);
    this.mTarget.startAnimation(this.mAnimateToStartPosition);
}