diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2015-03-11 16:56:52 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2015-03-17 15:05:23 -0700 |
commit | 34b6527cefd36fbd5da78464ce9771e379158552 (patch) | |
tree | b7884c2d9c7500c54b9e5fcb54161cc2d00904c6 /src/com/android/launcher3/BubbleTextView.java | |
parent | 5d85c44fd873c740dc191b28424c2ee367d730a2 (diff) | |
download | android_packages_apps_Trebuchet-34b6527cefd36fbd5da78464ce9771e379158552.tar.gz android_packages_apps_Trebuchet-34b6527cefd36fbd5da78464ce9771e379158552.tar.bz2 android_packages_apps_Trebuchet-34b6527cefd36fbd5da78464ce9771e379158552.zip |
Lazy loading high res icons
> Loading low-res icons for icons which are not visible on
the homescreen.
Change-Id: I8ac7bf09f6030ed554cb60a4cd402f3f36ffe12b
Diffstat (limited to 'src/com/android/launcher3/BubbleTextView.java')
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 8ef234bb0..50549cad0 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -34,6 +34,8 @@ import android.view.MotionEvent; import android.view.ViewConfiguration; import android.widget.TextView; +import com.android.launcher3.IconCache.IconLoadRequest; + /** * TextView that draws a bubble behind the text. We cannot use a LineBackgroundSpan * because we want to make the bubble taller than the text and TextView's clip is @@ -74,6 +76,8 @@ public class BubbleTextView extends TextView { private boolean mStayPressed; private boolean mIgnorePressedStateChange; + private IconLoadRequest mIconLoadRequest; + public BubbleTextView(Context context) { this(context, null, 0); } @@ -163,6 +167,9 @@ public class BubbleTextView extends TextView { } // We don't need to check the info since it's not a ShortcutInfo super.setTag(info); + + // Verify high res immediately + verifyHighRes(); } @Override @@ -450,4 +457,42 @@ public class BubbleTextView extends TextView { } return icon; } + + /** + * Applies the item info if it is same as what the view is pointing to currently. + */ + public void reapplyItemInfo(final ItemInfo info) { + if (getTag() == info) { + mIconLoadRequest = null; + if (info instanceof AppInfo) { + applyFromApplicationInfo((AppInfo) info); + } else if (info instanceof ShortcutInfo) { + applyFromShortcutInfo((ShortcutInfo) info, + LauncherAppState.getInstance().getIconCache(), false); + } + } + } + + /** + * Verifies that the current icon is high-res otherwise posts a request to load the icon. + */ + public void verifyHighRes() { + if (mIconLoadRequest != null) { + mIconLoadRequest.cancel(); + mIconLoadRequest = null; + } + if (getTag() instanceof AppInfo) { + AppInfo info = (AppInfo) getTag(); + if (info.usingLowResIcon) { + mIconLoadRequest = LauncherAppState.getInstance().getIconCache() + .updateIconInBackground(BubbleTextView.this, info); + } + } else if (getTag() instanceof ShortcutInfo) { + ShortcutInfo info = (ShortcutInfo) getTag(); + if (info.usingLowResIcon) { + mIconLoadRequest = LauncherAppState.getInstance().getIconCache() + .updateIconInBackground(BubbleTextView.this, info); + } + } + } } |