use of android.animation.TimeInterpolator in project android_frameworks_base by AOSPA.
the class ViewPropertyAnimatorRT method doStartAnimation.
private void doStartAnimation(ViewPropertyAnimator parent) {
int size = parent.mPendingAnimations.size();
long startDelay = parent.getStartDelay();
long duration = parent.getDuration();
TimeInterpolator interpolator = parent.getInterpolator();
if (interpolator == null) {
// Documented to be LinearInterpolator in ValueAnimator.setInterpolator
interpolator = sLinearInterpolator;
}
if (!RenderNodeAnimator.isNativeInterpolator(interpolator)) {
interpolator = new FallbackLUTInterpolator(interpolator, duration);
}
for (int i = 0; i < size; i++) {
NameValuesHolder holder = parent.mPendingAnimations.get(i);
int property = RenderNodeAnimator.mapViewPropertyToRenderProperty(holder.mNameConstant);
final float finalValue = holder.mFromValue + holder.mDeltaValue;
RenderNodeAnimator animator = new RenderNodeAnimator(property, finalValue);
animator.setStartDelay(startDelay);
animator.setDuration(duration);
animator.setInterpolator(interpolator);
animator.setTarget(mView);
animator.start();
mAnimators[property] = animator;
}
parent.mPendingAnimations.clear();
}
use of android.animation.TimeInterpolator in project assertj-android by square.
the class ViewPropertyAnimatorAssert method hasInterpolator.
@TargetApi(JELLY_BEAN_MR2)
public ViewPropertyAnimatorAssert hasInterpolator(TimeInterpolator interpolator) {
isNotNull();
TimeInterpolator actualInterpolator = actual.getInterpolator();
//
assertThat(actualInterpolator).overridingErrorMessage("Expected interpolator <%s> but was <%s>.", interpolator, //
actualInterpolator).isEqualTo(interpolator);
return this;
}
use of android.animation.TimeInterpolator in project android_frameworks_base by DirtyUnicorns.
the class ViewPropertyAnimatorRT method doStartAnimation.
private void doStartAnimation(ViewPropertyAnimator parent) {
int size = parent.mPendingAnimations.size();
long startDelay = parent.getStartDelay();
long duration = parent.getDuration();
TimeInterpolator interpolator = parent.getInterpolator();
if (interpolator == null) {
// Documented to be LinearInterpolator in ValueAnimator.setInterpolator
interpolator = sLinearInterpolator;
}
if (!RenderNodeAnimator.isNativeInterpolator(interpolator)) {
interpolator = new FallbackLUTInterpolator(interpolator, duration);
}
for (int i = 0; i < size; i++) {
NameValuesHolder holder = parent.mPendingAnimations.get(i);
int property = RenderNodeAnimator.mapViewPropertyToRenderProperty(holder.mNameConstant);
final float finalValue = holder.mFromValue + holder.mDeltaValue;
RenderNodeAnimator animator = new RenderNodeAnimator(property, finalValue);
animator.setStartDelay(startDelay);
animator.setDuration(duration);
animator.setInterpolator(interpolator);
animator.setTarget(mView);
animator.start();
mAnimators[property] = animator;
}
parent.mPendingAnimations.clear();
}
use of android.animation.TimeInterpolator in project Launcher3 by chislon.
the class DeleteDropTarget method onFlingToDelete.
public void onFlingToDelete(final DragObject d, int x, int y, PointF vel) {
final boolean isAllApps = d.dragSource instanceof AppsCustomizePagedView;
// Don't highlight the icon as it's animating
d.dragView.setColor(0);
d.dragView.updateInitialScaleToCurrentScale();
// Don't highlight the target if we are flinging from AllApps
if (isAllApps) {
resetHoverColor();
}
if (mFlingDeleteMode == MODE_FLING_DELETE_TO_TRASH) {
// Defer animating out the drop target if we are animating to it
mSearchDropTargetBar.deferOnDragEnd();
mSearchDropTargetBar.finishAnimations();
}
final ViewConfiguration config = ViewConfiguration.get(mLauncher);
final DragLayer dragLayer = mLauncher.getDragLayer();
final int duration = FLING_DELETE_ANIMATION_DURATION;
final long startTime = AnimationUtils.currentAnimationTimeMillis();
// NOTE: Because it takes time for the first frame of animation to actually be
// called and we expect the animation to be a continuation of the fling, we have
// to account for the time that has elapsed since the fling finished. And since
// we don't have a startDelay, we will always get call to update when we call
// start() (which we want to ignore).
final TimeInterpolator tInterpolator = new TimeInterpolator() {
private int mCount = -1;
private float mOffset = 0f;
@Override
public float getInterpolation(float t) {
if (mCount < 0) {
mCount++;
} else if (mCount == 0) {
mOffset = Math.min(0.5f, (float) (AnimationUtils.currentAnimationTimeMillis() - startTime) / duration);
mCount++;
}
return Math.min(1f, mOffset + t);
}
};
AnimatorUpdateListener updateCb = null;
if (mFlingDeleteMode == MODE_FLING_DELETE_TO_TRASH) {
updateCb = createFlingToTrashAnimatorListener(dragLayer, d, vel, config);
} else if (mFlingDeleteMode == MODE_FLING_DELETE_ALONG_VECTOR) {
updateCb = createFlingAlongVectorAnimatorListener(dragLayer, d, vel, startTime, duration, config);
}
deferCompleteDropIfUninstalling(d);
Runnable onAnimationEndRunnable = new Runnable() {
@Override
public void run() {
// itself, otherwise, complete the drop to initiate the deletion process
if (!isAllApps) {
mLauncher.exitSpringLoadedDragMode();
completeDrop(d);
}
mLauncher.getDragController().onDeferredEndFling(d);
}
};
dragLayer.animateView(d.dragView, updateCb, duration, tInterpolator, onAnimationEndRunnable, DragLayer.ANIMATION_END_DISAPPEAR, null);
}
use of android.animation.TimeInterpolator in project Launcher3 by chislon.
the class DeleteDropTarget method createFlingToTrashAnimatorListener.
/**
* Creates an animation from the current drag view to the delete trash icon.
*/
private AnimatorUpdateListener createFlingToTrashAnimatorListener(final DragLayer dragLayer, DragObject d, PointF vel, ViewConfiguration config) {
final Rect to = getIconRect(d.dragView.getMeasuredWidth(), d.dragView.getMeasuredHeight(), mCurrentDrawable.getIntrinsicWidth(), mCurrentDrawable.getIntrinsicHeight());
final Rect from = new Rect();
dragLayer.getViewRectRelativeToSelf(d.dragView, from);
// Calculate how far along the velocity vector we should put the intermediate point on
// the bezier curve
float velocity = Math.abs(vel.length());
float vp = Math.min(1f, velocity / (config.getScaledMaximumFlingVelocity() / 2f));
int offsetY = (int) (-from.top * vp);
int offsetX = (int) (offsetY / (vel.y / vel.x));
// intermediate t/l
final float y2 = from.top + offsetY;
final float x2 = from.left + offsetX;
// drag view t/l
final float x1 = from.left;
final float y1 = from.top;
// delete target t/l
final float x3 = to.left;
final float y3 = to.top;
final TimeInterpolator scaleAlphaInterpolator = new TimeInterpolator() {
@Override
public float getInterpolation(float t) {
return t * t * t * t * t * t * t * t;
}
};
return new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
final DragView dragView = (DragView) dragLayer.getAnimatedView();
float t = ((Float) animation.getAnimatedValue()).floatValue();
float tp = scaleAlphaInterpolator.getInterpolation(t);
float initialScale = dragView.getInitialScale();
float finalAlpha = 0.5f;
float scale = dragView.getScaleX();
float x1o = ((1f - scale) * dragView.getMeasuredWidth()) / 2f;
float y1o = ((1f - scale) * dragView.getMeasuredHeight()) / 2f;
float x = (1f - t) * (1f - t) * (x1 - x1o) + 2 * (1f - t) * t * (x2 - x1o) + (t * t) * x3;
float y = (1f - t) * (1f - t) * (y1 - y1o) + 2 * (1f - t) * t * (y2 - x1o) + (t * t) * y3;
dragView.setTranslationX(x);
dragView.setTranslationY(y);
dragView.setScaleX(initialScale * (1f - tp));
dragView.setScaleY(initialScale * (1f - tp));
dragView.setAlpha(finalAlpha + (1f - finalAlpha) * (1f - tp));
}
};
}
Aggregations