- implements BitmapOptions {
+ implements BitmapOptions, DrawableOptions {
private final Glide glide;
private final Context context;
@@ -186,90 +186,35 @@ public class DrawableRequestBuilder
}
/**
- * Applies a cross fade transformation that fades from the placeholder to the loaded
- * {@link android.graphics.drawable.Drawable}. If no placeholder is set, the Drawable will instead simply fade in.
- *
- *
- * Note - this only works by default for {@link android.view.View}s and
- * {@link com.bumptech.glide.request.target.ViewTarget}s.
- *
- *
- * @see #crossFade(int)
- * @see #crossFade(int, int)
- * @see #crossFade(android.view.animation.Animation, int)
- *
- * @return This request builder.
+ * {@inheritDoc}
*/
public DrawableRequestBuilder crossFade() {
- super.animate(new DrawableCrossFadeViewAnimation.DrawableCrossFadeFactory());
+ super.animate(new DrawableCrossFadeViewAnimation.DrawableCrossFadeFactory());
return this;
}
/**
- * Applies a cross fade transformation that fades from the placeholder to the loaded
- * {@link android.graphics.drawable.Drawable}. If no placeholder is set the Drawable will instead simply fade in.
- *
- *
- * Note - this only works by default for {@link android.view.View}s and
- * {@link com.bumptech.glide.request.target.ViewTarget}s.
- *
- *
- * @see #crossFade()
- * @see #crossFade(int, int)
- * @see #crossFade(android.view.animation.Animation, int)
- *
- * @param duration The duration of the cross fade and initial fade in.
- * @return This request builder.
+ * {@inheritDoc}
*/
public DrawableRequestBuilder crossFade(int duration) {
- super.animate(new DrawableCrossFadeViewAnimation.DrawableCrossFadeFactory(duration));
+ super.animate(new DrawableCrossFadeViewAnimation.DrawableCrossFadeFactory(duration));
return this;
}
/**
- * Applies a cross fade transformation that des from the placeholder to the loaded
- * {@link android.graphics.drawable.Drawable}. If no placeholder is set, the Drawable will instead be animated in
- * using the given {@link android.view.animation.Animation}.
- *
- *
- * Note - this only works by default for {@link android.view.View}s and
- * {@link com.bumptech.glide.request.target.ViewTarget}s.
- *
- *
- * @see #crossFade()
- * @see #crossFade(int)
- * @see #crossFade(int, int)
- *
- * @param animation The Animation to use if no placeholder is set.
- * @param duration The duration of the cross fade animation.
- * @return This request builder.
+ * {@inheritDoc}
*/
public DrawableRequestBuilder crossFade(Animation animation, int duration) {
- super.animate(new DrawableCrossFadeViewAnimation.DrawableCrossFadeFactory(animation, duration));
+ super.animate(new DrawableCrossFadeViewAnimation.DrawableCrossFadeFactory(animation, duration));
return this;
}
-
/**
- * Applies a cross fade transformation that des from the placeholder to the loaded
- * {@link android.graphics.drawable.Drawable}. If no placeholder is set, the Drawable will instead be animated in
- * using the {@link android.view.animation.Animation} loaded from the given animation id.
- *
- *
- * Note - this only works by default for {@link android.view.View}s and
- * {@link com.bumptech.glide.request.target.ViewTarget}s.
- *
- *
- * @see #crossFade()
- * @see #crossFade(int)
- * @see #crossFade(android.view.animation.Animation, int)
- *
- * @param animationId The id of the Animation to use if no placeholder is set.
- * @param duration The duration of the cross fade animation.
- * @return This request builder.
+ * {@inheritDoc}
*/
public DrawableRequestBuilder crossFade(int animationId, int duration) {
- super.animate(new DrawableCrossFadeViewAnimation.DrawableCrossFadeFactory(context, animationId, duration));
+ super.animate(new DrawableCrossFadeViewAnimation.DrawableCrossFadeFactory(context, animationId,
+ duration));
return this;
}
diff --git a/library/src/main/java/com/bumptech/glide/DrawableTypeRequest.java b/library/src/main/java/com/bumptech/glide/DrawableTypeRequest.java
index 35f7310f..d655d450 100644
--- a/library/src/main/java/com/bumptech/glide/DrawableTypeRequest.java
+++ b/library/src/main/java/com/bumptech/glide/DrawableTypeRequest.java
@@ -23,17 +23,17 @@ import java.io.InputStream;
* adds an {@link com.bumptech.glide.load.resource.transcode.ResourceTranscoder} to transcode the data into a
* resource type other than a {@link android.graphics.drawable.Drawable}.
*
- * @param The type of model to use to load the {@link android.graphics.drawable.BitmapDrawable} or
+ * @param The type of model to use to load the {@link android.graphics.drawable.BitmapDrawable} or
* {@link com.bumptech.glide.load.resource.gif.GifDrawable}.
*/
-public class DrawableTypeRequest extends DrawableRequestBuilder implements DownloadOptions {
- private final ModelLoader streamModelLoader;
- private final ModelLoader fileDescriptorModelLoader;
+public class DrawableTypeRequest extends DrawableRequestBuilder implements DownloadOptions {
+ private final ModelLoader streamModelLoader;
+ private final ModelLoader fileDescriptorModelLoader;
private final Context context;
private final Glide glide;
private RequestTracker requestTracker;
private RequestManager.OptionsApplier optionsApplier;
- private final A model;
+ private final ModelType model;
private static FixedLoadProvider buildProvider(Glide glide,
ModelLoader streamModelLoader,
@@ -54,8 +54,8 @@ public class DrawableTypeRequest extends DrawableRequestBuilder implements
return new FixedLoadProvider(modelLoader, transcoder, dataLoadProvider);
}
- DrawableTypeRequest(A model, ModelLoader streamModelLoader,
- ModelLoader fileDescriptorModelLoader, Context context, Glide glide,
+ DrawableTypeRequest(ModelType model, ModelLoader streamModelLoader,
+ ModelLoader fileDescriptorModelLoader, Context context, Glide glide,
RequestTracker requestTracker, RequestManager.OptionsApplier optionsApplier) {
super(context, model,
buildProvider(glide, streamModelLoader, fileDescriptorModelLoader, GifBitmapWrapper.class,
@@ -75,8 +75,8 @@ public class DrawableTypeRequest extends DrawableRequestBuilder implements
*
* @return A new request builder for loading a {@link android.graphics.Bitmap}
*/
- public BitmapTypeRequest asBitmap() {
- return optionsApplier.apply(model, new BitmapTypeRequest(context, model, streamModelLoader,
+ public BitmapTypeRequest asBitmap() {
+ return optionsApplier.apply(model, new BitmapTypeRequest(context, model, streamModelLoader,
fileDescriptorModelLoader, glide, requestTracker, optionsApplier));
}
@@ -92,8 +92,8 @@ public class DrawableTypeRequest extends DrawableRequestBuilder implements
*
* @return A new request builder for loading a {@link com.bumptech.glide.load.resource.gif.GifDrawable}.
*/
- public GifTypeRequest asGif() {
- return optionsApplier.apply(model, new GifTypeRequest(context, model, streamModelLoader, glide,
+ public GifTypeRequest asGif() {
+ return optionsApplier.apply(model, new GifTypeRequest(context, model, streamModelLoader, glide,
requestTracker, optionsApplier));
}
@@ -120,8 +120,8 @@ public class DrawableTypeRequest extends DrawableRequestBuilder implements
return getDownloadOnlyRequest().downloadOnly(width, height);
}
- private GenericTranscodeRequest getDownloadOnlyRequest() {
- return optionsApplier.apply(model, new GenericTranscodeRequest(context, glide, model,
- streamModelLoader, InputStream.class, File.class, requestTracker, optionsApplier));
+ private GenericTranscodeRequest getDownloadOnlyRequest() {
+ return optionsApplier.apply(model, new GenericTranscodeRequest(context, glide,
+ model, streamModelLoader, InputStream.class, File.class, requestTracker, optionsApplier));
}
}
diff --git a/library/src/main/java/com/bumptech/glide/GenericTranscodeRequest.java b/library/src/main/java/com/bumptech/glide/GenericTranscodeRequest.java
index 4fa45389..c6da01a8 100644
--- a/library/src/main/java/com/bumptech/glide/GenericTranscodeRequest.java
+++ b/library/src/main/java/com/bumptech/glide/GenericTranscodeRequest.java
@@ -19,17 +19,18 @@ import java.io.File;
* A class for handling requests to load a generic resource type or transcode the generic resource type into another
* generic resource type.
*
- * @param The type of the model used to retrieve data.
- * @param The type of data retrieved.
- * @param The type of resource to be decoded from the the data.
+ * @param The type of the model used to retrieve data.
+ * @param The type of data retrieved.
+ * @param The type of resource to be decoded from the the data.
*/
-public class GenericTranscodeRequest extends GenericRequestBuilder implements DownloadOptions {
+public class GenericTranscodeRequest
+ extends GenericRequestBuilder implements DownloadOptions {
private final Context context;
- private final A model;
+ private final ModelType model;
private final Glide glide;
- private final ModelLoader modelLoader;
- private final Class dataClass;
- private final Class resourceClass;
+ private final ModelLoader modelLoader;
+ private final Class dataClass;
+ private final Class resourceClass;
private final RequestTracker requestTracker;
private final RequestManager.OptionsApplier optionsApplier;
@@ -42,12 +43,11 @@ public class GenericTranscodeRequest extends GenericRequestBuilder(modelLoader, transcoder, dataLoadProvider);
}
- GenericTranscodeRequest(Context context, Glide glide, A model, ModelLoader modelLoader,
- Class dataClass, Class resourceClass, RequestTracker requestTracker,
+ GenericTranscodeRequest(Context context, Glide glide, ModelType model, ModelLoader modelLoader,
+ Class dataClass, Class resourceClass, RequestTracker requestTracker,
RequestManager.OptionsApplier optionsApplier) {
- super(context, model,
- build(glide, modelLoader, dataClass, resourceClass, (ResourceTranscoder) null),
- resourceClass, glide, requestTracker);
+ super(context, model, build(glide, modelLoader, dataClass, resourceClass,
+ (ResourceTranscoder) null), resourceClass, glide, requestTracker);
this.context = context;
this.model = model;
this.glide = glide;
@@ -63,14 +63,18 @@ public class GenericTranscodeRequest extends GenericRequestBuilder The type of the resource that will be transcoded to.
+ * @param The type of the resource that will be transcoded to.
* @return A new request builder to set options for the transcoded load.
*/
- public GenericRequestBuilder transcode(ResourceTranscoder transcoder,
- Class transcodeClass) {
- return optionsApplier.apply(model, new GenericRequestBuilder(context, model,
- build(glide, modelLoader, dataClass, resourceClass, transcoder), transcodeClass, glide,
- requestTracker));
+ public GenericRequestBuilder transcode(
+ ResourceTranscoder transcoder,
+ Class transcodeClass) {
+ LoadProvider loadProvider = build(glide, modelLoader,
+ dataClass, resourceClass, transcoder);
+
+ return optionsApplier.apply(model,
+ new GenericRequestBuilder(context, model,
+ loadProvider, transcodeClass, glide, requestTracker));
}
/**
@@ -96,12 +100,12 @@ public class GenericTranscodeRequest extends GenericRequestBuilder getDownloadOnlyRequest() {
+ private GenericRequestBuilder getDownloadOnlyRequest() {
ResourceTranscoder transcoder = UnitTranscoder.get();
- DataLoadProvider dataLoadProvider = glide.buildDataProvider(dataClass, File.class);
- FixedLoadProvider fixedLoadProvider = new FixedLoadProvider(modelLoader,
- transcoder, dataLoadProvider);
- return optionsApplier.apply(model, new GenericRequestBuilder(context, model,
+ DataLoadProvider dataLoadProvider = glide.buildDataProvider(dataClass, File.class);
+ FixedLoadProvider fixedLoadProvider =
+ new FixedLoadProvider(modelLoader, transcoder, dataLoadProvider);
+ return optionsApplier.apply(model, new GenericRequestBuilder(context, model,
fixedLoadProvider,
File.class, glide,
requestTracker)
diff --git a/library/src/main/java/com/bumptech/glide/GifTypeRequest.java b/library/src/main/java/com/bumptech/glide/GifTypeRequest.java
index 396da00b..e0ea8de6 100644
--- a/library/src/main/java/com/bumptech/glide/GifTypeRequest.java
+++ b/library/src/main/java/com/bumptech/glide/GifTypeRequest.java
@@ -1,6 +1,7 @@
package com.bumptech.glide;
import android.content.Context;
+import android.view.animation.Animation;
import com.bumptech.glide.load.model.ModelLoader;
import com.bumptech.glide.load.resource.gif.GifData;
@@ -10,6 +11,7 @@ import com.bumptech.glide.load.resource.transcode.ResourceTranscoder;
import com.bumptech.glide.manager.RequestTracker;
import com.bumptech.glide.provider.DataLoadProvider;
import com.bumptech.glide.provider.FixedLoadProvider;
+import com.bumptech.glide.request.animation.DrawableCrossFadeViewAnimation;
import java.io.InputStream;
@@ -18,13 +20,13 @@ import java.io.InputStream;
* directly or that adds an {@link com.bumptech.glide.load.resource.transcode.ResourceTranscoder} to transcode
* {@link com.bumptech.glide.load.resource.gif.GifData} into another resource type.
*
- * @param The type of model to load the {@link com.bumptech.glide.load.resource.gif.GifDrawable} or other
+ * @param The type of model to load the {@link com.bumptech.glide.load.resource.gif.GifDrawable} or other
* transcoded class from.
*/
-public class GifTypeRequest extends GifRequestBuilder {
+public class GifTypeRequest extends GifRequestBuilder implements DrawableOptions {
private final Context context;
- private final A model;
- private final ModelLoader streamModelLoader;
+ private final ModelType model;
+ private final ModelLoader streamModelLoader;
private final Glide glide;
private final RequestTracker requestTracker;
private RequestManager.OptionsApplier optionsApplier;
@@ -45,7 +47,7 @@ public class GifTypeRequest extends GifRequestBuilder {
}
- GifTypeRequest(Context context, A model, ModelLoader streamModelLoader, Glide glide,
+ GifTypeRequest(Context context, ModelType model, ModelLoader streamModelLoader, Glide glide,
RequestTracker requestTracker, RequestManager.OptionsApplier optionsApplier) {
super(context, model, buildProvider(glide, streamModelLoader, GifDrawable.class, null), GifDrawable.class,
glide, requestTracker);
@@ -69,8 +71,9 @@ public class GifTypeRequest extends GifRequestBuilder {
* trasncoded to.
* @return This request builder.
*/
- public GifRequestBuilder transcode(ResourceTranscoder transcoder, Class transcodeClass) {
- return optionsApplier.apply(model, new GifRequestBuilder(context, model,
+ public GifRequestBuilder transcode(ResourceTranscoder transcoder,
+ Class transcodeClass) {
+ return optionsApplier.apply(model, new GifRequestBuilder(context, model,
buildProvider(glide, streamModelLoader, transcodeClass, transcoder), transcodeClass, glide,
requestTracker));
}
@@ -84,7 +87,44 @@ public class GifTypeRequest extends GifRequestBuilder {
*
* @return A new Builder object to build a request to transform the given model into the bytes of an animated gif.
*/
- public GifRequestBuilder toBytes() {
+ public GifRequestBuilder toBytes() {
return transcode(new GifDataBytesTranscoder(), byte[].class);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GifTypeRequest crossFade() {
+ super.animate(new DrawableCrossFadeViewAnimation.DrawableCrossFadeFactory());
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GifTypeRequest crossFade(int duration) {
+ super.animate(new DrawableCrossFadeViewAnimation.DrawableCrossFadeFactory(duration));
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GifTypeRequest crossFade(Animation animation, int duration) {
+ super.animate(new DrawableCrossFadeViewAnimation.DrawableCrossFadeFactory(animation, duration));
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GifTypeRequest crossFade(int animationId, int duration) {
+ super.animate(new DrawableCrossFadeViewAnimation.DrawableCrossFadeFactory(context, animationId,
+ duration));
+ return this;
+ }
}
diff --git a/library/src/main/java/com/bumptech/glide/request/animation/DrawableCrossFadeViewAnimation.java b/library/src/main/java/com/bumptech/glide/request/animation/DrawableCrossFadeViewAnimation.java
index 27526f63..761b85d1 100644
--- a/library/src/main/java/com/bumptech/glide/request/animation/DrawableCrossFadeViewAnimation.java
+++ b/library/src/main/java/com/bumptech/glide/request/animation/DrawableCrossFadeViewAnimation.java
@@ -3,12 +3,10 @@ package com.bumptech.glide.request.animation;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
-import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
-
-import com.bumptech.glide.request.target.Target;
+import android.widget.ImageView;
/**
* A cross fade {@link GlideAnimation} for {@link android.graphics.drawable.Drawable}s
@@ -16,7 +14,7 @@ import com.bumptech.glide.request.target.Target;
* already visible on the target to a new drawable. If no existing drawable exists, this class can instead fall back
* to a default animation that doesn't rely on {@link android.graphics.drawable.TransitionDrawable}.
*/
-public class DrawableCrossFadeViewAnimation implements GlideAnimation {
+public class DrawableCrossFadeViewAnimation implements GlideAnimation {
// 150 ms.
public static final int DEFAULT_DURATION = 300;
private Animation defaultAnimation;
@@ -40,12 +38,12 @@ public class DrawableCrossFadeViewAnimation implements GlideAnimation
* cache this factory producdes an {@link NoAnimation}.
*