android.view.animation.Animation.AnimationListener Java Examples

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: SwipeRefreshLayout.java    From letv with 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 #2
Source File: SuperSwipeRefreshLayout.java    From AutoRecycleView with 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 #3
Source File: SwipeRefreshLayout.java    From android-source-codes with Creative Commons Attribution 4.0 International 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 #4
Source File: SuperSwipeRefreshLayout.java    From AutoRecycleView with 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 #5
Source File: SuperSwipeRefreshLayout.java    From android-fly-refreshlayout with 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 #6
Source File: SuperSwipeRefreshLayout.java    From AutoRecycleView with 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 #7
Source File: SuperSwipeRefreshLayout.java    From android-fly-refreshlayout with Apache License 2.0 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 #8
Source File: SwipeRefreshLayout.java    From android-source-codes with Creative Commons Attribution 4.0 International 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 File: SwipeRefreshLayout.java    From letv with 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 #10
Source File: SuperSwipeRefreshLayout.java    From Ticket-Analysis with 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 #11
Source File: SuperSwipeRefreshLayout.java    From Ticket-Analysis with 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 File: SuperSwipeRefreshLayout.java    From Ticket-Analysis with 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 #13
Source File: SwipeRefreshLayout.java    From fangzhuishushenqi with 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 #14
Source File: SwipeRefreshLayout.java    From fangzhuishushenqi with 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 #15
Source File: SwipeRefreshLayout.java    From fangzhuishushenqi with 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 #16
Source File: CustomSwipeRefreshLayout.java    From NewFastFrame with 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 #17
Source File: SwipeRefreshLayout.java    From android-source-codes with Creative Commons Attribution 4.0 International 6 votes vote down vote up
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 #18
Source File: CustomSwipeRefreshLayout.java    From NewFastFrame with 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 #19
Source File: SuperSwipeRefreshLayout.java    From android-fly-refreshlayout with 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 #20
Source File: SuperSwipeRefreshLayout.java    From AutoRecycleView 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);
    mHeadViewContainer.setAnimationListener(listener);
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mScaleDownAnimation);
}
 
Example #21
Source File: SwipeRefreshLayout.java    From letv with Apache License 2.0 5 votes vote down vote up
private void animateOffsetToCorrectPosition(int from, AnimationListener listener) {
    this.mFrom = from;
    this.mAnimateToCorrectPosition.reset();
    this.mAnimateToCorrectPosition.setDuration(200);
    this.mAnimateToCorrectPosition.setInterpolator(this.mDecelerateInterpolator);
    if (listener != null) {
        this.mCircleView.setAnimationListener(listener);
    }
    this.mCircleView.clearAnimation();
    this.mCircleView.startAnimation(this.mAnimateToCorrectPosition);
}
 
Example #22
Source File: SwipeRefreshLayout.java    From android-source-codes with Creative Commons Attribution 4.0 International 5 votes vote down vote up
private void finishSpinner(float overscrollTop) {
    if (overscrollTop > mTotalDragDistance) {
        setRefreshing(true, true /* notify */);
    } else {
        // cancel refresh
        mRefreshing = false;
        mProgress.setStartEndTrim(0f, 0f);
        Animation.AnimationListener listener = null;
        if (!mScale) {
            listener = new Animation.AnimationListener() {

                @Override
                public void onAnimationStart(Animation animation) {
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    if (!mScale) {
                        startScaleDownAnimation(null);
                    }
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                }

            };
        }
        animateOffsetToStartPosition(mCurrentTargetOffsetTop, listener);
        mProgress.showArrow(false);
    }
}
 
Example #23
Source File: CustomSwipeRefreshLayout.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
private void animateOffsetToCorrectPosition(int from, 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 #24
Source File: CustomSwipeRefreshLayout.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
void startScaleDownAnimation(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 #25
Source File: SwipeRefreshLayout.java    From android-source-codes with Creative Commons Attribution 4.0 International 5 votes vote down vote up
private void animateOffsetToCorrectPosition(int from, 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 #26
Source File: SwipeRefreshLayout.java    From HaoReader with 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);
}
 
Example #27
Source File: SuperSwipeRefreshLayout.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
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 #28
Source File: SuperSwipeRefreshLayout.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
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
Source File: SuperSwipeRefreshLayout.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
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 #30
Source File: SwipeRefreshLayout.java    From fangzhuishushenqi with Apache License 2.0 5 votes vote down vote up
private void animateOffsetToCorrectPosition(int from, 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);
}