diff options
| author | Sunny Goyal <sunnygoyal@google.com> | 2014-08-15 21:41:11 +0000 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2014-08-15 21:41:11 +0000 |
| commit | be55d637d904201b9df0333778790758318edef3 (patch) | |
| tree | ba6c350dd3412b3b8a93d53109e3542ae77b96d7 /core/java/android | |
| parent | 1db2391d9fb05dc20846731c41c76bb806327fb9 (diff) | |
| parent | 336eaae177d8c836549bc2a589ef16e72e772ef5 (diff) | |
| download | frameworks_base-be55d637d904201b9df0333778790758318edef3.zip frameworks_base-be55d637d904201b9df0333778790758318edef3.tar.gz frameworks_base-be55d637d904201b9df0333778790758318edef3.tar.bz2 | |
am c4949481: Merge "Returning null when preview image is not available for AppWidgetProviderInfo" into lmp-dev
* commit 'c49494811aa1ed42c3f0b0519cb037e239f8b0e8':
Returning null when preview image is not available for AppWidgetProviderInfo
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/appwidget/AppWidgetProviderInfo.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/core/java/android/appwidget/AppWidgetProviderInfo.java b/core/java/android/appwidget/AppWidgetProviderInfo.java index a767246..0b40e35 100644 --- a/core/java/android/appwidget/AppWidgetProviderInfo.java +++ b/core/java/android/appwidget/AppWidgetProviderInfo.java @@ -271,13 +271,13 @@ public class AppWidgetProviderInfo implements Parcelable { * @return The provider icon. */ public final Drawable loadIcon(@NonNull Context context, int density) { - return loadDrawable(context, density, providerInfo.getIconResource()); + return loadDrawable(context, density, providerInfo.getIconResource(), true); } /** * Loads a preview of what the AppWidget will look like after it's configured. - * If not supplied, the AppWidget's icon will be used. A client can optionally - * provide a desired deinsity such as {@link android.util.DisplayMetrics#DENSITY_LOW} + * A client can optionally provide a desired density such as + * {@link android.util.DisplayMetrics#DENSITY_LOW} * {@link android.util.DisplayMetrics#DENSITY_MEDIUM}, etc. If no density is * provided, the density of the current display will be used. * <p> @@ -288,10 +288,10 @@ public class AppWidgetProviderInfo implements Parcelable { * @param context Context for accessing resources. * @param density The optional desired density as per * {@link android.util.DisplayMetrics#densityDpi}. - * @return The widget preview image. + * @return The widget preview image or {@null} if preview image is not available. */ public final Drawable loadPreviewImage(@NonNull Context context, int density) { - return loadDrawable(context, density, previewImage); + return loadDrawable(context, density, previewImage, false); } /** @@ -361,7 +361,8 @@ public class AppWidgetProviderInfo implements Parcelable { return 0; } - private Drawable loadDrawable(Context context, int density, int resourceId) { + private Drawable loadDrawable(Context context, int density, int resourceId, + boolean loadDefaultIcon) { try { Resources resources = context.getPackageManager().getResourcesForApplication( providerInfo.applicationInfo); @@ -374,7 +375,7 @@ public class AppWidgetProviderInfo implements Parcelable { } catch (PackageManager.NameNotFoundException | Resources.NotFoundException e) { /* ignore */ } - return providerInfo.loadIcon(context.getPackageManager()); + return loadDefaultIcon ? providerInfo.loadIcon(context.getPackageManager()) : null; } /** |
