use of android.view.animation.LinearInterpolator in project UltimateAndroid by cymcsg.
the class DropDownListView method initDropDownStyle.
/**
* init drop down style, only init once
*/
private void initDropDownStyle() {
if (headerLayout != null) {
if (isDropDownStyle) {
addHeaderView(headerLayout);
} else {
removeHeaderView(headerLayout);
}
return;
}
if (!isDropDownStyle) {
return;
}
headerReleaseMinDistance = context.getResources().getDimensionPixelSize(R.dimen.drop_down_list_header_release_min_distance);
flipAnimation = new RotateAnimation(0, 180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
flipAnimation.setInterpolator(new LinearInterpolator());
flipAnimation.setDuration(250);
flipAnimation.setFillAfter(true);
reverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
reverseFlipAnimation.setInterpolator(new LinearInterpolator());
reverseFlipAnimation.setDuration(250);
reverseFlipAnimation.setFillAfter(true);
headerDefaultText = context.getString(R.string.drop_down_list_header_default_text);
headerPullText = context.getString(R.string.drop_down_list_header_pull_text);
headerReleaseText = context.getString(R.string.drop_down_list_header_release_text);
headerLoadingText = context.getString(R.string.drop_down_list_header_loading_text);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
headerLayout = (RelativeLayout) inflater.inflate(R.layout.drop_down_list_header, this, false);
headerText = (TextView) headerLayout.findViewById(R.id.drop_down_list_header_default_text);
headerImage = (ImageView) headerLayout.findViewById(R.id.drop_down_list_header_image);
headerProgressBar = (ProgressBar) headerLayout.findViewById(R.id.drop_down_list_header_progress_bar);
headerSecondText = (TextView) headerLayout.findViewById(R.id.drop_down_list_header_second_text);
headerLayout.setClickable(true);
headerLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onDropDown();
}
});
headerText.setText(headerDefaultText);
addHeaderView(headerLayout);
measureHeaderLayout(headerLayout);
headerOriginalHeight = headerLayout.getMeasuredHeight();
headerOriginalTopPadding = headerLayout.getPaddingTop();
currentHeaderStatus = HEADER_STATUS_CLICK_TO_LOAD;
}
use of android.view.animation.LinearInterpolator in project UltimateAndroid by cymcsg.
the class DownloadProgressBar method setupAnimations.
private void setupAnimations() {
mOvershootInterpolator = new OvershootInterpolator(mOvershootValue);
mArrowLineToDot = ValueAnimator.ofFloat(0, mRadius / 4);
mArrowLineToDot.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mArrowLineToDotAnimatedValue = (float) valueAnimator.getAnimatedValue();
invalidate();
}
});
mArrowLineToDot.setDuration(200);
mArrowLineToDot.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
mState = State.ANIMATING_LINE_TO_DOT;
if (mOnProgressUpdateListener != null) {
mOnProgressUpdateListener.onAnimationStarted();
}
}
@Override
public void onAnimationEnd(Animator animator) {
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
mArrowLineToDot.setInterpolator(new AccelerateInterpolator());
mArrowLineToHorizontalLine = ValueAnimator.ofFloat(0, mRadius / 2);
mArrowLineToHorizontalLine.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mArrowLineToHorizontalLineAnimatedValue = (float) valueAnimator.getAnimatedValue();
invalidate();
}
});
mArrowLineToHorizontalLine.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
mArrowLineToHorizontalLine.setDuration(600);
mArrowLineToHorizontalLine.setStartDelay(400);
mArrowLineToHorizontalLine.setInterpolator(mOvershootInterpolator);
mDotToProgressAnimation = ValueAnimator.ofFloat(0, mRadius);
mDotToProgressAnimation.setDuration(600);
mDotToProgressAnimation.setStartDelay(600);
mDotToProgressAnimation.setInterpolator(mOvershootInterpolator);
mDotToProgressAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mDotToProgressAnimatedValue = (float) valueAnimator.getAnimatedValue();
invalidate();
}
});
mDotToProgressAnimation.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
if (mWhichProgress == State.ANIMATING_PROGRESS)
mProgressAnimationSet.start();
else if (mWhichProgress == State.ANIMATING_MANUAL_PROGRESS)
mManualProgressAnimationSet.start();
mState = mWhichProgress;
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
mArrowToLineAnimatorSet = new AnimatorSet();
mArrowToLineAnimatorSet.playTogether(mArrowLineToDot, mArrowLineToHorizontalLine, mDotToProgressAnimation);
mProgressAnimation = ValueAnimator.ofFloat(0, 360f);
mProgressAnimation.setStartDelay(500);
mProgressAnimation.setInterpolator(new LinearInterpolator());
mProgressAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mCurrentGlobalProgressValue = (float) valueAnimator.getAnimatedValue();
if (mOnProgressUpdateListener != null) {
mOnProgressUpdateListener.onProgressUpdate(mCurrentGlobalProgressValue);
}
invalidate();
}
});
mProgressAnimation.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
mDotToProgressAnimatedValue = 0;
}
@Override
public void onAnimationEnd(Animator animator) {
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
mProgressAnimation.setDuration(mProgressDuration);
mManualProgressAnimation = ValueAnimator.ofFloat(mFromArc, mToArc);
mManualProgressAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mCurrentGlobalManualProgressValue = (float) valueAnimator.getAnimatedValue();
invalidate();
}
});
mManualProgressAnimation.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
if (mOnProgressUpdateListener != null) {
mOnProgressUpdateListener.onManualProgressStarted();
}
mDotToProgressAnimatedValue = 0;
}
@Override
public void onAnimationEnd(Animator animator) {
if (mOnProgressUpdateListener != null) {
mOnProgressUpdateListener.onManualProgressEnded();
}
if (mToArc > 359) {
mCollapseAnimation.start();
}
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
mExpandAnimation = ValueAnimator.ofFloat(0, mRadius / 6);
mExpandAnimation.setDuration(300);
mExpandAnimation.setInterpolator(new DecelerateInterpolator());
mExpandAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mExpandCollapseValue = (float) animation.getAnimatedValue();
invalidate();
}
});
mCollapseAnimation = ValueAnimator.ofFloat(mRadius / 6, mStrokeWidth / 2);
mCollapseAnimation.setDuration(300);
mCollapseAnimation.setStartDelay(300);
mCollapseAnimation.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
if (mState == State.ANIMATING_MANUAL_PROGRESS) {
if (mResultState == State.ANIMATING_ERROR) {
mErrorAnimation.start();
} else if (mResultState == State.ANIMATING_SUCCESS) {
mSuccessAnimation.start();
}
}
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
mCollapseAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
mCollapseAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mExpandCollapseValue = (float) animation.getAnimatedValue();
invalidate();
}
});
mManualProgressAnimationSet = new AnimatorSet();
mManualProgressAnimationSet.playSequentially(mExpandAnimation, mManualProgressAnimation);
mProgressAnimationSet = new AnimatorSet();
mProgressAnimationSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
if (mResultState == State.ANIMATING_ERROR) {
mErrorAnimation.start();
} else if (mResultState == State.ANIMATING_SUCCESS) {
mSuccessAnimation.start();
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
mProgressAnimationSet.playSequentially(mExpandAnimation, mProgressAnimation, mCollapseAnimation);
mErrorAnimation = ValueAnimator.ofFloat(0, mRadius / 4);
mErrorAnimation.setDuration(600);
mErrorAnimation.setStartDelay(500);
mErrorAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
mErrorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mErrorValue = (float) valueAnimator.getAnimatedValue();
invalidate();
}
});
mErrorAnimation.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
mState = State.ANIMATING_ERROR;
if (mOnProgressUpdateListener != null) {
mOnProgressUpdateListener.onAnimationError();
}
}
@Override
public void onAnimationEnd(Animator animator) {
postDelayed(new Runnable() {
@Override
public void run() {
if (mOnProgressUpdateListener != null) {
mOnProgressUpdateListener.onAnimationEnded();
}
mState = State.IDLE;
resetValues();
invalidate();
}
}, mResultDuration);
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
mSuccessAnimation = ValueAnimator.ofFloat(0, mRadius / 4);
mSuccessAnimation.setDuration(600);
mSuccessAnimation.setStartDelay(500);
mSuccessAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
mSuccessAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mSuccessValue = (float) valueAnimator.getAnimatedValue();
invalidate();
}
});
mSuccessAnimation.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
mState = State.ANIMATING_SUCCESS;
if (mOnProgressUpdateListener != null) {
mOnProgressUpdateListener.onAnimationSuccess();
}
}
@Override
public void onAnimationEnd(Animator animator) {
postDelayed(new Runnable() {
@Override
public void run() {
if (mOnProgressUpdateListener != null) {
mOnProgressUpdateListener.onAnimationEnded();
}
mState = State.IDLE;
resetValues();
invalidate();
}
}, mResultDuration);
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
}
use of android.view.animation.LinearInterpolator in project UltimateAndroid by cymcsg.
the class DropDownListView method initDropDownStyle.
/**
* init drop down style, only init once
*/
private void initDropDownStyle() {
if (headerLayout != null) {
if (isDropDownStyle) {
addHeaderView(headerLayout);
} else {
removeHeaderView(headerLayout);
}
return;
}
if (!isDropDownStyle) {
return;
}
headerReleaseMinDistance = context.getResources().getDimensionPixelSize(R.dimen.drop_down_list_header_release_min_distance);
flipAnimation = new RotateAnimation(0, 180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
flipAnimation.setInterpolator(new LinearInterpolator());
flipAnimation.setDuration(250);
flipAnimation.setFillAfter(true);
reverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
reverseFlipAnimation.setInterpolator(new LinearInterpolator());
reverseFlipAnimation.setDuration(250);
reverseFlipAnimation.setFillAfter(true);
headerDefaultText = context.getString(R.string.drop_down_list_header_default_text);
headerPullText = context.getString(R.string.drop_down_list_header_pull_text);
headerReleaseText = context.getString(R.string.drop_down_list_header_release_text);
headerLoadingText = context.getString(R.string.drop_down_list_header_loading_text);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
headerLayout = (RelativeLayout) inflater.inflate(R.layout.drop_down_list_header, this, false);
headerText = (TextView) headerLayout.findViewById(R.id.drop_down_list_header_default_text);
headerImage = (ImageView) headerLayout.findViewById(R.id.drop_down_list_header_image);
headerProgressBar = (ProgressBar) headerLayout.findViewById(R.id.drop_down_list_header_progress_bar);
headerSecondText = (TextView) headerLayout.findViewById(R.id.drop_down_list_header_second_text);
headerLayout.setClickable(true);
headerLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onDropDown();
}
});
headerText.setText(headerDefaultText);
addHeaderView(headerLayout);
measureHeaderLayout(headerLayout);
headerOriginalHeight = headerLayout.getMeasuredHeight();
headerOriginalTopPadding = headerLayout.getPaddingTop();
currentHeaderStatus = HEADER_STATUS_CLICK_TO_LOAD;
}
use of android.view.animation.LinearInterpolator in project UltimateAndroid by cymcsg.
the class SwitchAnimationUtil method runHorizonRightAnimation.
private void runHorizonRightAnimation(View view, long delay) {
view.setAlpha(0);
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "translationX", ViewUtils.getScreenWidth(), 0);
objectAnimator.setInterpolator(new LinearInterpolator());
ObjectAnimator objectAnimatorAlpha = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
AnimatorSet set = new AnimatorSet();
set.setStartDelay(delay);
set.setDuration(mDuration);
set.playTogether(objectAnimator, objectAnimatorAlpha);
set.start();
}
use of android.view.animation.LinearInterpolator in project Depth-LIB-Android- by danielzeller.
the class PathBitmapMesh method startWaveAnim.
private void startWaveAnim(Bitmap bitmap, float waves, int animDuration) {
pathOffset = ValueAnimator.ofFloat(0, ((bitmap.getWidth() / waves) * 2f) / bitmap.getWidth()).setDuration(animDuration);
pathOffset.setRepeatCount(ValueAnimator.INFINITE);
pathOffset.setRepeatMode(ValueAnimator.RESTART);
pathOffset.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
pathOffsetPercent = (float) animation.getAnimatedValue();
}
});
pathOffset.setInterpolator(new LinearInterpolator());
pathOffset.start();
}
Aggregations