Reducing memory impact of hardware layers in Launcher

- Disabling hardware layers in customize tray
- Destroying hardware layers for pages in All Apps that are not visible
- Re-adding CachedTextView for icons in customize tray (to regain some of the lost performance there)
This commit is contained in:
Michael Jurka
2011-02-03 16:47:14 -08:00
parent 7924f2592f
commit c0759f5090
6 changed files with 54 additions and 4 deletions

View File

@@ -40,6 +40,7 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
private static int sDefaultCellDimensions = 96;
protected PagedViewCellLayoutChildren mChildren;
private PagedViewCellLayoutChildren mHolographicChildren;
private boolean mUseHardwareLayers = false;
public PagedViewCellLayout(Context context) {
this(context, null);
@@ -73,12 +74,29 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
addView(mHolographicChildren);
}
public void enableHardwareLayers() {
mUseHardwareLayers = true;
}
@Override
public void setAlpha(float alpha) {
mChildren.setAlpha(alpha);
mHolographicChildren.setAlpha(1.0f - alpha);
}
void destroyHardwareLayers() {
if (mUseHardwareLayers) {
mChildren.destroyHardwareLayer();
mHolographicChildren.destroyHardwareLayer();
}
}
void createHardwareLayers() {
if (mUseHardwareLayers) {
mChildren.createHardwareLayer();
mHolographicChildren.createHardwareLayer();
}
}
@Override
public void cancelLongPress() {
super.cancelLongPress();
@@ -109,6 +127,9 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
if (child instanceof PagedViewIcon) {
PagedViewIcon pagedViewIcon = (PagedViewIcon) child;
if (mUseHardwareLayers) {
pagedViewIcon.disableCache();
}
mHolographicChildren.addView(pagedViewIcon.getHolographicOutlineView(), index, lp);
}
return true;