use of android.animation.Animator in project Conductor by bluelinelabs.
the class AnimatorChangeHandler method performAnimation.
private void performAnimation(@NonNull final ViewGroup container, @Nullable final View from, @Nullable final View to, final boolean isPush, final boolean toAddedToContainer, @NonNull final ControllerChangeCompletedListener changeListener) {
if (canceled) {
complete(changeListener, null);
return;
}
animator = getAnimator(container, from, to, isPush, toAddedToContainer);
if (animationDuration > 0) {
animator.setDuration(animationDuration);
}
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
if (from != null && (!isPush || removesFromViewOnPush) && needsImmediateCompletion) {
container.removeView(from);
}
complete(changeListener, this);
}
@Override
public void onAnimationEnd(Animator animation) {
if (!canceled && animator != null) {
if (from != null && (!isPush || removesFromViewOnPush)) {
container.removeView(from);
}
complete(changeListener, this);
if (isPush && from != null) {
resetFromView(from);
}
}
}
});
animator.start();
}
use of android.animation.Animator in project platform_frameworks_base by android.
the class DecorView method setHandledPrimaryActionMode.
private void setHandledPrimaryActionMode(ActionMode mode) {
endOnGoingFadeAnimation();
mPrimaryActionMode = mode;
mPrimaryActionMode.invalidate();
mPrimaryActionModeView.initForMode(mPrimaryActionMode);
if (mPrimaryActionModePopup != null) {
post(mShowPrimaryActionModePopup);
} else {
if (shouldAnimatePrimaryActionModeView()) {
mFadeAnim = ObjectAnimator.ofFloat(mPrimaryActionModeView, View.ALPHA, 0f, 1f);
mFadeAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mPrimaryActionModeView.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animator animation) {
mPrimaryActionModeView.setAlpha(1f);
mFadeAnim = null;
}
});
mFadeAnim.start();
} else {
mPrimaryActionModeView.setAlpha(1f);
mPrimaryActionModeView.setVisibility(View.VISIBLE);
}
}
mPrimaryActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
use of android.animation.Animator in project platform_frameworks_base by android.
the class AppearAnimationUtils method createAnimation.
@Override
public void createAnimation(final View view, long delay, long duration, float translationY, boolean appearing, Interpolator interpolator, final Runnable endRunnable) {
if (view != null) {
view.setAlpha(appearing ? 0f : 1.0f);
view.setTranslationY(appearing ? translationY : 0);
Animator alphaAnim;
float targetAlpha = appearing ? 1f : 0f;
if (view.isHardwareAccelerated()) {
RenderNodeAnimator alphaAnimRt = new RenderNodeAnimator(RenderNodeAnimator.ALPHA, targetAlpha);
alphaAnimRt.setTarget(view);
alphaAnim = alphaAnimRt;
} else {
alphaAnim = ObjectAnimator.ofFloat(view, View.ALPHA, view.getAlpha(), targetAlpha);
}
alphaAnim.setInterpolator(interpolator);
alphaAnim.setDuration(duration);
alphaAnim.setStartDelay(delay);
if (view.hasOverlappingRendering()) {
view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
alphaAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
view.setLayerType(View.LAYER_TYPE_NONE, null);
}
});
}
if (endRunnable != null) {
alphaAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
endRunnable.run();
}
});
}
alphaAnim.start();
startTranslationYAnimation(view, delay, duration, appearing ? 0 : translationY, interpolator);
}
}
use of android.animation.Animator in project platform_frameworks_base by android.
the class AppearAnimationUtils method startTranslationYAnimation.
public static void startTranslationYAnimation(View view, long delay, long duration, float endTranslationY, Interpolator interpolator) {
Animator translationAnim;
if (view.isHardwareAccelerated()) {
RenderNodeAnimator translationAnimRt = new RenderNodeAnimator(RenderNodeAnimator.TRANSLATION_Y, endTranslationY);
translationAnimRt.setTarget(view);
translationAnim = translationAnimRt;
} else {
translationAnim = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, view.getTranslationY(), endTranslationY);
}
translationAnim.setInterpolator(interpolator);
translationAnim.setDuration(duration);
translationAnim.setStartDelay(delay);
translationAnim.start();
}
use of android.animation.Animator in project platform_frameworks_base by android.
the class SwipeHelper method snapChild.
public void snapChild(final View animView, final float targetLeft, float velocity) {
final boolean canBeDismissed = mCallback.canChildBeDismissed(animView);
AnimatorUpdateListener updateListener = new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
onTranslationUpdate(animView, (float) animation.getAnimatedValue(), canBeDismissed);
}
};
Animator anim = getViewTranslationAnimator(animView, targetLeft, updateListener);
if (anim == null) {
return;
}
int duration = SNAP_ANIM_LEN;
anim.setDuration(duration);
anim.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animator) {
mSnappingChild = false;
updateSwipeProgressFromOffset(animView, canBeDismissed);
mCallback.onChildSnappedBack(animView, targetLeft);
}
});
prepareSnapBackAnimation(animView, anim);
mSnappingChild = true;
anim.start();
}
Aggregations