summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/LauncherModel.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-11-09 10:43:58 -0800
committerSunny Goyal <sunnygoyal@google.com>2016-12-13 10:31:12 -0800
commit1cd01b023acc123b771765b7297d8aaedac224e0 (patch)
tree9f275f4cbf290c7fb7e67a913bba14079abcd982 /src/com/android/launcher3/LauncherModel.java
parent824c540f1911101321ebe7f05cb0885a4922e363 (diff)
downloadandroid_packages_apps_Trebuchet-1cd01b023acc123b771765b7297d8aaedac224e0.tar.gz
android_packages_apps_Trebuchet-1cd01b023acc123b771765b7297d8aaedac224e0.tar.bz2
android_packages_apps_Trebuchet-1cd01b023acc123b771765b7297d8aaedac224e0.zip
Ensuring that ShortcutInfo always has an icon
> Making iconBitmap public instead of a getter (similar to AppInfo) > Removing getIcon() which can lead to IO on UI thread > Removing updateIcon and handling the update at the caller Bug: 21325319 Change-Id: I6a49b9043f974e9629ea25e77012d97cc04c0594
Diffstat (limited to 'src/com/android/launcher3/LauncherModel.java')
-rw-r--r--src/com/android/launcher3/LauncherModel.java50
1 files changed, 21 insertions, 29 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index cc56d439f..2a6f56bf0 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1792,8 +1792,10 @@ public class LauncherModel extends BroadcastReceiver
Collections.sort(folder.contents, Folder.ITEM_POS_COMPARATOR);
int pos = 0;
for (ShortcutInfo info : folder.contents) {
- if (info.usingLowResIcon) {
- info.updateIcon(mIconCache, false);
+ if (info.usingLowResIcon &&
+ info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
+ mIconCache.getTitleAndIcon(
+ info, info.getPromisedIntent(), info.user, false);
}
pos ++;
if (pos >= FolderIcon.NUM_ITEMS_IN_PREVIEW) {
@@ -2518,13 +2520,10 @@ public class LauncherModel extends BroadcastReceiver
int promiseType, int itemType, CursorIconInfo iconInfo) {
final ShortcutInfo info = new ShortcutInfo();
info.user = UserHandleCompat.myUserHandle();
-
- Bitmap icon = iconInfo.loadIcon(c, info);
+ info.iconBitmap = iconInfo.loadIcon(c, info);
// the fallback icon
- if (icon == null) {
+ if (info.iconBitmap == null) {
mIconCache.getTitleAndIcon(info, intent, info.user, false /* useLowResIcon */);
- } else {
- info.setIcon(icon);
}
if ((promiseType & ShortcutInfo.FLAG_RESTORED_ICON) != 0) {
@@ -2595,9 +2594,9 @@ public class LauncherModel extends BroadcastReceiver
final ShortcutInfo info = new ShortcutInfo();
mIconCache.getTitleAndIcon(info, componentName, lai, user, false, useLowResIcon);
- if (mIconCache.isDefaultIcon(info.getIcon(mIconCache), user) && c != null) {
+ if (mIconCache.isDefaultIcon(info.iconBitmap, user) && c != null) {
Bitmap icon = iconInfo.loadIcon(c);
- info.setIcon(icon == null ? mIconCache.getDefaultIcon(user) : icon);
+ info.iconBitmap = icon != null ? icon : mIconCache.getDefaultIcon(user);
}
if (lai != null && PackageManagerHelper.isAppSuspended(lai.getApplicationInfo())) {
@@ -2640,12 +2639,11 @@ public class LauncherModel extends BroadcastReceiver
*/
public void loadInfoFromCursor(ShortcutInfo info, Cursor c, CursorIconInfo iconInfo) {
info.title = iconInfo.getTitle(c);
- Bitmap icon = iconInfo.loadIcon(c, info);
+ info.iconBitmap = iconInfo.loadIcon(c, info);
// the fallback icon
- if (icon == null) {
- icon = mIconCache.getDefaultIcon(info.user);
+ if (info.iconBitmap == null) {
+ info.iconBitmap = mIconCache.getDefaultIcon(info.user);
}
- info.setIcon(icon);
}
ShortcutInfo infoFromShortcutIntent(Context context, Intent data) {
@@ -2659,34 +2657,28 @@ public class LauncherModel extends BroadcastReceiver
return null;
}
- Bitmap icon = null;
- ShortcutIconResource iconResource = null;
+ final ShortcutInfo info = new ShortcutInfo();
+
+ // Only support intents for current user for now. Intents sent from other
+ // users wouldn't get here without intent forwarding anyway.
+ info.user = UserHandleCompat.myUserHandle();
if (bitmap instanceof Bitmap) {
- icon = LauncherIcons.createIconBitmap((Bitmap) bitmap, context);
+ info.iconBitmap = LauncherIcons.createIconBitmap((Bitmap) bitmap, context);
} else {
Parcelable extra = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
if (extra instanceof ShortcutIconResource) {
- iconResource = (ShortcutIconResource) extra;
- icon = LauncherIcons.createIconBitmap(iconResource.packageName,
- iconResource.resourceName, context);
+ info.iconResource = (ShortcutIconResource) extra;
+ info.iconBitmap = LauncherIcons.createIconBitmap(info.iconResource, context);
}
}
-
- final ShortcutInfo info = new ShortcutInfo();
-
- // Only support intents for current user for now. Intents sent from other
- // users wouldn't get here without intent forwarding anyway.
- info.user = UserHandleCompat.myUserHandle();
- if (icon == null) {
- icon = mIconCache.getDefaultIcon(info.user);
+ if (info.iconBitmap == null) {
+ info.iconBitmap = mIconCache.getDefaultIcon(info.user);
}
- info.setIcon(icon);
info.title = Utilities.trim(name);
info.contentDescription = mUserManager.getBadgedLabelForUser(info.title, info.user);
info.intent = intent;
- info.iconResource = iconResource;
return info;
}