Fields Summary |
---|
private static final String | TAG |
private static final boolean | DEBUG |
private final DozeParameters | mDozeParameters |
private final android.view.animation.Interpolator | mPulseInInterpolator |
private final android.view.animation.Interpolator | mPulseInInterpolatorPickup |
private final android.view.animation.Interpolator | mPulseOutInterpolator |
private final android.view.animation.Interpolator | mDozeAnimationInterpolator |
private final android.os.Handler | mHandler |
private final ScrimController | mScrimController |
private boolean | mDozing |
private DozeHost.PulseCallback | mPulseCallback |
private int | mPulseReason |
private android.animation.Animator | mInFrontAnimator |
private android.animation.Animator | mBehindAnimator |
private float | mInFrontTarget |
private float | mBehindTarget |
private final Runnable | mPulseIn |
private final Runnable | mPulseInFinished |
private final Runnable | mPulseOut |
private final Runnable | mPulseOutFinished |
Methods Summary |
---|
private void | abortAnimations()
if (mInFrontAnimator != null) {
mInFrontAnimator.cancel();
}
if (mBehindAnimator != null) {
mBehindAnimator.cancel();
}
|
private void | cancelPulsing()
if (DEBUG) Log.d(TAG, "Cancel pulsing");
if (mPulseCallback != null) {
mHandler.removeCallbacks(mPulseIn);
mHandler.removeCallbacks(mPulseOut);
pulseFinished();
}
|
private android.animation.Animator | getCurrentAnimator(boolean inFront)
return inFront ? mInFrontAnimator : mBehindAnimator;
|
private float | getCurrentTarget(boolean inFront)
return inFront ? mInFrontTarget : mBehindTarget;
|
private float | getDozeAlpha(boolean inFront)
return inFront
? mScrimController.getDozeInFrontAlpha()
: mScrimController.getDozeBehindAlpha();
|
public boolean | isPulsing()
return mPulseCallback != null;
|
public void | pulse(DozeHost.PulseCallback callback, int reason)When dozing, fade screen contents in and out using the front scrim.
if (callback == null) {
throw new IllegalArgumentException("callback must not be null");
}
if (!mDozing || mPulseCallback != null) {
// Pulse suppressed.
callback.onPulseFinished();
return;
}
// Begin pulse. Note that it's very important that the pulse finished callback
// be invoked when we're done so that the caller can drop the pulse wakelock.
mPulseCallback = callback;
mPulseReason = reason;
mHandler.post(mPulseIn);
|
private void | pulseFinished()
if (mPulseCallback != null) {
mPulseCallback.onPulseFinished();
mPulseCallback = null;
}
|
private void | pulseStarted()
if (mPulseCallback != null) {
mPulseCallback.onPulseStarted();
}
|
private void | setCurrentAnimator(boolean inFront, android.animation.Animator animator)
if (inFront) {
mInFrontAnimator = animator;
} else {
mBehindAnimator = animator;
}
|
private void | setCurrentTarget(boolean inFront, float target)
if (inFront) {
mInFrontTarget = target;
} else {
mBehindTarget = target;
}
|
private void | setDozeAlpha(boolean inFront, float alpha)
if (inFront) {
mScrimController.setDozeInFrontAlpha(alpha);
} else {
mScrimController.setDozeBehindAlpha(alpha);
}
|
public void | setDozing(boolean dozing, boolean animate)
if (mDozing == dozing) return;
mDozing = dozing;
if (mDozing) {
abortAnimations();
mScrimController.setDozeBehindAlpha(1f);
mScrimController.setDozeInFrontAlpha(1f);
} else {
cancelPulsing();
if (animate) {
startScrimAnimation(false /* inFront */, 0f /* target */,
NotificationPanelView.DOZE_ANIMATION_DURATION, mDozeAnimationInterpolator);
startScrimAnimation(true /* inFront */, 0f /* target */,
NotificationPanelView.DOZE_ANIMATION_DURATION, mDozeAnimationInterpolator);
} else {
abortAnimations();
mScrimController.setDozeBehindAlpha(0f);
mScrimController.setDozeInFrontAlpha(0f);
}
}
|
private void | startScrimAnimation(boolean inFront, float target, long duration, android.view.animation.Interpolator interpolator, long delay, java.lang.Runnable endRunnable)
Animator current = getCurrentAnimator(inFront);
if (current != null) {
float currentTarget = getCurrentTarget(inFront);
if (currentTarget == target) {
return;
}
current.cancel();
}
ValueAnimator anim = ValueAnimator.ofFloat(getDozeAlpha(inFront), target);
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (float) animation.getAnimatedValue();
setDozeAlpha(inFront, value);
}
});
anim.setInterpolator(interpolator);
anim.setDuration(duration);
anim.setStartDelay(delay);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
setCurrentAnimator(inFront, null);
if (endRunnable != null) {
endRunnable.run();
}
}
});
anim.start();
setCurrentAnimator(inFront, anim);
setCurrentTarget(inFront, target);
|
private void | startScrimAnimation(boolean inFront, float target, long duration, android.view.animation.Interpolator interpolator)
startScrimAnimation(inFront, target, duration, interpolator, 0 /* delay */,
null /* endRunnable */);
|