aboutsummaryrefslogtreecommitdiff
path: root/library/src/main/java/com
diff options
context:
space:
mode:
authorSam Judd <judds@google.com>2014-10-22 19:03:05 -0700
committerSam Judd <judds@google.com>2014-10-22 19:03:05 -0700
commitf4e84300ed9c3a518f4bda4d29f417202e0e3adf (patch)
tree58fbda621deda967517c27193e5ef4924c362487 /library/src/main/java/com
parent1c213bd9646c0292439767103060391121624ff9 (diff)
downloadglide-f4e84300ed9c3a518f4bda4d29f417202e0e3adf.tar.gz
Throw when given null data in Resources.
Adds assertions for #212.
Diffstat (limited to 'library/src/main/java/com')
-rw-r--r--library/src/main/java/com/bumptech/glide/load/engine/EngineResource.java3
-rw-r--r--library/src/main/java/com/bumptech/glide/load/resource/SimpleResource.java3
-rw-r--r--library/src/main/java/com/bumptech/glide/load/resource/bitmap/BitmapResource.java6
-rw-r--r--library/src/main/java/com/bumptech/glide/load/resource/bytes/BytesResource.java3
-rw-r--r--library/src/main/java/com/bumptech/glide/load/resource/drawable/DrawableResource.java3
-rw-r--r--library/src/main/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapWrapperResource.java3
6 files changed, 21 insertions, 0 deletions
diff --git a/library/src/main/java/com/bumptech/glide/load/engine/EngineResource.java b/library/src/main/java/com/bumptech/glide/load/engine/EngineResource.java
index 92574e1f..4cf275f4 100644
--- a/library/src/main/java/com/bumptech/glide/load/engine/EngineResource.java
+++ b/library/src/main/java/com/bumptech/glide/load/engine/EngineResource.java
@@ -22,6 +22,9 @@ class EngineResource<Z> implements Resource<Z> {
}
EngineResource(Resource<Z> toWrap, boolean isCacheable) {
+ if (toWrap == null) {
+ throw new NullPointerException("Wrapped resource must not be null");
+ }
resource = toWrap;
this.isCacheable = isCacheable;
}
diff --git a/library/src/main/java/com/bumptech/glide/load/resource/SimpleResource.java b/library/src/main/java/com/bumptech/glide/load/resource/SimpleResource.java
index 4dca7fb1..33ccbb8a 100644
--- a/library/src/main/java/com/bumptech/glide/load/resource/SimpleResource.java
+++ b/library/src/main/java/com/bumptech/glide/load/resource/SimpleResource.java
@@ -13,6 +13,9 @@ public class SimpleResource<T> implements Resource<T> {
protected final T data;
public SimpleResource(T data) {
+ if (data == null) {
+ throw new NullPointerException("Data must not be null");
+ }
this.data = data;
}
diff --git a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/BitmapResource.java b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/BitmapResource.java
index 0ce032ea..939f930a 100644
--- a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/BitmapResource.java
+++ b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/BitmapResource.java
@@ -13,6 +13,12 @@ public class BitmapResource implements Resource<Bitmap> {
private final BitmapPool bitmapPool;
public BitmapResource(Bitmap bitmap, BitmapPool bitmapPool) {
+ if (bitmap == null) {
+ throw new NullPointerException("Bitmap must not be null");
+ }
+ if (bitmapPool == null) {
+ throw new NullPointerException("BitmapPool must not be null");
+ }
this.bitmap = bitmap;
this.bitmapPool = bitmapPool;
}
diff --git a/library/src/main/java/com/bumptech/glide/load/resource/bytes/BytesResource.java b/library/src/main/java/com/bumptech/glide/load/resource/bytes/BytesResource.java
index eb29217d..a6368d26 100644
--- a/library/src/main/java/com/bumptech/glide/load/resource/bytes/BytesResource.java
+++ b/library/src/main/java/com/bumptech/glide/load/resource/bytes/BytesResource.java
@@ -9,6 +9,9 @@ public class BytesResource implements Resource<byte[]> {
private final byte[] bytes;
public BytesResource(byte[] bytes) {
+ if (bytes == null) {
+ throw new NullPointerException("Bytes must not be null");
+ }
this.bytes = bytes;
}
diff --git a/library/src/main/java/com/bumptech/glide/load/resource/drawable/DrawableResource.java b/library/src/main/java/com/bumptech/glide/load/resource/drawable/DrawableResource.java
index b3efc621..643f7b40 100644
--- a/library/src/main/java/com/bumptech/glide/load/resource/drawable/DrawableResource.java
+++ b/library/src/main/java/com/bumptech/glide/load/resource/drawable/DrawableResource.java
@@ -18,6 +18,9 @@ public abstract class DrawableResource<T extends Drawable> implements Resource<T
private boolean returnedOriginalDrawable;
public DrawableResource(T drawable) {
+ if (drawable == null) {
+ throw new NullPointerException("Drawable must not be null!");
+ }
this.drawable = drawable;
}
diff --git a/library/src/main/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapWrapperResource.java b/library/src/main/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapWrapperResource.java
index 7e10e008..5dab61b3 100644
--- a/library/src/main/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapWrapperResource.java
+++ b/library/src/main/java/com/bumptech/glide/load/resource/gifbitmap/GifBitmapWrapperResource.java
@@ -11,6 +11,9 @@ public class GifBitmapWrapperResource implements Resource<GifBitmapWrapper> {
private final GifBitmapWrapper data;
public GifBitmapWrapperResource(GifBitmapWrapper data) {
+ if (data == null) {
+ throw new NullPointerException("Data must not be null");
+ }
this.data = data;
}