summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/widget/WidgetCell.java
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2016-02-22 16:36:15 -0800
committerHyunyoung Song <hyunyoungs@google.com>2016-02-23 00:45:56 +0000
commitb62fd0957607ae54c7bca7ce64eed288a11f0f2f (patch)
treebdb4bb21ea9ebbaa6d18a12624a7e81eec58baf1 /src/com/android/launcher3/widget/WidgetCell.java
parenta6194d3d9205488d6f5400193f8d4d6aaf140218 (diff)
downloadandroid_packages_apps_Trebuchet-b62fd0957607ae54c7bca7ce64eed288a11f0f2f.tar.gz
android_packages_apps_Trebuchet-b62fd0957607ae54c7bca7ce64eed288a11f0f2f.tar.bz2
android_packages_apps_Trebuchet-b62fd0957607ae54c7bca7ce64eed288a11f0f2f.zip
Load label in bg thread to prevent ANR
b/27238970 Change-Id: Ic5d77df7d5276cee07861d59427a94fb19691d9c (cherry picked from commit 72a9953cf463e0e7a8d24903f1692828ffe5b017)
Diffstat (limited to 'src/com/android/launcher3/widget/WidgetCell.java')
-rw-r--r--src/com/android/launcher3/widget/WidgetCell.java35
1 files changed, 13 insertions, 22 deletions
diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java
index 94bbd929f..75c84c32f 100644
--- a/src/com/android/launcher3/widget/WidgetCell.java
+++ b/src/com/android/launcher3/widget/WidgetCell.java
@@ -136,32 +136,23 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
}
/**
- * Apply the widget provider info to the view.
+ * Apply the widget provider info or the resolve info to the view.
*/
- public void applyFromAppWidgetProviderInfo(LauncherAppWidgetProviderInfo info,
- WidgetPreviewLoader loader) {
-
- InvariantDeviceProfile profile =
- LauncherAppState.getInstance().getInvariantDeviceProfile();
+ public void applyFromInfo(Object info, CharSequence label,
+ WidgetPreviewLoader loader) {
mInfo = info;
- // TODO(hyunyoungs): setup a cache for these labels.
- mWidgetName.setText(AppWidgetManagerCompat.getInstance(getContext()).loadLabel(info));
- int hSpan = Math.min(info.spanX, profile.numColumns);
- int vSpan = Math.min(info.spanY, profile.numRows);
- mWidgetDims.setText(String.format(mDimensionsFormatString, hSpan, vSpan));
- mWidgetPreviewLoader = loader;
- }
-
- /**
- * Apply the resolve info to the view.
- */
- public void applyFromResolveInfo(
- PackageManager pm, ResolveInfo info, WidgetPreviewLoader loader) {
- mInfo = info;
- CharSequence label = info.loadLabel(pm);
mWidgetName.setText(label);
- mWidgetDims.setText(String.format(mDimensionsFormatString, 1, 1));
mWidgetPreviewLoader = loader;
+ if (info instanceof LauncherAppWidgetProviderInfo) {
+ InvariantDeviceProfile profile =
+ LauncherAppState.getInstance().getInvariantDeviceProfile();
+ int hSpan = Math.min(((LauncherAppWidgetProviderInfo)info).spanX, profile.numColumns);
+ int vSpan = Math.min(((LauncherAppWidgetProviderInfo)info).spanY, profile.numRows);
+ mWidgetDims.setText(String.format(mDimensionsFormatString, hSpan, vSpan));
+ }
+ if (info instanceof ResolveInfo) {
+ mWidgetDims.setText(String.format(mDimensionsFormatString, 1, 1));
+ }
}
public int[] getPreviewSize() {