summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/PagedViewIcon.java
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-06-13 11:32:14 -0700
committerWinson Chung <winsonc@google.com>2011-06-23 11:26:17 -0700
commitb44b52439d155f570db7d6d0b80fdd3350e35685 (patch)
treed07c95c4a43b7bfb1504b1a521e097f238f6eb77 /src/com/android/launcher2/PagedViewIcon.java
parent4b825dcd5f64a5ebb60271844fbc5257374422bc (diff)
downloadandroid_packages_apps_Trebuchet-b44b52439d155f570db7d6d0b80fdd3350e35685.tar.gz
android_packages_apps_Trebuchet-b44b52439d155f570db7d6d0b80fdd3350e35685.tar.bz2
android_packages_apps_Trebuchet-b44b52439d155f570db7d6d0b80fdd3350e35685.zip
Loading previews and holographic icons in background thread using AsyncTasks.
- Adding back animation between tabs Change-Id: I1a49bfca4f85f579e232861aa02d08fb25d0aafc
Diffstat (limited to 'src/com/android/launcher2/PagedViewIcon.java')
-rw-r--r--src/com/android/launcher2/PagedViewIcon.java112
1 files changed, 12 insertions, 100 deletions
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index 30f0b1db2..a48a4effb 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -45,14 +45,10 @@ public class PagedViewIcon extends CachedTextView implements Checkable {
// holographic outline
private final Paint mPaint = new Paint();
- private static HolographicOutlineHelper sHolographicOutlineHelper;
private Bitmap mCheckedOutline;
private Bitmap mHolographicOutline;
private Bitmap mIcon;
- private PagedViewIconCache.Key mIconCacheKey;
- private PagedViewIconCache mIconCache;
-
private int mAlpha = 255;
private int mHolographicAlpha;
@@ -62,42 +58,8 @@ public class PagedViewIcon extends CachedTextView implements Checkable {
private int mCheckedFadeInDuration;
private int mCheckedFadeOutDuration;
- // Highlight colors
- private int mHoloBlurColor;
- private int mHoloOutlineColor;
-
HolographicPagedViewIcon mHolographicOutlineView;
-
- private static final HandlerThread sWorkerThread = new HandlerThread("pagedviewicon-helper");
- static {
- sWorkerThread.start();
- }
-
- private static final int MESSAGE_CREATE_HOLOGRAPHIC_OUTLINE = 1;
-
- private static final Handler sWorker = new Handler(sWorkerThread.getLooper()) {
- private DeferredHandler mHandler = new DeferredHandler();
- private Paint mPaint = new Paint();
- public void handleMessage(Message msg) {
- final PagedViewIcon icon = (PagedViewIcon) msg.obj;
-
- final Bitmap holographicOutline = Bitmap.createBitmap(
- icon.mIcon.getWidth(), icon.mIcon.getHeight(), Bitmap.Config.ARGB_8888);
- Canvas holographicOutlineCanvas = new Canvas(holographicOutline);
- holographicOutlineCanvas.drawBitmap(icon.mIcon, 0, 0, mPaint);
-
- sHolographicOutlineHelper.applyThickExpensiveOutlineWithBlur(holographicOutline,
- holographicOutlineCanvas, icon.mHoloBlurColor, icon.mHoloOutlineColor);
-
- mHandler.post(new Runnable() {
- public void run() {
- icon.mHolographicOutline = holographicOutline;
- icon.mIconCache.addOutline(icon.mIconCacheKey, holographicOutline);
- icon.getHolographicOutlineView().invalidate();
- }
- });
- }
- };
+ private HolographicOutlineHelper mHolographicOutlineHelper;
public PagedViewIcon(Context context) {
this(context, null);
@@ -110,15 +72,6 @@ public class PagedViewIcon extends CachedTextView implements Checkable {
public PagedViewIcon(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedViewIcon, defStyle, 0);
- mHoloBlurColor = a.getColor(R.styleable.PagedViewIcon_blurColor, 0);
- mHoloOutlineColor = a.getColor(R.styleable.PagedViewIcon_outlineColor, 0);
- a.recycle();
-
- if (sHolographicOutlineHelper == null) {
- sHolographicOutlineHelper = new HolographicOutlineHelper();
- }
-
// Set up fade in/out constants
final Resources r = context.getResources();
final int alpha = r.getInteger(R.integer.config_dragAppsCustomizeIconFadeAlpha);
@@ -141,69 +94,34 @@ public class PagedViewIcon extends CachedTextView implements Checkable {
return mHolographicOutline;
}
- private boolean queueHolographicOutlineCreation() {
- // Generate the outline in the background
- if (mHolographicOutline == null) {
- Message m = sWorker.obtainMessage(MESSAGE_CREATE_HOLOGRAPHIC_OUTLINE);
- m.obj = this;
- sWorker.sendMessage(m);
- return true;
- }
- 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);
+ public void applyFromApplicationInfo(ApplicationInfo info, boolean scaleUp,
+ HolographicOutlineHelper holoOutlineHelper) {
+ mHolographicOutlineHelper = holoOutlineHelper;
mIcon = info.iconBitmap;
setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null);
setText(info.title);
setTag(info);
-
- if (createHolographicOutlines) {
- mHolographicOutline = mIconCache.getOutline(mIconCacheKey);
- if (!queueHolographicOutlineCreation()) {
- getHolographicOutlineView().invalidate();
- }
- }
}
public void applyFromResolveInfo(ResolveInfo info, PackageManager packageManager,
- PagedViewIconCache cache, IconCache modelIconCache, boolean createHolographicOutlines) {
+ IconCache modelIconCache, HolographicOutlineHelper holoOutlineHelper) {
+ mHolographicOutlineHelper = holoOutlineHelper;
ComponentName cn = new ComponentName(info.activityInfo.packageName, info.activityInfo.name);
mIcon = modelIconCache.getIcon(cn, info);
setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null);
setText(info.loadLabel(packageManager));
setTag(info);
+ }
- if (createHolographicOutlines) {
- mIconCache = cache;
- mIconCacheKey = new PagedViewIconCache.Key(info);
- mHolographicOutline = mIconCache.getOutline(mIconCacheKey);
- if (!queueHolographicOutlineCreation()) {
- getHolographicOutlineView().invalidate();
- }
- }
+ public void setHolographicOutline(Bitmap holoOutline) {
+ mHolographicOutline = holoOutline;
+ getHolographicOutlineView().invalidate();
}
@Override
public void setAlpha(float alpha) {
- final float viewAlpha = sHolographicOutlineHelper.viewAlphaInterpolator(alpha);
- final float holographicAlpha = sHolographicOutlineHelper.highlightAlphaInterpolator(alpha);
+ final float viewAlpha = mHolographicOutlineHelper.viewAlphaInterpolator(alpha);
+ final float holographicAlpha = mHolographicOutlineHelper.highlightAlphaInterpolator(alpha);
int newViewAlpha = (int) (viewAlpha * 255);
int newHolographicAlpha = (int) (holographicAlpha * 255);
if ((mAlpha != newViewAlpha) || (mHolographicAlpha != newHolographicAlpha)) {
@@ -247,12 +165,6 @@ public class PagedViewIcon extends CachedTextView implements Checkable {
}
@Override
- public void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- sWorker.removeMessages(MESSAGE_CREATE_HOLOGRAPHIC_OUTLINE, this);
- }
-
- @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return FocusHelper.handlePagedViewIconKeyEvent(this, keyCode, event)
|| super.onKeyDown(keyCode, event);