Adding outline cache for PagedViewIcons.
Change-Id: I258740a0323660edd73b5f40d61d509455ae195b
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index d56e7ac..6154947 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -18,8 +18,10 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import android.content.Context;
+import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Parcel;
@@ -87,6 +89,30 @@
private ArrayList<Boolean> mDirtyPageContent;
private boolean mDirtyPageAlpha;
+ protected PagedViewIconCache mPageViewIconCache;
+
+ /**
+ * Simple cache mechanism for PagedViewIcon outlines.
+ */
+ class PagedViewIconCache {
+ private final HashMap<Object, Bitmap> iconOutlineCache = new HashMap<Object, Bitmap>();
+
+ public void clear() {
+ iconOutlineCache.clear();
+ }
+ public void addOutline(Object key, Bitmap b) {
+ iconOutlineCache.put(key, b);
+ }
+ public void removeOutline(Object key) {
+ if (iconOutlineCache.containsKey(key)) {
+ iconOutlineCache.remove(key);
+ }
+ }
+ public Bitmap getOutline(Object key) {
+ return iconOutlineCache.get(key);
+ }
+ }
+
public interface PageSwitchListener {
void onPageSwitch(View newPage, int newPageIndex);
}
@@ -112,6 +138,7 @@
private void initWorkspace() {
mDirtyPageContent = new ArrayList<Boolean>();
mDirtyPageContent.ensureCapacity(32);
+ mPageViewIconCache = new PagedViewIconCache();
mScroller = new Scroller(getContext());
mCurrentPage = 0;