summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2014-08-15 21:47:45 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-08-15 21:47:45 +0000
commita4dd2c336f289b67d194056b9d4acd9ab5676ab5 (patch)
tree4c9fefea0cfd070834e72ef2eef2674288b59da6
parenta981cfba7b8f29f0433fcf7910daa46ab6d071a7 (diff)
parentbe55d637d904201b9df0333778790758318edef3 (diff)
downloadframeworks_base-a4dd2c336f289b67d194056b9d4acd9ab5676ab5.zip
frameworks_base-a4dd2c336f289b67d194056b9d4acd9ab5676ab5.tar.gz
frameworks_base-a4dd2c336f289b67d194056b9d4acd9ab5676ab5.tar.bz2
am 6ba6c6ce: am c4949481: Merge "Returning null when preview image is not available for AppWidgetProviderInfo" into lmp-dev
* commit '6ba6c6cecbfe58295c07d6c793aebbc3d9ea2ec2': Returning null when preview image is not available for AppWidgetProviderInfo
-rw-r--r--core/java/android/appwidget/AppWidgetProviderInfo.java15
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;
}
/**