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 weex-example by KalicyZhou.
the class DimensionUpdateListener method onAnimationUpdate.
@Override
public void onAnimationUpdate(ValueAnimator animation) {
if (view.getLayoutParams() != null) {
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
TimeInterpolator interpolator = animation.getInterpolator();
float fraction = animation.getAnimatedFraction();
int preWidth = layoutParams.width;
int preHeight = layoutParams.height;
if (width != null) {
layoutParams.width = intEvaluator.evaluate(interpolator.getInterpolation(fraction), width.first, width.second);
}
if (height != null) {
layoutParams.height = intEvaluator.evaluate(interpolator.getInterpolation(fraction), height.first, height.second);
}
if (preHeight != layoutParams.height || preWidth != layoutParams.width) {
view.requestLayout();
}
}
}
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 android_frameworks_base by ResurrectionRemix.
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 android_packages_apps_Launcher2 by CyanogenMod.
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);
}
Runnable onAnimationEndRunnable = new Runnable() {
@Override
public void run() {
mSearchDropTargetBar.onDragEnd();
// 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);
}
Aggregations