@@ -45,6 +45,7 @@ public final class GlideBuilder {
45
45
private RequestOptions defaultRequestOptions = new RequestOptions ();
46
46
@ Nullable
47
47
private RequestManagerFactory requestManagerFactory ;
48
+ private GlideExecutor animationExecutor ;
48
49
49
50
/**
50
51
* Sets the {@link com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool} implementation to use
@@ -116,39 +117,84 @@ public GlideBuilder setDiskCache(DiskCache.Factory diskCacheFactory) {
116
117
}
117
118
118
119
/**
119
- * Sets the {@link java.util.concurrent.ExecutorService} implementation to use when retrieving
120
+ * Sets the {@link GlideExecutor} to use when retrieving
120
121
* {@link com.bumptech.glide.load.engine.Resource}s that are not already in the cache.
121
122
*
122
- * <p> Any implementation must order requests based on their {@link com.bumptech.glide.Priority}
123
- * for thumbnail requests to work properly.
123
+ * <p>The thread count defaults to the number of cores available on the device, with a maximum of
124
+ * 4.
125
+ *
126
+ * <p>Use the {@link GlideExecutor#newSourceExecutor()} methods if you'd like to specify options
127
+ * for the source executor.
124
128
*
125
129
* @param service The ExecutorService to use.
126
130
* @return This builder.
127
131
* @see #setDiskCacheExecutor(GlideExecutor)
128
132
* @see GlideExecutor
133
+ *
134
+ * @deprecated Use {@link #setSourceExecutor(GlideExecutor)}
129
135
*/
136
+ @ Deprecated
130
137
public GlideBuilder setResizeExecutor (GlideExecutor service ) {
138
+ return setSourceExecutor (service );
139
+ }
140
+
141
+ /**
142
+ * Sets the {@link GlideExecutor} to use when retrieving
143
+ * {@link com.bumptech.glide.load.engine.Resource}s that are not already in the cache.
144
+ *
145
+ * <p>The thread count defaults to the number of cores available on the device, with a maximum of
146
+ * 4.
147
+ *
148
+ * <p>Use the {@link GlideExecutor#newSourceExecutor()} methods if you'd like to specify options
149
+ * for the source executor.
150
+ *
151
+ * @param service The ExecutorService to use.
152
+ * @return This builder.
153
+ * @see #setDiskCacheExecutor(GlideExecutor)
154
+ * @see GlideExecutor
155
+ */
156
+ public GlideBuilder setSourceExecutor (GlideExecutor service ) {
131
157
this .sourceExecutor = service ;
132
158
return this ;
133
159
}
134
160
135
161
/**
136
- * Sets the {@link java.util.concurrent.ExecutorService} implementation to use when retrieving
137
- * {@link com.bumptech.glide.load.engine.Resource}s that are currently in cache .
162
+ * Sets the {@link GlideExecutor} to use when retrieving
163
+ * {@link com.bumptech.glide.load.engine.Resource}s that are currently in Glide's disk caches .
138
164
*
139
- * <p> Any implementation must order requests based on their {@link com.bumptech.glide.Priority}
140
- * for thumbnail requests to work properly .
165
+ * <p>Defaults to a single thread which is usually the best combination of memory usage,
166
+ * jank, and performance, even on high end devices .
141
167
*
142
- * @param service The ExecutorService to use.
168
+ * <p>Use the {@link GlideExecutor#newDiskCacheExecutor()} if you'd like to specify options
169
+ * for the disk cache executor.
170
+ *
171
+ * @param service The {@link GlideExecutor} to use.
143
172
* @return This builder.
144
- * @see #setResizeExecutor (GlideExecutor)
173
+ * @see #setSourceExecutor (GlideExecutor)
145
174
* @see GlideExecutor
146
175
*/
147
176
public GlideBuilder setDiskCacheExecutor (GlideExecutor service ) {
148
177
this .diskCacheExecutor = service ;
149
178
return this ;
150
179
}
151
180
181
+ /**
182
+ * Sets the {@link GlideExecutor} to use when loading frames of animated images and particularly
183
+ * of {@link com.bumptech.glide.load.resource.gif.GifDrawable}s.
184
+ *
185
+ * <p>Defaults to one or two threads, depending on the number of cores available.
186
+ *
187
+ * <p>Use the {@link GlideExecutor#newAnimationExecutor()} methods if you'd like to specify
188
+ * options for the animation executor.
189
+ *
190
+ * @param service The {@link GlideExecutor} to use.
191
+ * @return This builder.
192
+ */
193
+ public GlideBuilder setAnimationExecutor (GlideExecutor service ) {
194
+ this .animationExecutor = service ;
195
+ return this ;
196
+ }
197
+
152
198
/**
153
199
* Sets the default {@link RequestOptions} to use for all loads across the app.
154
200
*
@@ -299,6 +345,10 @@ public Glide build(Context context) {
299
345
diskCacheExecutor = GlideExecutor .newDiskCacheExecutor ();
300
346
}
301
347
348
+ if (animationExecutor == null ) {
349
+ animationExecutor = GlideExecutor .newAnimationExecutor ();
350
+ }
351
+
302
352
if (memorySizeCalculator == null ) {
303
353
memorySizeCalculator = new MemorySizeCalculator .Builder (context ).build ();
304
354
}
0 commit comments