Merge "Avoid crash when widget previews have no intrinsic size"
am: f51b706439
Change-Id: I801969e037a0f8e41c536b695a3acb67d4e1f599
This commit is contained in:
@@ -340,7 +340,8 @@ public class WidgetPreviewLoader {
|
|||||||
int previewWidth;
|
int previewWidth;
|
||||||
int previewHeight;
|
int previewHeight;
|
||||||
|
|
||||||
if (widgetPreviewExists) {
|
if (widgetPreviewExists && drawable.getIntrinsicWidth() > 0
|
||||||
|
&& drawable.getIntrinsicHeight() > 0) {
|
||||||
previewWidth = drawable.getIntrinsicWidth();
|
previewWidth = drawable.getIntrinsicWidth();
|
||||||
previewHeight = drawable.getIntrinsicHeight();
|
previewHeight = drawable.getIntrinsicHeight();
|
||||||
} else {
|
} else {
|
||||||
@@ -360,8 +361,8 @@ public class WidgetPreviewLoader {
|
|||||||
scale = maxPreviewWidth / (float) (previewWidth);
|
scale = maxPreviewWidth / (float) (previewWidth);
|
||||||
}
|
}
|
||||||
if (scale != 1f) {
|
if (scale != 1f) {
|
||||||
previewWidth = (int) (scale * previewWidth);
|
previewWidth = Math.max((int)(scale * previewWidth), 1);
|
||||||
previewHeight = (int) (scale * previewHeight);
|
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
|
// If a bitmap is passed in, we use it; otherwise, we create a bitmap of the right size
|
||||||
|
|||||||
Reference in New Issue
Block a user