if (!mFilteredApps.isEmpty()) {
int curNumPageItems = layout.getPageChildCount();
int numPageItems = endIndex - startIndex;
+ boolean createHolographicOutlines = (numPages > 1);
// If we were previously an empty page, then restart anew
boolean wasEmptyPage = false;
// Add any necessary items
for (int i = curNumPageItems; i < numPageItems; ++i) {
- final boolean createHolographicOutlines = (numPages > 1);
TextView text = (TextView) mInflater.inflate(
R.layout.all_apps_paged_view_application, layout, false);
text.setOnClickListener(this);
text.setOnTouchListener(this);
layout.addViewToCellLayout(text, -1, i,
- new PagedViewCellLayout.LayoutParams(0, 0, 1, 1), createHolographicOutlines);
+ new PagedViewCellLayout.LayoutParams(0, 0, 1, 1));
}
// Actually reapply to the existing text views
for (int i = startIndex; i < endIndex; ++i) {
final int index = i - startIndex;
final ApplicationInfo info = mFilteredApps.get(i);
- final boolean createHolographicOutlines = (numPages > 1);
PagedViewIcon icon = (PagedViewIcon) layout.getChildOnPageAt(index);
icon.applyFromApplicationInfo(
info, mPageViewIconCache, true, createHolographicOutlines);
params.cellY = index / mCellCountX;
}
+ // We should try and sync all the holographic icons after adding/removing new items
+ layout.reloadHolographicIcons(createHolographicOutlines);
+
// Default to left-aligned icons
layout.enableCenteredContent(false);
} else {
layout.enableCenteredContent(true);
layout.removeAllViewsOnPage();
layout.addViewToCellLayout(icon, -1, 0,
- new PagedViewCellLayout.LayoutParams(0, 0, 4, 1), createHolographicOutlines);
+ new PagedViewCellLayout.LayoutParams(0, 0, 4, 1));
}
layout.createHardwareLayers();
}
int index = i - startIndex;
int x = index % mCellCountX;
int y = index / mCellCountX;
- layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1),
- isHardwareAccelerated() && (numPages > 1));
+ layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1));
}
}
/*
final int x = index % mCellCountX;
final int y = index / mCellCountX;
setupPage(layout);
- layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1),
- createHolographicOutlines);
+ layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1));
}
}
final int x = index % mCellCountX;
final int y = index / mCellCountX;
setupPage(layout);
- layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1),
- createHolographicOutlines);
+ layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1));
}
}
}
}
+ /** Syncs the holographic icon views to the child icon views */
+ public void reloadHolographicIcons(boolean createHolographicOutlines) {
+ if (createHolographicOutlines) {
+ mChildren.loadHolographicOutlines();
+ } else {
+ mChildren.clearHolographicOutlines();
+ }
+ }
+
public boolean addViewToCellLayout(View child, int index, int childId,
- PagedViewCellLayout.LayoutParams params, boolean createHolographicOutlines) {
+ PagedViewCellLayout.LayoutParams params) {
final PagedViewCellLayout.LayoutParams lp = params;
// Generate an id for each view, this assumes we have at most 256x256 cells
if (mAllowHardwareLayerCreation) {
pagedViewIcon.disableCache();
}
- if (createHolographicOutlines) {
- mHolographicChildren.addView(pagedViewIcon.getHolographicOutlineView(),
- index, lp);
- }
+ mHolographicChildren.addView(pagedViewIcon.getHolographicOutlineView(),
+ index, lp);
}
return true;
}
@Override
public void removeViewOnPageAt(int index) {
mChildren.removeViewAt(index);
- // Holographic icons are disabled in certain cases (on lower hardware, or if there is only
- // one page), so check before we try and remove the view at a specified index.
- if (mHolographicChildren.getChildAt(index) != null) {
- mHolographicChildren.removeViewAt(index);
- }
+ mHolographicChildren.removeViewAt(index);
}
@Override
}
}
}
+
+ public void loadHolographicOutlines() {
+ int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ View view = getChildAt(i);
+ if (view instanceof PagedViewIcon) {
+ PagedViewIcon icon = (PagedViewIcon) view;
+ icon.loadHolographicIcon();
+ }
+ }
+ }
+
+ public void clearHolographicOutlines() {
+ int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ View view = getChildAt(i);
+ if (view instanceof PagedViewIcon) {
+ PagedViewIcon icon = (PagedViewIcon) view;
+ icon.clearHolographicIcon();
+ }
+ }
+ }
}
return false;
}
+ public void loadHolographicIcon() {
+ if (mHolographicOutline == null) {
+ mHolographicOutline = mIconCache.getOutline(mIconCacheKey);
+ if (!queueHolographicOutlineCreation()) {
+ getHolographicOutlineView().invalidate();
+ }
+ }
+ }
+ public void clearHolographicIcon() {
+ mHolographicOutline = null;
+ getHolographicOutlineView().invalidate();
+ }
+
public void applyFromApplicationInfo(ApplicationInfo info, PagedViewIconCache cache,
boolean scaleUp, boolean createHolographicOutlines) {
+ mIconCache = cache;
+ mIconCacheKey = new PagedViewIconCache.Key(info);
mIcon = info.iconBitmap;
setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null);
setText(info.title);
setTag(info);
if (createHolographicOutlines) {
- mIconCache = cache;
- mIconCacheKey = new PagedViewIconCache.Key(info);
mHolographicOutline = mIconCache.getOutline(mIconCacheKey);
if (!queueHolographicOutlineCreation()) {
getHolographicOutlineView().invalidate();
Bitmap overlay = null;
// draw any blended overlays
- if (mCheckedOutline == null) {
- if (canvas.isHardwareAccelerated() && mHolographicOutline != null
- && mHolographicAlpha > 0) {
- mPaint.setAlpha(mHolographicAlpha);
- overlay = mHolographicOutline;
- }
- } else {
+ if (mCheckedOutline != null) {
mPaint.setAlpha(255);
overlay = mCheckedOutline;
}