use of android.animation.AnimatorListenerAdapter in project platform_frameworks_base by android.
the class ExpandableNotificationRow method getTranslateViewAnimator.
public Animator getTranslateViewAnimator(final float leftTarget, AnimatorUpdateListener listener) {
if (mTranslateAnim != null) {
mTranslateAnim.cancel();
}
if (areGutsExposed()) {
// No translation if guts are exposed.
return null;
}
final ObjectAnimator translateAnim = ObjectAnimator.ofFloat(this, TRANSLATE_CONTENT, leftTarget);
if (listener != null) {
translateAnim.addUpdateListener(listener);
}
translateAnim.addListener(new AnimatorListenerAdapter() {
boolean cancelled = false;
@Override
public void onAnimationCancel(Animator anim) {
cancelled = true;
}
@Override
public void onAnimationEnd(Animator anim) {
if (!cancelled && mSettingsIconRow != null && leftTarget == 0) {
mSettingsIconRow.resetState();
mTranslateAnim = null;
}
}
});
mTranslateAnim = translateAnim;
return translateAnim;
}
use of android.animation.AnimatorListenerAdapter in project platform_frameworks_base by android.
the class KeyguardAffordanceView method finishAnimation.
public void finishAnimation(float velocity, final Runnable mAnimationEndRunnable) {
cancelAnimator(mCircleAnimator);
cancelAnimator(mPreviewClipper);
mFinishing = true;
mCircleStartRadius = mCircleRadius;
final float maxCircleSize = getMaxCircleSize();
Animator animatorToRadius;
if (mSupportHardware) {
initHwProperties();
animatorToRadius = getRtAnimatorToRadius(maxCircleSize);
startRtAlphaFadeIn();
} else {
animatorToRadius = getAnimatorToRadius(maxCircleSize);
}
mFlingAnimationUtils.applyDismissing(animatorToRadius, mCircleRadius, maxCircleSize, velocity, maxCircleSize);
animatorToRadius.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mAnimationEndRunnable.run();
mFinishing = false;
mCircleRadius = maxCircleSize;
invalidate();
}
});
animatorToRadius.start();
setImageAlpha(0, true);
if (mPreviewView != null) {
mPreviewView.setVisibility(View.VISIBLE);
mPreviewClipper = ViewAnimationUtils.createCircularReveal(mPreviewView, getLeft() + mCenterX, getTop() + mCenterY, mCircleRadius, maxCircleSize);
mFlingAnimationUtils.applyDismissing(mPreviewClipper, mCircleRadius, maxCircleSize, velocity, maxCircleSize);
mPreviewClipper.addListener(mClipEndListener);
mPreviewClipper.start();
if (mSupportHardware) {
startRtCircleFadeOut(animatorToRadius.getDuration());
}
}
}
use of android.animation.AnimatorListenerAdapter in project platform_frameworks_base by android.
the class StackStateAnimator method startHeightAnimation.
private void startHeightAnimation(final ExpandableView child, StackViewState viewState, long duration, long delay) {
Integer previousStartValue = getChildTag(child, TAG_START_HEIGHT);
Integer previousEndValue = getChildTag(child, TAG_END_HEIGHT);
int newEndValue = viewState.height;
if (previousEndValue != null && previousEndValue == newEndValue) {
return;
}
ValueAnimator previousAnimator = getChildTag(child, TAG_ANIMATOR_HEIGHT);
if (!mAnimationFilter.animateHeight) {
// just a local update was performed
if (previousAnimator != null) {
// we need to increase all animation keyframes of the previous animator by the
// relative change to the end value
PropertyValuesHolder[] values = previousAnimator.getValues();
int relativeDiff = newEndValue - previousEndValue;
int newStartValue = previousStartValue + relativeDiff;
values[0].setIntValues(newStartValue, newEndValue);
child.setTag(TAG_START_HEIGHT, newStartValue);
child.setTag(TAG_END_HEIGHT, newEndValue);
previousAnimator.setCurrentPlayTime(previousAnimator.getCurrentPlayTime());
return;
} else {
// no new animation needed, let's just apply the value
child.setActualHeight(newEndValue, false);
return;
}
}
ValueAnimator animator = ValueAnimator.ofInt(child.getActualHeight(), newEndValue);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
child.setActualHeight((int) animation.getAnimatedValue(), false);
}
});
animator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
long newDuration = cancelAnimatorAndGetNewDuration(duration, previousAnimator);
animator.setDuration(newDuration);
if (delay > 0 && (previousAnimator == null || previousAnimator.getAnimatedFraction() == 0)) {
animator.setStartDelay(delay);
}
animator.addListener(getGlobalAnimationFinishedListener());
// remove the tag when the animation is finished
animator.addListener(new AnimatorListenerAdapter() {
boolean mWasCancelled;
@Override
public void onAnimationEnd(Animator animation) {
child.setTag(TAG_ANIMATOR_HEIGHT, null);
child.setTag(TAG_START_HEIGHT, null);
child.setTag(TAG_END_HEIGHT, null);
child.setActualHeightAnimating(false);
if (!mWasCancelled && child instanceof ExpandableNotificationRow) {
((ExpandableNotificationRow) child).setGroupExpansionChanging(false);
}
}
@Override
public void onAnimationStart(Animator animation) {
mWasCancelled = false;
}
@Override
public void onAnimationCancel(Animator animation) {
mWasCancelled = true;
}
});
startAnimator(animator);
child.setTag(TAG_ANIMATOR_HEIGHT, animator);
child.setTag(TAG_START_HEIGHT, child.getActualHeight());
child.setTag(TAG_END_HEIGHT, newEndValue);
child.setActualHeightAnimating(true);
}
use of android.animation.AnimatorListenerAdapter in project platform_frameworks_base by android.
the class StackStateAnimator method animateOverScrollToAmount.
public void animateOverScrollToAmount(float targetAmount, final boolean onTop, final boolean isRubberbanded) {
final float startOverScrollAmount = mHostLayout.getCurrentOverScrollAmount(onTop);
if (targetAmount == startOverScrollAmount) {
return;
}
cancelOverScrollAnimators(onTop);
ValueAnimator overScrollAnimator = ValueAnimator.ofFloat(startOverScrollAmount, targetAmount);
overScrollAnimator.setDuration(ANIMATION_DURATION_STANDARD);
overScrollAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float currentOverScroll = (float) animation.getAnimatedValue();
mHostLayout.setOverScrollAmount(currentOverScroll, onTop, false, /* animate */
false, /* cancelAnimators */
isRubberbanded);
}
});
overScrollAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
overScrollAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (onTop) {
mTopOverScrollAnimator = null;
} else {
mBottomOverScrollAnimator = null;
}
}
});
overScrollAnimator.start();
if (onTop) {
mTopOverScrollAnimator = overScrollAnimator;
} else {
mBottomOverScrollAnimator = overScrollAnimator;
}
}
use of android.animation.AnimatorListenerAdapter in project platform_frameworks_base by android.
the class RemoteInputView method onDefocus.
private void onDefocus(boolean animate) {
mController.removeRemoteInput(mEntry, mToken);
mEntry.remoteInputText = mEditText.getText();
// case to prevent flicker.
if (!mRemoved) {
if (animate && mRevealR > 0) {
Animator reveal = ViewAnimationUtils.createCircularReveal(this, mRevealCx, mRevealCy, mRevealR, 0);
reveal.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN);
reveal.setDuration(StackStateAnimator.ANIMATION_DURATION_CLOSE_REMOTE_INPUT);
reveal.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
setVisibility(INVISIBLE);
}
});
reveal.start();
} else {
setVisibility(INVISIBLE);
}
}
MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_REMOTE_INPUT_CLOSE, mEntry.notification.getPackageName());
}
Aggregations