From 6f39b40ff540378dd883c2e813f54e98072f95db Mon Sep 17 00:00:00 2001 From: Alex Yanchenko Date: Fri, 3 May 2013 02:57:10 +0300 Subject: [PATCH] Fixed ImageSizeUtils.defineTargetSizeForView() NPE crash with standalone ImageViews. --- .../universalimageloader/utils/ImageSizeUtils.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/src/com/nostra13/universalimageloader/utils/ImageSizeUtils.java b/library/src/com/nostra13/universalimageloader/utils/ImageSizeUtils.java index e94f350f3..ed6127db9 100644 --- a/library/src/com/nostra13/universalimageloader/utils/ImageSizeUtils.java +++ b/library/src/com/nostra13/universalimageloader/utils/ImageSizeUtils.java @@ -52,14 +52,14 @@ public static ImageSize defineTargetSizeForView(ImageView imageView, int maxImag final DisplayMetrics displayMetrics = imageView.getContext().getResources().getDisplayMetrics(); final LayoutParams params = imageView.getLayoutParams(); - int width = params.width == LayoutParams.WRAP_CONTENT ? 0 : imageView.getWidth(); // Get actual image width - if (width <= 0) width = params.width; // Get layout width parameter + int width = (params != null && params.width == LayoutParams.WRAP_CONTENT) ? 0 : imageView.getWidth(); // Get actual image width + if (width <= 0) width = (params != null) ? params.width : width; // Get layout width parameter if (width <= 0) width = getImageViewFieldValue(imageView, "mMaxWidth"); // Check maxWidth parameter if (width <= 0) width = maxImageWidth; if (width <= 0) width = displayMetrics.widthPixels; - int height = params.height == LayoutParams.WRAP_CONTENT ? 0 : imageView.getHeight(); // Get actual image height - if (height <= 0) height = params.height; // Get layout height parameter + int height = (params != null && params.height == LayoutParams.WRAP_CONTENT) ? 0 : imageView.getHeight(); // Get actual image height + if (height <= 0) height = (params != null) ? params.height : height; // Get layout height parameter if (height <= 0) height = getImageViewFieldValue(imageView, "mMaxHeight"); // Check maxHeight parameter if (height <= 0) height = maxImageHeight; if (height <= 0) height = displayMetrics.heightPixels;