KeyguardWidgetCarouselpublic class KeyguardWidgetCarousel extends KeyguardWidgetPager
Fields Summary |
---|
private float | mAdjacentPagesAngle | private static float | MAX_SCROLL_PROGRESS | private static float | CAMERA_DISTANCE | protected android.animation.AnimatorSet | mChildrenTransformsAnimator | float[] | mTmpTransform | android.view.animation.Interpolator | mFastFadeInterpolator | android.view.animation.Interpolator | mSlowFadeInterpolator |
Methods Summary |
---|
void | animatePagesToCarousel()
if (mChildrenTransformsAnimator != null) {
mChildrenTransformsAnimator.cancel();
mChildrenTransformsAnimator = null;
}
int count = getChildCount();
PropertyValuesHolder alpha;
PropertyValuesHolder outlineAlpha;
PropertyValuesHolder rotationY;
PropertyValuesHolder pivotX;
PropertyValuesHolder pivotY;
ArrayList<Animator> anims = new ArrayList<Animator>();
for (int i = 0; i < count; i++) {
KeyguardWidgetFrame child = getWidgetPageAt(i);
float finalAlpha = getAlphaForPage(mScreenCenter, i, true);
float finalOutlineAlpha = getOutlineAlphaForPage(mScreenCenter, i, true);
getTransformForPage(mScreenCenter, i, mTmpTransform);
boolean inVisibleRange = (i >= mCurrentPage - 1 && i <= mCurrentPage + 1);
ObjectAnimator a;
alpha = PropertyValuesHolder.ofFloat("contentAlpha", finalAlpha);
outlineAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", finalOutlineAlpha);
pivotX = PropertyValuesHolder.ofFloat("pivotX", mTmpTransform[0]);
pivotY = PropertyValuesHolder.ofFloat("pivotY", mTmpTransform[1]);
rotationY = PropertyValuesHolder.ofFloat("rotationY", mTmpTransform[2]);
if (inVisibleRange) {
// for the central pages we animate into a rotated state
a = ObjectAnimator.ofPropertyValuesHolder(child, alpha, outlineAlpha,
pivotX, pivotY, rotationY);
} else {
a = ObjectAnimator.ofPropertyValuesHolder(child, alpha, outlineAlpha);
a.setInterpolator(mFastFadeInterpolator);
}
anims.add(a);
}
int duration = REORDERING_ZOOM_IN_OUT_DURATION;
mChildrenTransformsAnimator = new AnimatorSet();
mChildrenTransformsAnimator.playTogether(anims);
mChildrenTransformsAnimator.setDuration(duration);
mChildrenTransformsAnimator.start();
| void | animatePagesToNeutral()
if (mChildrenTransformsAnimator != null) {
mChildrenTransformsAnimator.cancel();
mChildrenTransformsAnimator = null;
}
int count = getChildCount();
PropertyValuesHolder alpha;
PropertyValuesHolder outlineAlpha;
PropertyValuesHolder rotationY;
ArrayList<Animator> anims = new ArrayList<Animator>();
for (int i = 0; i < count; i++) {
KeyguardWidgetFrame child = getWidgetPageAt(i);
boolean inVisibleRange = (i >= mCurrentPage - 1 && i <= mCurrentPage + 1);
if (!inVisibleRange) {
child.setRotationY(0f);
}
alpha = PropertyValuesHolder.ofFloat("contentAlpha", 1.0f);
outlineAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha",
KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER);
rotationY = PropertyValuesHolder.ofFloat("rotationY", 0f);
ObjectAnimator a = ObjectAnimator.ofPropertyValuesHolder(child, alpha, outlineAlpha, rotationY);
child.setVisibility(VISIBLE);
if (!inVisibleRange) {
a.setInterpolator(mSlowFadeInterpolator);
}
anims.add(a);
}
int duration = REORDERING_ZOOM_IN_OUT_DURATION;
mChildrenTransformsAnimator = new AnimatorSet();
mChildrenTransformsAnimator.playTogether(anims);
mChildrenTransformsAnimator.setDuration(duration);
mChildrenTransformsAnimator.start();
| public float | getAlphaForPage(int screenCenter, int index, boolean showSidePages)
View child = getChildAt(index);
if (child == null) return 0f;
boolean inVisibleRange = index >= getNextPage() - 1 && index <= getNextPage() + 1;
float scrollProgress = getScrollProgress(screenCenter, child, index);
if (isOverScrollChild(index, scrollProgress)) {
return 1.0f;
} else if ((showSidePages && inVisibleRange) || index == getNextPage()) {
scrollProgress = getBoundedScrollProgress(screenCenter, child, index);
float alpha = 1.0f - 1.0f * Math.abs(scrollProgress / MAX_SCROLL_PROGRESS);
return alpha;
} else {
return 0f;
}
| protected float | getMaxScrollProgress()
return MAX_SCROLL_PROGRESS;
| public float | getOutlineAlphaForPage(int screenCenter, int index, boolean showSidePages)
boolean inVisibleRange = index >= getNextPage() - 1 && index <= getNextPage() + 1;
if (inVisibleRange) {
return super.getOutlineAlphaForPage(screenCenter, index, showSidePages);
} else {
return 0f;
}
| private void | getTransformForPage(int screenCenter, int index, float[] transform)
View child = getChildAt(index);
float boundedProgress = getBoundedScrollProgress(screenCenter, child, index);
float rotationY = - mAdjacentPagesAngle * boundedProgress;
int width = child.getMeasuredWidth();
float pivotX = (width / 2f) + boundedProgress * (width / 2f);
float pivotY = child.getMeasuredHeight() / 2;
transform[0] = pivotX;
transform[1] = pivotY;
transform[2] = rotationY;
| protected void | onEndReordering()
super.onEndReordering();
mViewStateManager.fadeInSecurity(REORDERING_ZOOM_IN_OUT_DURATION);
| protected void | reorderStarting()
mViewStateManager.fadeOutSecurity(REORDERING_ZOOM_IN_OUT_DURATION);
animatePagesToNeutral();
| protected void | screenScrolled(int screenCenter)
mScreenCenter = screenCenter;
updatePageAlphaValues(screenCenter);
if (isReordering(false)) return;
for (int i = 0; i < getChildCount(); i++) {
KeyguardWidgetFrame v = getWidgetPageAt(i);
float scrollProgress = getScrollProgress(screenCenter, v, i);
float boundedProgress = getBoundedScrollProgress(screenCenter, v, i);
if (v == mDragView || v == null) continue;
v.setCameraDistance(CAMERA_DISTANCE);
if (isOverScrollChild(i, scrollProgress)) {
v.setRotationY(- OVERSCROLL_MAX_ROTATION * scrollProgress);
v.setOverScrollAmount(Math.abs(scrollProgress), scrollProgress < 0);
} else {
int width = v.getMeasuredWidth();
float pivotX = (width / 2f) + boundedProgress * (width / 2f);
float pivotY = v.getMeasuredHeight() / 2;
float rotationY = - mAdjacentPagesAngle * boundedProgress;
v.setPivotX(pivotX);
v.setPivotY(pivotY);
v.setRotationY(rotationY);
v.setOverScrollAmount(0f, false);
}
float alpha = v.getAlpha();
// If the view has 0 alpha, we set it to be invisible so as to prevent
// it from accepting touches
if (alpha == 0) {
v.setVisibility(INVISIBLE);
} else if (v.getVisibility() != VISIBLE) {
v.setVisibility(VISIBLE);
}
}
| public void | showInitialPageHints()
mShowingInitialHints = true;
int count = getChildCount();
for (int i = 0; i < count; i++) {
boolean inVisibleRange = i >= getNextPage() - 1 && i <= getNextPage() + 1;
KeyguardWidgetFrame child = getWidgetPageAt(i);
if (inVisibleRange) {
child.setBackgroundAlpha(KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER);
child.setContentAlpha(1f);
} else {
child.setBackgroundAlpha(0f);
child.setContentAlpha(0f);
}
}
| private void | updatePageAlphaValues(int screenCenter)
if (mChildrenOutlineFadeAnimation != null) {
mChildrenOutlineFadeAnimation.cancel();
mChildrenOutlineFadeAnimation = null;
}
boolean showSidePages = mShowingInitialHints || isPageMoving();
if (!isReordering(false)) {
for (int i = 0; i < getChildCount(); i++) {
KeyguardWidgetFrame child = getWidgetPageAt(i);
if (child != null) {
float outlineAlpha = getOutlineAlphaForPage(screenCenter, i, showSidePages);
float contentAlpha = getAlphaForPage(screenCenter, i,showSidePages);
child.setBackgroundAlpha(outlineAlpha);
child.setContentAlpha(contentAlpha);
}
}
}
| protected boolean | zoomIn(java.lang.Runnable onCompleteRunnable)
animatePagesToCarousel();
return super.zoomIn(onCompleteRunnable);
|
|