summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Olsson <roger.olsson@sony.com>2018-04-12 08:08:01 (GMT)
committerAlexander Martinz <amartinz@shiftphones.com>2018-04-27 08:14:06 (GMT)
commitcfe2ebcd4298e898f9b3099dfb7b72433a839ae8 (patch)
tree8af84640b334feeae968c2e5abc313ea809b1433
parentf8f263a9c350d9561cfe6169596e5b1186d5d838 (diff)
downloadandroid_packages_apps_Trebuchet-cfe2ebcd4298e898f9b3099dfb7b72433a839ae8.zip
android_packages_apps_Trebuchet-cfe2ebcd4298e898f9b3099dfb7b72433a839ae8.tar.gz
android_packages_apps_Trebuchet-cfe2ebcd4298e898f9b3099dfb7b72433a839ae8.tar.bz2
Avoid crash when widget previews have no intrinsic size
Intrinsic size for widget preview drawable checked. Needed since some drawables, like color drawables, do not have any intrinsic size. Bug: 78452220 Test: manual, see Bug info. Change-Id: I815353773e38b1fce2fe19962f07c1727e1b0768
-rw-r--r--src/com/android/launcher3/WidgetPreviewLoader.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/com/android/launcher3/WidgetPreviewLoader.java b/src/com/android/launcher3/WidgetPreviewLoader.java
index a65ea9b..e8c1361 100644
--- a/src/com/android/launcher3/WidgetPreviewLoader.java
+++ b/src/com/android/launcher3/WidgetPreviewLoader.java
@@ -340,7 +340,8 @@ public class WidgetPreviewLoader {
int previewWidth;
int previewHeight;
- if (widgetPreviewExists) {
+ if (widgetPreviewExists && drawable.getIntrinsicWidth() > 0
+ && drawable.getIntrinsicHeight() > 0) {
previewWidth = drawable.getIntrinsicWidth();
previewHeight = drawable.getIntrinsicHeight();
} else {
@@ -360,8 +361,8 @@ public class WidgetPreviewLoader {
scale = maxPreviewWidth / (float) (previewWidth);
}
if (scale != 1f) {
- previewWidth = (int) (scale * previewWidth);
- previewHeight = (int) (scale * previewHeight);
+ previewWidth = Math.max((int)(scale * previewWidth), 1);
+ previewHeight = Math.max((int)(scale * previewHeight), 1);
}
// If a bitmap is passed in, we use it; otherwise, we create a bitmap of the right size