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-22 16:36:15 -0800
commit72a9953cf463e0e7a8d24903f1692828ffe5b017 (patch)
treeacfe28f7974788e9b00a5dcadf6233b18bfd09f1 /src/com/android/launcher3/widget/WidgetCell.java
parentfbf19cccd293ca23cbed38eaa25abc6ea72be83e (diff)
downloadandroid_packages_apps_Trebuchet-72a9953cf463e0e7a8d24903f1692828ffe5b017.tar.gz
android_packages_apps_Trebuchet-72a9953cf463e0e7a8d24903f1692828ffe5b017.tar.bz2
android_packages_apps_Trebuchet-72a9953cf463e0e7a8d24903f1692828ffe5b017.zip
Load label in bg thread to prevent ANR
b/27238970 Change-Id: Ic5d77df7d5276cee07861d59427a94fb19691d9c
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 70eceb9ce..ec2bd70b1 100644
--- a/src/com/android/launcher3/widget/WidgetCell.java
+++ b/src/com/android/launcher3/widget/WidgetCell.java
@@ -137,32 +137,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() {