use of android.view.animation.LinearInterpolator in project wire-android by wireapp.
the class GlyphProgressView method startEndlessProgress.
public void startEndlessProgress() {
if (endlessValueAnimator != null && endlessValueAnimator.isRunning()) {
return;
}
endlessValueAnimator = ValueAnimator.ofInt(0, 360);
endlessValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
startAngle = (int) animation.getAnimatedValue();
invalidate();
}
});
progress = ENDLESS_PROGRESS_VALUE;
endlessValueAnimator.setDuration(1500);
endlessValueAnimator.setInterpolator(new LinearInterpolator());
endlessValueAnimator.setRepeatCount(ValueAnimator.INFINITE);
endlessValueAnimator.start();
}
use of android.view.animation.LinearInterpolator in project react-native-navigation by wix.
the class ScreenAnimator method createHideAnimator.
private Animator createHideAnimator(final Runnable onAnimationEnd) {
ObjectAnimator alpha = ObjectAnimator.ofFloat(screen, View.ALPHA, 0);
alpha.setInterpolator(new LinearInterpolator());
alpha.setStartDelay(100);
alpha.setDuration(150);
ObjectAnimator translationY = ObjectAnimator.ofFloat(screen, View.TRANSLATION_Y, this.translationY);
translationY.setInterpolator(new AccelerateInterpolator());
translationY.setDuration(250);
AnimatorSet set = new AnimatorSet();
set.playTogether(translationY, alpha);
set.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
onAnimationEnd.run();
}
});
return set;
}
use of android.view.animation.LinearInterpolator in project smartmodule by carozhu.
the class LVCircularSmile method startViewAnim.
private ValueAnimator startViewAnim(float startF, final float endF, long time) {
valueAnimator = ValueAnimator.ofFloat(startF, endF);
valueAnimator.setDuration(time);
valueAnimator.setInterpolator(new LinearInterpolator());
//无限循环
valueAnimator.setRepeatCount(ValueAnimator.INFINITE);
valueAnimator.setRepeatMode(ValueAnimator.RESTART);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mAnimatedValue = (float) valueAnimator.getAnimatedValue();
if (mAnimatedValue < 0.5) {
isSmile = false;
startAngle = 720 * mAnimatedValue;
} else {
startAngle = 720;
isSmile = true;
}
invalidate();
}
});
valueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
}
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
}
@Override
public void onAnimationRepeat(Animator animation) {
super.onAnimationRepeat(animation);
}
});
if (!valueAnimator.isRunning()) {
valueAnimator.start();
}
return valueAnimator;
}
use of android.view.animation.LinearInterpolator in project android_frameworks_base by crdroidandroid.
the class StackView method handlePointerUp.
private void handlePointerUp(MotionEvent ev) {
int pointerIndex = ev.findPointerIndex(mActivePointerId);
float newY = ev.getY(pointerIndex);
int deltaY = (int) (newY - mInitialY);
mLastInteractionTime = System.currentTimeMillis();
if (mVelocityTracker != null) {
mVelocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
mYVelocity = (int) mVelocityTracker.getYVelocity(mActivePointerId);
}
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
mVelocityTracker = null;
}
if (deltaY > mSwipeThreshold && mSwipeGestureType == GESTURE_SLIDE_DOWN && mStackSlider.mMode == StackSlider.NORMAL_MODE) {
// We reset the gesture variable, because otherwise we will ignore showPrevious() /
// showNext();
mSwipeGestureType = GESTURE_NONE;
// Swipe threshold exceeded, swipe down
if (mStackMode == ITEMS_SLIDE_UP) {
showPrevious();
} else {
showNext();
}
mHighlight.bringToFront();
} else if (deltaY < -mSwipeThreshold && mSwipeGestureType == GESTURE_SLIDE_UP && mStackSlider.mMode == StackSlider.NORMAL_MODE) {
// We reset the gesture variable, because otherwise we will ignore showPrevious() /
// showNext();
mSwipeGestureType = GESTURE_NONE;
// Swipe threshold exceeded, swipe up
if (mStackMode == ITEMS_SLIDE_UP) {
showNext();
} else {
showPrevious();
}
mHighlight.bringToFront();
} else if (mSwipeGestureType == GESTURE_SLIDE_UP) {
// Didn't swipe up far enough, snap back down
int duration;
float finalYProgress = (mStackMode == ITEMS_SLIDE_DOWN) ? 1 : 0;
if (mStackMode == ITEMS_SLIDE_UP || mStackSlider.mMode != StackSlider.NORMAL_MODE) {
duration = Math.round(mStackSlider.getDurationForNeutralPosition());
} else {
duration = Math.round(mStackSlider.getDurationForOffscreenPosition());
}
StackSlider animationSlider = new StackSlider(mStackSlider);
PropertyValuesHolder snapBackY = PropertyValuesHolder.ofFloat("YProgress", finalYProgress);
PropertyValuesHolder snapBackX = PropertyValuesHolder.ofFloat("XProgress", 0.0f);
ObjectAnimator pa = ObjectAnimator.ofPropertyValuesHolder(animationSlider, snapBackX, snapBackY);
pa.setDuration(duration);
pa.setInterpolator(new LinearInterpolator());
pa.start();
} else if (mSwipeGestureType == GESTURE_SLIDE_DOWN) {
// Didn't swipe down far enough, snap back up
float finalYProgress = (mStackMode == ITEMS_SLIDE_DOWN) ? 0 : 1;
int duration;
if (mStackMode == ITEMS_SLIDE_DOWN || mStackSlider.mMode != StackSlider.NORMAL_MODE) {
duration = Math.round(mStackSlider.getDurationForNeutralPosition());
} else {
duration = Math.round(mStackSlider.getDurationForOffscreenPosition());
}
StackSlider animationSlider = new StackSlider(mStackSlider);
PropertyValuesHolder snapBackY = PropertyValuesHolder.ofFloat("YProgress", finalYProgress);
PropertyValuesHolder snapBackX = PropertyValuesHolder.ofFloat("XProgress", 0.0f);
ObjectAnimator pa = ObjectAnimator.ofPropertyValuesHolder(animationSlider, snapBackX, snapBackY);
pa.setDuration(duration);
pa.start();
}
mActivePointerId = INVALID_POINTER;
mSwipeGestureType = GESTURE_NONE;
}
use of android.view.animation.LinearInterpolator in project android_frameworks_base by crdroidandroid.
the class StackView method transformViewForTransition.
/**
* Animate the views between different relative indexes within the {@link AdapterViewAnimator}
*/
void transformViewForTransition(int fromIndex, int toIndex, final View view, boolean animate) {
if (!animate) {
((StackFrame) view).cancelSliderAnimator();
view.setRotationX(0f);
LayoutParams lp = (LayoutParams) view.getLayoutParams();
lp.setVerticalOffset(0);
lp.setHorizontalOffset(0);
}
if (fromIndex == -1 && toIndex == getNumActiveViews() - 1) {
transformViewAtIndex(toIndex, view, false);
view.setVisibility(VISIBLE);
view.setAlpha(1.0f);
} else if (fromIndex == 0 && toIndex == 1) {
// Slide item in
((StackFrame) view).cancelSliderAnimator();
view.setVisibility(VISIBLE);
int duration = Math.round(mStackSlider.getDurationForNeutralPosition(mYVelocity));
StackSlider animationSlider = new StackSlider(mStackSlider);
animationSlider.setView(view);
if (animate) {
PropertyValuesHolder slideInY = PropertyValuesHolder.ofFloat("YProgress", 0.0f);
PropertyValuesHolder slideInX = PropertyValuesHolder.ofFloat("XProgress", 0.0f);
ObjectAnimator slideIn = ObjectAnimator.ofPropertyValuesHolder(animationSlider, slideInX, slideInY);
slideIn.setDuration(duration);
slideIn.setInterpolator(new LinearInterpolator());
((StackFrame) view).setSliderAnimator(slideIn);
slideIn.start();
} else {
animationSlider.setYProgress(0f);
animationSlider.setXProgress(0f);
}
} else if (fromIndex == 1 && toIndex == 0) {
// Slide item out
((StackFrame) view).cancelSliderAnimator();
int duration = Math.round(mStackSlider.getDurationForOffscreenPosition(mYVelocity));
StackSlider animationSlider = new StackSlider(mStackSlider);
animationSlider.setView(view);
if (animate) {
PropertyValuesHolder slideOutY = PropertyValuesHolder.ofFloat("YProgress", 1.0f);
PropertyValuesHolder slideOutX = PropertyValuesHolder.ofFloat("XProgress", 0.0f);
ObjectAnimator slideOut = ObjectAnimator.ofPropertyValuesHolder(animationSlider, slideOutX, slideOutY);
slideOut.setDuration(duration);
slideOut.setInterpolator(new LinearInterpolator());
((StackFrame) view).setSliderAnimator(slideOut);
slideOut.start();
} else {
animationSlider.setYProgress(1.0f);
animationSlider.setXProgress(0f);
}
} else if (toIndex == 0) {
// Make sure this view that is "waiting in the wings" is invisible
view.setAlpha(0.0f);
view.setVisibility(INVISIBLE);
} else if ((fromIndex == 0 || fromIndex == 1) && toIndex > 1) {
view.setVisibility(VISIBLE);
view.setAlpha(1.0f);
view.setRotationX(0f);
LayoutParams lp = (LayoutParams) view.getLayoutParams();
lp.setVerticalOffset(0);
lp.setHorizontalOffset(0);
} else if (fromIndex == -1) {
view.setAlpha(1.0f);
view.setVisibility(VISIBLE);
} else if (toIndex == -1) {
if (animate) {
postDelayed(new Runnable() {
public void run() {
view.setAlpha(0);
}
}, STACK_RELAYOUT_DURATION);
} else {
view.setAlpha(0f);
}
}
// Implement the faked perspective
if (toIndex != -1) {
transformViewAtIndex(toIndex, view, animate);
}
}
Aggregations