aboutsummaryrefslogtreecommitdiff
path: root/library/src/main/java/com/bumptech
diff options
context:
space:
mode:
authorSam Judd <judds@google.com>2014-10-03 19:03:39 -0700
committerSam Judd <judds@google.com>2014-10-03 19:10:02 -0700
commit29438d5d293744613485914005d2717e03cae485 (patch)
tree7f20b6b8c165d1f5de7afb73ae378aa0c455ed7d /library/src/main/java/com/bumptech
parentf08ab536741266de5ed3887a2b3d5469299e89e9 (diff)
downloadglide-29438d5d293744613485914005d2717e03cae485.tar.gz
Add an empty constructor for SimpleTarget.
Fixes #170.
Diffstat (limited to 'library/src/main/java/com/bumptech')
-rw-r--r--library/src/main/java/com/bumptech/glide/request/target/SimpleTarget.java22
1 files changed, 18 insertions, 4 deletions
diff --git a/library/src/main/java/com/bumptech/glide/request/target/SimpleTarget.java b/library/src/main/java/com/bumptech/glide/request/target/SimpleTarget.java
index 1f62a1d8..78522c32 100644
--- a/library/src/main/java/com/bumptech/glide/request/target/SimpleTarget.java
+++ b/library/src/main/java/com/bumptech/glide/request/target/SimpleTarget.java
@@ -28,16 +28,26 @@ public abstract class SimpleTarget<Z> extends BaseTarget<Z> {
private final int height;
/**
+ * Constructor for the target that assumes you will have called
+ * {@link com.bumptech.glide.GenericRequestBuilder#override(int, int)} on the request builder this target is given
+ * to.
+ *
+ * <p>
+ * Requests that load into this target will throw an {@link java.lang.IllegalArgumentException} if
+ * {@link com.bumptech.glide.GenericRequestBuilder#override(int, int)} was not called on the request builder.
+ * </p>
+ */
+ public SimpleTarget() {
+ this(-1, -1);
+ }
+
+ /**
* Constructor for the target that takes the desired dimensions of the decoded and/or transformed resource.
*
* @param width The desired width of the resource.
* @param height The desired height of the resource.
*/
public SimpleTarget(int width, int height) {
- if (width <= 0 || height <= 0) {
- throw new IllegalArgumentException("Width and height must both be > 0, but given width: " + width + " and"
- + " height: " + height);
- }
this.width = width;
this.height = height;
}
@@ -49,6 +59,10 @@ public abstract class SimpleTarget<Z> extends BaseTarget<Z> {
*/
@Override
public final void getSize(SizeReadyCallback cb) {
+ if (width <= 0 || height <= 0) {
+ throw new IllegalArgumentException("Width and height must both be > 0, but given width: " + width + " and"
+ + " height: " + height + ", either provide dimensions in the constructor or call override()");
+ }
cb.onSizeReady(width, height);
}
}