Manual revert due to conflict:

Revert "Load label in bg thread to prevent ANR b/27238970"

This reverts commit b62fd09576.

Change-Id: Ia751e3414fb24a18bb8bb9ca09dcd93d0e4249f6
This commit is contained in:
Hyunyoung Song
2016-02-23 11:36:21 -08:00
parent e1bd986d77
commit d31dcbcc7c
3 changed files with 34 additions and 52 deletions

View File

@@ -136,23 +136,32 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
}
/**
* Apply the widget provider info or the resolve info to the view.
* Apply the widget provider info to the view.
*/
public void applyFromInfo(Object info, CharSequence label,
WidgetPreviewLoader loader) {
public void applyFromAppWidgetProviderInfo(LauncherAppWidgetProviderInfo info,
WidgetPreviewLoader loader) {
InvariantDeviceProfile profile =
LauncherAppState.getInstance().getInvariantDeviceProfile();
mInfo = info;
mWidgetName.setText(label);
// 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() {