Example usage for android.view.animation Animation Animation

List of usage examples for android.view.animation Animation Animation

Introduction

In this page you can find the example usage for android.view.animation Animation Animation.

Prototype

public Animation() 

Source Link

Document

Creates a new animation with a duration of 0ms, the default interpolator, with fillBefore set to true and fillAfter set to false

Usage

From source file:com.cyan.widget.refreshlayout.RefreshLayout.java

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);/*from ww  w.  j  a v a  2s.c  om*/
    }
    mHeaderScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mHeaderScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        mCircleView.setAnimationListener(listener);
    }
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mHeaderScaleAnimation);
}

From source file:com.xfzbd.cqi.widget.srl.ShyaringanSwipeRefreshLayout.java

@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);// w w w  . j  a  va 2s .  com
    }
    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);
}

From source file:com.callba.phone.widget.refreshlayout.RefreshLayout.java

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 community appearing.
        // Don't adjust the alpha during appearance otherwise.
        mProgress.setAlpha(MAX_ALPHA);//from   ww w.j a v  a2s  .  c  om
    }
    mHeaderScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mHeaderScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        mCircleView.setAnimationListener(listener);
    }
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mHeaderScaleAnimation);
}

From source file:org.alex.swiperefreshlayout.SwipeRefreshLayout.java

protected void startScaleDownAnimation(Animation.AnimationListener listener) {
    scaleDownAnimation = new Animation() {
        @Override/*  w w  w.  j  av  a2s.c o  m*/
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(1 - interpolatedTime);
        }
    };
    scaleDownAnimation.setDuration(SCALE_DOWN_DURATION);
    circleView.setAnimationListener(listener);
    circleView.clearAnimation();
    circleView.startAnimation(scaleDownAnimation);
}

From source file:com.usabusi.swiperefreshlayoutupdown.view.SwipeRefreshLayoutUpDown.java

/**
    * Notify the widget that refresh state has changed. Do not call this when
    * refresh is triggered by a swipe gesture.
    *//  w  w  w.  ja  va 2 s.co  m
    * @param loading Whether or not the view should show load progress.
    */
/*
public void setLoading(boolean loading) {
if (loading && mRefreshing != loading) {
    // scale and show
    mLoading = loading;
    //v21 updown
    mCurrentMode = PullMode.DISABLED;
    int endTarget = 0;
    if (!mUsingCustomStart) {
        endTarget = (int) (mSpinnerFinalOffset + mOriginalOffsetTop);
    } else {
        endTarget = (int) mSpinnerFinalOffset;
    }
    setTargetOffsetTopAndBottom(endTarget - mCurrentTargetOffsetTop,
            true );
    mNotify = false;
    startScaleUpAnimation(mLoadListener);
} else {
    setLoading(loading, false );
}
}
*/
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);
}

From source file:com.develop.autorus.MainActivity.java

public static void expand(final View v) {
    v.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();

    // Older versions of android (pre API 21) cancel animations for views with a height of 0.
    v.getLayoutParams().height = 1;/*  ww  w .j ava2 s .  c o m*/
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1 ? LinearLayout.LayoutParams.WRAP_CONTENT
                    : (int) (targetHeight * interpolatedTime);
            v.requestLayout();
        }

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

    // 1dp/ms
    a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}

From source file:org.alex.refreshlayout.RefreshLayout.java

private Animation startAlphaAnimation(final int startingAlpha, final int endingAlpha) {
    // Pre API 11, alpha is used in place of scale. Don't also use it to
    // show the trigger point.
    if (scale && isAlphaUsedForScale()) {
        return null;
    }/*from w ww  .j a va2s. co  m*/
    Animation alpha = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            progress.setAlpha((int) (startingAlpha + ((endingAlpha - startingAlpha) * interpolatedTime)));
        }
    };
    alpha.setDuration(ALPHA_ANIMATION_DURATION);
    // Clear out the previous animation listeners.
    circleView.setAnimationListener(null);
    circleView.clearAnimation();
    circleView.startAnimation(alpha);
    return alpha;
}

From source file:com.callba.phone.widget.refreshlayout.RefreshLayout.java

private void startScaleDownAnimation(AnimationListener listener) {
    mHeaderScaleDownAnimation = new Animation() {
        @Override//from w w w . j  av  a  2s .com
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(1 - interpolatedTime);
        }
    };
    mHeaderScaleDownAnimation.setDuration(SCALE_DOWN_DURATION);
    mCircleView.setAnimationListener(listener);
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mHeaderScaleDownAnimation);
}

From source file:com.develop.autorus.MainActivity.java

public static void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

    Animation a = new Animation() {
        @Override/*from w w  w. java  2s  .c o  m*/
        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;
        }
    };

    a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}

From source file:com.hippo.refreshlayout.RefreshLayout.java

@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);//from  w  w  w  .j  a  v a2  s.c  om
    }
    mHeaderScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mHeaderScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        mCircleView.setAnimationListener(listener);
    }
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mHeaderScaleAnimation);
}