Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE crash fix. #272

Merged
merged 1 commit into from
May 16, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down