DrawableRequestBuilder.java revision be9ba784e13d6f8bf390ec0f11fc2600a38b0548
1package com.bumptech.glide;
2
3import android.content.Context;
4import android.graphics.Bitmap;
5import android.graphics.drawable.Drawable;
6import android.view.animation.Animation;
7import com.bumptech.glide.load.ResourceDecoder;
8import com.bumptech.glide.load.ResourceEncoder;
9import com.bumptech.glide.load.Transformation;
10import com.bumptech.glide.load.model.ImageVideoWrapper;
11import com.bumptech.glide.load.resource.bitmap.CenterCrop;
12import com.bumptech.glide.load.resource.bitmap.FitCenter;
13import com.bumptech.glide.load.resource.gifbitmap.GifBitmap;
14import com.bumptech.glide.load.resource.gifbitmap.GifBitmapTransformation;
15import com.bumptech.glide.load.resource.transcode.ResourceTranscoder;
16import com.bumptech.glide.provider.LoadProvider;
17import com.bumptech.glide.request.bitmap.RequestListener;
18
19import java.io.InputStream;
20
21public class DrawableRequestBuilder<ModelType> extends
22        GenericRequestBuilder<ModelType, ImageVideoWrapper, GifBitmap, Drawable> {
23    private final Context context;
24    private final Glide glide;
25
26    public DrawableRequestBuilder(Context context, ModelType model,
27            LoadProvider<ModelType, ImageVideoWrapper, GifBitmap, Drawable> loadProvider, Glide glide) {
28        super(context, model, loadProvider, Drawable.class, glide);
29        this.context = context;
30        this.glide = glide;
31    }
32
33    public DrawableRequestBuilder<ModelType> thumbnail(
34            DrawableRequestBuilder<ModelType> thumbnailRequest) {
35        super.thumbnail(thumbnailRequest);
36        return this;
37    }
38
39    @Override
40    public DrawableRequestBuilder<ModelType> thumbnail(
41            GenericRequestBuilder<ModelType, ImageVideoWrapper, GifBitmap, Drawable> thumbnailRequest) {
42        super.thumbnail(thumbnailRequest);
43        return this;
44    }
45
46    @Override
47    public DrawableRequestBuilder<ModelType> thumbnail(float sizeMultiplier) {
48        super.thumbnail(sizeMultiplier);
49        return this;
50    }
51
52    @Override
53    public DrawableRequestBuilder<ModelType> sizeMultiplier(
54            float sizeMultiplier) {
55        super.sizeMultiplier(sizeMultiplier);
56        return this;
57    }
58
59    @Override
60    public DrawableRequestBuilder<ModelType> decoder(
61            ResourceDecoder<ImageVideoWrapper, GifBitmap> decoder) {
62        super.decoder(decoder);
63        return this;
64    }
65
66    @Override
67    public DrawableRequestBuilder<ModelType> cacheDecoder(
68            ResourceDecoder<InputStream, GifBitmap> cacheDecoder) {
69        super.cacheDecoder(cacheDecoder);
70        return this;
71    }
72
73    @Override
74    public DrawableRequestBuilder<ModelType> encoder(
75            ResourceEncoder<GifBitmap> encoder) {
76        super.encoder(encoder);
77        return this;
78    }
79
80    @Override
81    public DrawableRequestBuilder<ModelType> priority(Priority priority) {
82        super.priority(priority);
83        return this;
84    }
85
86    public DrawableRequestBuilder<ModelType> centerCrop() {
87        return bitmapTransform(new CenterCrop(glide.getBitmapPool()));
88    }
89
90    public DrawableRequestBuilder<ModelType> fitCenter() {
91        return bitmapTransform(new FitCenter(glide.getBitmapPool()));
92    }
93
94    public DrawableRequestBuilder<ModelType> bitmapTransform(Transformation<Bitmap> bitmapTransformation) {
95        return transform(new GifBitmapTransformation(context, bitmapTransformation));
96    }
97
98    @Override
99    public DrawableRequestBuilder<ModelType> transform(
100            Transformation<GifBitmap> transformation) {
101        super.transform(transformation);
102        return this;
103    }
104
105    @Override
106    public DrawableRequestBuilder<ModelType> transcoder(
107            ResourceTranscoder<GifBitmap, Drawable> transcoder) {
108        super.transcoder(transcoder);
109        return this;
110    }
111
112    @Override
113    public DrawableRequestBuilder<ModelType> animate(int animationId) {
114        super.animate(animationId);
115        return this;
116    }
117
118    @Override
119    public DrawableRequestBuilder<ModelType> animate(Animation animation) {
120        super.animate(animation);
121        return this;
122    }
123
124    @Override
125    public DrawableRequestBuilder<ModelType> placeholder(int resourceId) {
126        super.placeholder(resourceId);
127        return this;
128    }
129
130    @Override
131    public DrawableRequestBuilder<ModelType> placeholder(Drawable drawable) {
132        super.placeholder(drawable);
133        return this;
134    }
135
136    @Override
137    public DrawableRequestBuilder<ModelType> error(int resourceId) {
138        super.error(resourceId);
139        return this;
140    }
141
142    @Override
143    public DrawableRequestBuilder<ModelType> error(Drawable drawable) {
144        super.error(drawable);
145        return this;
146    }
147
148    @Override
149    public DrawableRequestBuilder<ModelType> listener(
150            RequestListener<ModelType> requestListener) {
151        super.listener(requestListener);
152        return this;
153    }
154
155    @Override
156    public DrawableRequestBuilder<ModelType> skipMemoryCache(boolean skip) {
157        super.skipMemoryCache(skip);
158        return this;
159    }
160
161    @Override
162    public DrawableRequestBuilder<ModelType> skipDiskCache(boolean skip) {
163        super.skipDiskCache(skip);
164        return this;
165    }
166
167    @Override
168    public DrawableRequestBuilder<ModelType> skipCache(boolean skip) {
169        super.skipCache(skip);
170        return this;
171    }
172}
173