Merge "Eliminate custom alpha handling in CellLayout"

This commit is contained in:
Michael Jurka
2012-03-21 05:14:55 -07:00
committed by Android (Google) Code Review
7 changed files with 108 additions and 118 deletions
+40 -29
View File
@@ -364,7 +364,7 @@ public class Workspace extends SmoothPagedView
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
CellLayout cl = (CellLayout) getChildAt(i);
cl.buildChildrenLayer();
cl.getShortcutsAndWidgets().buildLayer();
}
}
}
@@ -378,7 +378,7 @@ public class Workspace extends SmoothPagedView
int count = getChildCount();
for (int i = 0; i < count; i++) {
CellLayout cl = (CellLayout) getPageAt(i);
cl.getChildrenLayout().animate().alpha(mDragFadeOutAlpha)
cl.getShortcutsAndWidgets().animate().alpha(mDragFadeOutAlpha)
.setInterpolator(new AccelerateInterpolator(1.5f))
.setDuration(mDragFadeOutDuration)
.start();
@@ -394,7 +394,7 @@ public class Workspace extends SmoothPagedView
int count = getChildCount();
for (int i = 0; i < count; i++) {
CellLayout cl = (CellLayout) getPageAt(i);
cl.getChildrenLayout().animate().alpha(1f)
cl.getShortcutsAndWidgets().animate().alpha(1f)
.setInterpolator(new DecelerateInterpolator(1.5f))
.setDuration(mDragFadeOutDuration)
.start();
@@ -723,7 +723,7 @@ public class Workspace extends SmoothPagedView
// user scrolls while we are transitioning (should not affect dispatchDraw optimizations)
if (!mFadeInAdjacentScreens) {
for (int i = 0; i < getChildCount(); ++i) {
getPageAt(i).setAlpha(1f);
((CellLayout) getPageAt(i)).setShortcutAndWidgetAlpha(1f);
}
}
@@ -1206,7 +1206,7 @@ public class Workspace extends SmoothPagedView
cl.setRotationY(rotation);
if (mFadeInAdjacentScreens && !isSmall()) {
float alpha = 1 - Math.abs(scrollProgress);
cl.setAlpha(alpha);
cl.setShortcutAndWidgetAlpha(alpha);
}
}
}
@@ -1658,7 +1658,7 @@ public class Workspace extends SmoothPagedView
cl.setScaleY(finalScaleFactor);
cl.setBackgroundAlpha(finalBackgroundAlpha);
cl.setBackgroundAlphaMultiplier(finalAlphaMultiplierValue);
cl.setAlpha(finalAlpha);
cl.setShortcutAndWidgetAlpha(finalAlpha);
cl.setRotationY(rotation);
}
}
@@ -1674,7 +1674,7 @@ public class Workspace extends SmoothPagedView
cl.setScaleY(mNewScaleYs[i]);
cl.setBackgroundAlpha(mNewBackgroundAlphas[i]);
cl.setBackgroundAlphaMultiplier(mNewBackgroundAlphaMultipliers[i]);
cl.setAlpha(mNewAlphas[i]);
cl.setShortcutAndWidgetAlpha(mNewAlphas[i]);
cl.setRotationY(mNewRotationYs[i]);
} else {
LauncherViewPropertyAnimator a = new LauncherViewPropertyAnimator(cl);
@@ -1684,10 +1684,16 @@ public class Workspace extends SmoothPagedView
.scaleY(mNewScaleYs[i])
.setDuration(duration)
.setInterpolator(mZoomInInterpolator);
if (mOldAlphas[i] != mNewAlphas[i]) {
a.alpha(mNewAlphas[i]);
}
anim.play(a);
LauncherViewPropertyAnimator alphaAnim =
new LauncherViewPropertyAnimator(cl.getShortcutsAndWidgets());
if (mOldAlphas[i] != mNewAlphas[i]) {
alphaAnim.alpha(mNewAlphas[i])
.setDuration(duration)
.setInterpolator(mZoomInInterpolator);
anim.play(alphaAnim);
}
if (mOldRotationYs[i] != 0 || mNewRotationYs[i] != 0) {
ValueAnimator rotate = ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
rotate.setInterpolator(new DecelerateInterpolator(2.0f));
@@ -1756,7 +1762,7 @@ public class Workspace extends SmoothPagedView
if (!mFadeInAdjacentScreens) {
for (int i = 0; i < getChildCount(); i++) {
final CellLayout cl = (CellLayout) getChildAt(i);
cl.setAlpha(1f);
cl.setShortcutAndWidgetAlpha(1f);
}
}
}
@@ -3080,7 +3086,7 @@ public class Workspace extends SmoothPagedView
info.spanY, insertAtFirst);
cellLayout.onDropChild(view);
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams();
cellLayout.getChildrenLayout().measureChild(view);
cellLayout.getShortcutsAndWidgets().measureChild(view);
LauncherModel.addOrMoveItemInDatabase(mLauncher, info, container, screen,
@@ -3319,10 +3325,10 @@ public class Workspace extends SmoothPagedView
}
private void updateItemLocationsInDatabase(CellLayout cl) {
int count = cl.getChildrenLayout().getChildCount();
int count = cl.getShortcutsAndWidgets().getChildCount();
int screen = indexOfChild(cl);
for (int i = 0; i < count; i++) {
View v = cl.getChildrenLayout().getChildAt(i);
View v = cl.getShortcutsAndWidgets().getChildAt(i);
ItemInfo info = (ItemInfo) v.getTag();
LauncherModel.moveItemInDatabase(mLauncher, info, Favorites.CONTAINER_DESKTOP, screen,
@@ -3443,7 +3449,7 @@ public class Workspace extends SmoothPagedView
CellLayout getParentCellLayoutForView(View v) {
ArrayList<CellLayout> layouts = getWorkspaceAndHotseatCellLayouts();
for (CellLayout layout : layouts) {
if (layout.getChildrenLayout().indexOfChild(v) > -1) {
if (layout.getShortcutsAndWidgets().indexOfChild(v) > -1) {
return layout;
}
}
@@ -3467,23 +3473,26 @@ public class Workspace extends SmoothPagedView
/**
* We should only use this to search for specific children. Do not use this method to modify
* CellLayoutChildren directly.
* ShortcutsAndWidgetsContainer directly. Includes ShortcutAndWidgetContainers from
* the hotseat and workspace pages
*/
ArrayList<CellLayoutChildren> getWorkspaceAndHotseatCellLayoutChildren() {
ArrayList<CellLayoutChildren> childrenLayouts = new ArrayList<CellLayoutChildren>();
ArrayList<ShortcutAndWidgetContainer> getAllShortcutAndWidgetContainers() {
ArrayList<ShortcutAndWidgetContainer> childrenLayouts =
new ArrayList<ShortcutAndWidgetContainer>();
int screenCount = getChildCount();
for (int screen = 0; screen < screenCount; screen++) {
childrenLayouts.add(((CellLayout) getChildAt(screen)).getChildrenLayout());
childrenLayouts.add(((CellLayout) getChildAt(screen)).getShortcutsAndWidgets());
}
if (mLauncher.getHotseat() != null) {
childrenLayouts.add(mLauncher.getHotseat().getLayout().getChildrenLayout());
childrenLayouts.add(mLauncher.getHotseat().getLayout().getShortcutsAndWidgets());
}
return childrenLayouts;
}
public Folder getFolderForTag(Object tag) {
ArrayList<CellLayoutChildren> childrenLayouts = getWorkspaceAndHotseatCellLayoutChildren();
for (CellLayoutChildren layout: childrenLayouts) {
ArrayList<ShortcutAndWidgetContainer> childrenLayouts =
getAllShortcutAndWidgetContainers();
for (ShortcutAndWidgetContainer layout: childrenLayouts) {
int count = layout.getChildCount();
for (int i = 0; i < count; i++) {
View child = layout.getChildAt(i);
@@ -3499,8 +3508,9 @@ public class Workspace extends SmoothPagedView
}
public View getViewForTag(Object tag) {
ArrayList<CellLayoutChildren> childrenLayouts = getWorkspaceAndHotseatCellLayoutChildren();
for (CellLayoutChildren layout: childrenLayouts) {
ArrayList<ShortcutAndWidgetContainer> childrenLayouts =
getAllShortcutAndWidgetContainers();
for (ShortcutAndWidgetContainer layout: childrenLayouts) {
int count = layout.getChildCount();
for (int i = 0; i < count; i++) {
View child = layout.getChildAt(i);
@@ -3513,8 +3523,9 @@ public class Workspace extends SmoothPagedView
}
void clearDropTargets() {
ArrayList<CellLayoutChildren> childrenLayouts = getWorkspaceAndHotseatCellLayoutChildren();
for (CellLayoutChildren layout: childrenLayouts) {
ArrayList<ShortcutAndWidgetContainer> childrenLayouts =
getAllShortcutAndWidgetContainers();
for (ShortcutAndWidgetContainer layout: childrenLayouts) {
int childCount = layout.getChildCount();
for (int j = 0; j < childCount; j++) {
View v = layout.getChildAt(j);
@@ -3536,7 +3547,7 @@ public class Workspace extends SmoothPagedView
ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts();
for (final CellLayout layoutParent: cellLayouts) {
final ViewGroup layout = layoutParent.getChildrenLayout();
final ViewGroup layout = layoutParent.getShortcutsAndWidgets();
// Avoid ANRs by treating each screen separately
post(new Runnable() {
@@ -3622,8 +3633,8 @@ public class Workspace extends SmoothPagedView
}
void updateShortcuts(ArrayList<ApplicationInfo> apps) {
ArrayList<CellLayoutChildren> childrenLayouts = getWorkspaceAndHotseatCellLayoutChildren();
for (CellLayoutChildren layout: childrenLayouts) {
ArrayList<ShortcutAndWidgetContainer> childrenLayouts = getAllShortcutAndWidgetContainers();
for (ShortcutAndWidgetContainer layout: childrenLayouts) {
int childCount = layout.getChildCount();
for (int j = 0; j < childCount; j++) {
final View view = layout.getChildAt(j);