use of android.view.animation.Interpolator in project android_frameworks_base by ResurrectionRemix.
the class NotificationStackScrollLayout method startTopAnimation.
private void startTopAnimation() {
int previousEndValue = mEndAnimationRect.top;
int newEndValue = mBackgroundBounds.top;
ObjectAnimator previousAnimator = mTopAnimator;
if (previousAnimator != null && previousEndValue == newEndValue) {
return;
}
if (!mAnimateNextBackgroundTop) {
// 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
int previousStartValue = mStartAnimationRect.top;
PropertyValuesHolder[] values = previousAnimator.getValues();
values[0].setIntValues(previousStartValue, newEndValue);
mStartAnimationRect.top = previousStartValue;
mEndAnimationRect.top = newEndValue;
previousAnimator.setCurrentPlayTime(previousAnimator.getCurrentPlayTime());
return;
} else {
// no new animation needed, let's just apply the value
setBackgroundTop(newEndValue);
return;
}
}
if (previousAnimator != null) {
previousAnimator.cancel();
}
ObjectAnimator animator = ObjectAnimator.ofInt(this, "backgroundTop", mCurrentBounds.top, newEndValue);
Interpolator interpolator = Interpolators.FAST_OUT_SLOW_IN;
animator.setInterpolator(interpolator);
animator.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
// remove the tag when the animation is finished
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mStartAnimationRect.top = -1;
mEndAnimationRect.top = -1;
mTopAnimator = null;
}
});
animator.start();
mStartAnimationRect.top = mCurrentBounds.top;
mEndAnimationRect.top = newEndValue;
mTopAnimator = animator;
}
use of android.view.animation.Interpolator in project android_frameworks_base by ResurrectionRemix.
the class AnimatorInflater method loadAnimator.
/**
* Creates a new animation whose parameters come from the specified context
* and attributes set.
*
* @param res The resources
* @param attrs The set of attributes holding the animation parameters
* @param anim Null if this is a ValueAnimator, otherwise this is an
* ObjectAnimator
*/
private static ValueAnimator loadAnimator(Resources res, Theme theme, AttributeSet attrs, ValueAnimator anim, float pathErrorScale) throws NotFoundException {
TypedArray arrayAnimator = null;
TypedArray arrayObjectAnimator = null;
if (theme != null) {
arrayAnimator = theme.obtainStyledAttributes(attrs, R.styleable.Animator, 0, 0);
} else {
arrayAnimator = res.obtainAttributes(attrs, R.styleable.Animator);
}
// If anim is not null, then it is an object animator.
if (anim != null) {
if (theme != null) {
arrayObjectAnimator = theme.obtainStyledAttributes(attrs, R.styleable.PropertyAnimator, 0, 0);
} else {
arrayObjectAnimator = res.obtainAttributes(attrs, R.styleable.PropertyAnimator);
}
anim.appendChangingConfigurations(arrayObjectAnimator.getChangingConfigurations());
}
if (anim == null) {
anim = new ValueAnimator();
}
anim.appendChangingConfigurations(arrayAnimator.getChangingConfigurations());
parseAnimatorFromTypeArray(anim, arrayAnimator, arrayObjectAnimator, pathErrorScale);
final int resID = arrayAnimator.getResourceId(R.styleable.Animator_interpolator, 0);
if (resID > 0) {
final Interpolator interpolator = AnimationUtils.loadInterpolator(res, theme, resID);
if (interpolator instanceof BaseInterpolator) {
anim.appendChangingConfigurations(((BaseInterpolator) interpolator).getChangingConfiguration());
}
anim.setInterpolator(interpolator);
}
arrayAnimator.recycle();
if (arrayObjectAnimator != null) {
arrayObjectAnimator.recycle();
}
return anim;
}
use of android.view.animation.Interpolator in project android_frameworks_base by ResurrectionRemix.
the class AssistInteractionSession method playAssistAnimation.
private void playAssistAnimation() {
Interpolator linearOutSlowIn = AnimationUtils.loadInterpolator(mBackground.getContext(), android.R.interpolator.linear_out_slow_in);
Interpolator fastOutSlowIn = AnimationUtils.loadInterpolator(mBackground.getContext(), android.R.interpolator.fast_out_slow_in);
mScrim.setAlpha(0f);
mScrim.animate().alpha(1f).setStartDelay(100).setDuration(500);
mBackground.setTranslationY(50 * mDensity);
mBackground.animate().translationY(0).setDuration(300).setInterpolator(linearOutSlowIn);
int centerX = mBackground.getWidth() / 2;
int centerY = (int) (mBackground.getHeight() / 5 * 3.8f);
int radius = (int) Math.sqrt(centerX * centerX + centerY * centerY) + 1;
Animator animator = ViewAnimationUtils.createCircularReveal(mBackground, centerX, centerY, 0, radius);
animator.setDuration(300);
animator.setInterpolator(fastOutSlowIn);
animator.start();
ValueAnimator colorAnim = ValueAnimator.ofArgb(Color.WHITE, 0xffe0e0e0);
colorAnim.setDuration(300);
colorAnim.setInterpolator(fastOutSlowIn);
colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mBackground.setBackgroundColor((Integer) animation.getAnimatedValue());
}
});
colorAnim.start();
mCard1.setY(mBackground.getHeight());
mCard2.setTranslationY(mCard1.getTranslationY());
mCard1.animate().translationY(0).setDuration(500).setInterpolator(linearOutSlowIn).setStartDelay(100);
mCard2.animate().translationY(0).setInterpolator(linearOutSlowIn).setStartDelay(150).setDuration(500);
mNavbarScrim.setAlpha(0f);
mNavbarScrim.animate().alpha(1f).setDuration(500).setStartDelay(100);
}
use of android.view.animation.Interpolator in project ride-read-android by Ride-Read.
the class MapFragment method addSignInMarker.
private void addSignInMarker(LatLng latLng) {
final Marker marker = addMarker(latLng);
if (marker != null) {
final long start = SystemClock.uptimeMillis();
Projection proj = mAMap.getProjection();
Point markerPoint = proj.toScreenLocation(latLng);
markerPoint.offset(0, -500);
final LatLng startLatLng = proj.fromScreenLocation(markerPoint);
final long duration = 2000;
final Interpolator interpolator = new BounceInterpolator();
mHandler.post(new Runnable() {
@Override
public void run() {
long elapsed = SystemClock.uptimeMillis() - start;
float t = interpolator.getInterpolation((float) elapsed / duration);
double lng = t * latLng.longitude + (1 - t) * startLatLng.longitude;
double lat = t * latLng.latitude + (1 - t) * startLatLng.latitude;
marker.setPosition(new LatLng(lat, lng));
if (t < 1.0) {
mHandler.postDelayed(this, 16);
}
}
});
}
mHandler.postDelayed(() -> {
mSignInDialogFragment = SignInDialogFragment.newInstance(AMapLocationUtils.getLocDetail());
mSignInDialogFragment.show(getFragmentManager(), "sign_in");
}, 1000L);
}
use of android.view.animation.Interpolator in project android_frameworks_base by ResurrectionRemix.
the class KeyguardAffordanceView method setCircleRadius.
private void setCircleRadius(float circleRadius, boolean slowAnimation, boolean noAnimation) {
// Check if we need a new animation
boolean radiusHidden = (mCircleAnimator != null && mCircleWillBeHidden) || (mCircleAnimator == null && mCircleRadius == 0.0f);
boolean nowHidden = circleRadius == 0.0f;
boolean radiusNeedsAnimation = (radiusHidden != nowHidden) && !noAnimation;
if (!radiusNeedsAnimation) {
if (mCircleAnimator == null) {
mCircleRadius = circleRadius;
updateIconColor();
invalidate();
if (nowHidden) {
if (mPreviewView != null) {
mPreviewView.setVisibility(View.INVISIBLE);
}
}
} else if (!mCircleWillBeHidden) {
// We just update the end value
float diff = circleRadius - mMinBackgroundRadius;
PropertyValuesHolder[] values = mCircleAnimator.getValues();
values[0].setFloatValues(mCircleStartValue + diff, circleRadius);
mCircleAnimator.setCurrentPlayTime(mCircleAnimator.getCurrentPlayTime());
}
} else {
cancelAnimator(mCircleAnimator);
cancelAnimator(mPreviewClipper);
ValueAnimator animator = getAnimatorToRadius(circleRadius);
Interpolator interpolator = circleRadius == 0.0f ? Interpolators.FAST_OUT_LINEAR_IN : Interpolators.LINEAR_OUT_SLOW_IN;
animator.setInterpolator(interpolator);
long duration = 250;
if (!slowAnimation) {
float durationFactor = Math.abs(mCircleRadius - circleRadius) / (float) mMinBackgroundRadius;
duration = (long) (CIRCLE_APPEAR_DURATION * durationFactor);
duration = Math.min(duration, CIRCLE_DISAPPEAR_MAX_DURATION);
}
animator.setDuration(duration);
animator.start();
if (mPreviewView != null && mPreviewView.getVisibility() == View.VISIBLE) {
mPreviewView.setVisibility(View.VISIBLE);
mPreviewClipper = ViewAnimationUtils.createCircularReveal(mPreviewView, getLeft() + mCenterX, getTop() + mCenterY, mCircleRadius, circleRadius);
mPreviewClipper.setInterpolator(interpolator);
mPreviewClipper.setDuration(duration);
mPreviewClipper.addListener(mClipEndListener);
mPreviewClipper.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mPreviewView.setVisibility(View.INVISIBLE);
}
});
mPreviewClipper.start();
}
}
}
Aggregations