Skip to content

Commit 2a5c7b7

Browse files
committed
Merge pull request #2523 from wordpress-mobile/issue/2521-npe-background-download-web-image
fix #2521 npe background download web image
2 parents 69b323b + dd1885f commit 2a5c7b7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

WordPress/src/main/java/org/wordpress/android/ui/media/MediaUtils.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.wordpress.android.R;
2222
import org.wordpress.android.WordPress;
2323
import org.wordpress.android.WordPressDB;
24-
import org.wordpress.android.models.Blog;
2524
import org.wordpress.android.models.MediaFile;
2625
import org.wordpress.android.util.AppLog;
2726
import org.wordpress.android.util.AppLog.T;
@@ -131,7 +130,9 @@ protected Bitmap doInBackground(Uri... params) {
131130
if (bitmap == null) {
132131
URL url = new URL(uri);
133132
bitmap = BitmapFactory.decodeStream(url.openConnection().getInputStream());
134-
WordPress.getBitmapCache().put(uri, bitmap);
133+
if (bitmap != null) {
134+
WordPress.getBitmapCache().put(uri, bitmap);
135+
}
135136
}
136137

137138
return bitmap;
@@ -145,7 +146,7 @@ protected Bitmap doInBackground(Uri... params) {
145146
protected void onPostExecute(Bitmap result) {
146147
ImageView imageView = mReference.get();
147148

148-
if (imageView != null) {
149+
if (imageView != null && result != null) {
149150
if (imageView.getTag() == this) {
150151
imageView.setImageBitmap(result);
151152
fadeInImage(imageView, result);

0 commit comments

Comments
 (0)