From c3dce982fb05a7674d360255a9831adf83475099 Mon Sep 17 00:00:00 2001 From: Vladimir Baryshnikov Date: Mon, 1 Jul 2013 11:42:04 -0700 Subject: NetworkImage - fix nullPointerException. 1. getLayoutParams() can be null. 2. old version used LinearLayout.LayoutParams instead of ViewGroup.LayoutParams --- src/com/android/volley/toolbox/NetworkImageView.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/android/volley/toolbox/NetworkImageView.java b/src/com/android/volley/toolbox/NetworkImageView.java index d4f14e9..74c9159 100644 --- a/src/com/android/volley/toolbox/NetworkImageView.java +++ b/src/com/android/volley/toolbox/NetworkImageView.java @@ -18,8 +18,8 @@ package com.android.volley.toolbox; import android.content.Context; import android.text.TextUtils; import android.util.AttributeSet; +import android.view.ViewGroup.LayoutParams; import android.widget.ImageView; -import android.widget.LinearLayout.LayoutParams; import com.android.volley.VolleyError; import com.android.volley.toolbox.ImageLoader.ImageContainer; @@ -104,7 +104,8 @@ public class NetworkImageView extends ImageView { int width = getWidth(); int height = getHeight(); - boolean isFullyWrapContent = getLayoutParams().height == LayoutParams.WRAP_CONTENT + boolean isFullyWrapContent = getLayoutParams() != null + && getLayoutParams().height == LayoutParams.WRAP_CONTENT && getLayoutParams().width == LayoutParams.WRAP_CONTENT; // if the view's bounds aren't known yet, and this is not a wrap-content/wrap-content // view, hold off on loading the image. -- cgit v1.2.3