diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2016-11-09 10:43:58 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2016-12-13 10:31:12 -0800 |
commit | 1cd01b023acc123b771765b7297d8aaedac224e0 (patch) | |
tree | 9f275f4cbf290c7fb7e67a913bba14079abcd982 /src/com/android/launcher3/model | |
parent | 824c540f1911101321ebe7f05cb0885a4922e363 (diff) | |
download | android_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/model')
-rw-r--r-- | src/com/android/launcher3/model/CacheDataUpdatedTask.java | 10 | ||||
-rw-r--r-- | src/com/android/launcher3/model/PackageUpdatedTask.java | 17 |
2 files changed, 15 insertions, 12 deletions
diff --git a/src/com/android/launcher3/model/CacheDataUpdatedTask.java b/src/com/android/launcher3/model/CacheDataUpdatedTask.java index 9f24e9035..64771d530 100644 --- a/src/com/android/launcher3/model/CacheDataUpdatedTask.java +++ b/src/com/android/launcher3/model/CacheDataUpdatedTask.java @@ -25,6 +25,7 @@ import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherModel.CallbackTask; import com.android.launcher3.LauncherModel.Callbacks; import com.android.launcher3.LauncherSettings; +import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.ShortcutInfo; import com.android.launcher3.compat.UserHandleCompat; @@ -61,9 +62,10 @@ public class CacheDataUpdatedTask extends ExtendedModelTask { if (info instanceof ShortcutInfo && mUser.equals(info.user)) { ShortcutInfo si = (ShortcutInfo) info; ComponentName cn = si.getTargetComponent(); - if (isValidShortcut(si) && - cn != null && mPackages.contains(cn.getPackageName())) { - si.updateIcon(iconCache); + if (si.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION + && isValidShortcut(si) && cn != null + && mPackages.contains(cn.getPackageName())) { + iconCache.getTitleAndIcon(si, si.getPromisedIntent(), si.user, si.usingLowResIcon); updatedShortcuts.add(si); } } @@ -85,7 +87,7 @@ public class CacheDataUpdatedTask extends ExtendedModelTask { public boolean isValidShortcut(ShortcutInfo si) { switch (mOp) { case OP_CACHE_UPDATE: - return si.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; + return true; case OP_SESSION_UPDATE: return si.isPromise(); default: diff --git a/src/com/android/launcher3/model/PackageUpdatedTask.java b/src/com/android/launcher3/model/PackageUpdatedTask.java index 176e8ea25..aae3490a7 100644 --- a/src/com/android/launcher3/model/PackageUpdatedTask.java +++ b/src/com/android/launcher3/model/PackageUpdatedTask.java @@ -34,6 +34,7 @@ import com.android.launcher3.LauncherModel; import com.android.launcher3.LauncherModel.CallbackTask; import com.android.launcher3.LauncherModel.Callbacks; import com.android.launcher3.LauncherSettings; +import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.ShortcutInfo; import com.android.launcher3.Utilities; import com.android.launcher3.compat.LauncherAppsCompat; @@ -209,11 +210,9 @@ public class PackageUpdatedTask extends ExtendedModelTask { // Update shortcuts which use iconResource. if ((si.iconResource != null) && packageSet.contains(si.iconResource.packageName)) { - Bitmap icon = LauncherIcons.createIconBitmap( - si.iconResource.packageName, - si.iconResource.resourceName, context); + Bitmap icon = LauncherIcons.createIconBitmap(si.iconResource, context); if (icon != null) { - si.setIcon(icon); + si.iconBitmap = icon; infoUpdated = true; } } @@ -251,14 +250,16 @@ public class PackageUpdatedTask extends ExtendedModelTask { si.promisedIntent = null; si.status = ShortcutInfo.DEFAULT; infoUpdated = true; - si.updateIcon(iconCache); + if (si.itemType == Favorites.ITEM_TYPE_APPLICATION) { + iconCache.getTitleAndIcon(si, si.getPromisedIntent(), + si.user, si.usingLowResIcon); + } } if (appInfo != null && Intent.ACTION_MAIN.equals(si.intent.getAction()) && si.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) { - si.updateIcon(iconCache); - si.title = Utilities.trim(appInfo.title); - si.contentDescription = appInfo.contentDescription; + iconCache.getTitleAndIcon( + si, si.getPromisedIntent(), si.user, si.usingLowResIcon); infoUpdated = true; } |