14
14
import com .bumptech .glide .load .Options ;
15
15
import com .bumptech .glide .load .Transformation ;
16
16
import com .bumptech .glide .load .engine .DiskCacheStrategy ;
17
+ import com .bumptech .glide .load .model .stream .HttpGlideUrlLoader ;
17
18
import com .bumptech .glide .load .resource .bitmap .BitmapDrawableTransformation ;
18
19
import com .bumptech .glide .load .resource .bitmap .BitmapEncoder ;
19
20
import com .bumptech .glide .load .resource .bitmap .CenterCrop ;
@@ -314,6 +315,13 @@ public static RequestOptions downsampleOf(@NonNull DownsampleStrategy strategy)
314
315
return new RequestOptions ().downsample (strategy );
315
316
}
316
317
318
+ /**
319
+ * Returns a {@link RequestOptions} object with {@link #timeout(int)} set.
320
+ */
321
+ public static RequestOptions timeoutOf (int timeout ) {
322
+ return new RequestOptions ().timeout (timeout );
323
+ }
324
+
317
325
/**
318
326
* Returns a {@link com.bumptech.glide.request.RequestOptions} with {@link
319
327
* #encodeQuality(int)} called with the given quality.
@@ -726,6 +734,20 @@ public RequestOptions encodeQuality(int quality) {
726
734
return set (BitmapEncoder .COMPRESSION_QUALITY , quality );
727
735
}
728
736
737
+ /**
738
+ * Sets the time position of the frame to extract from a video.
739
+ *
740
+ * <p>This is a component option specific to {@link VideoBitmapDecoder}. If the default video
741
+ * decoder is replaced or skipped because of your configuration, this option may be ignored.
742
+ *
743
+ * @see VideoBitmapDecoder#TARGET_FRAME
744
+ * @param frameTimeMicros The time position in microseconds of the desired frame. If negative, the
745
+ * Android framework implementation return a representative frame.
746
+ */
747
+ public RequestOptions frame (long frameTimeMicros ) {
748
+ return set (VideoBitmapDecoder .TARGET_FRAME , frameTimeMicros );
749
+ }
750
+
729
751
/**
730
752
* Sets the {@link DecodeFormat} to use when decoding {@link Bitmap} objects using
731
753
* {@link Downsampler}.
@@ -735,27 +757,40 @@ public RequestOptions encodeQuality(int quality) {
735
757
* ({@link android.media.MediaMetadataRetriever} for example), or that the decoder may choose to
736
758
* ignore the requested format if it can't display the image (i.e. RGB_565 is requested, but the
737
759
* image has alpha).
760
+ *
761
+ * <p>This is a component option specific to {@link Downsampler}. If the defautlt Bitmap decoder
762
+ * is replaced or skipped because of your configuration, this option may be ignored.
763
+ *
764
+ * @see Downsampler#DECODE_FORMAT
738
765
*/
739
766
public RequestOptions format (@ NonNull DecodeFormat format ) {
740
767
return set (Downsampler .DECODE_FORMAT , Preconditions .checkNotNull (format ));
741
768
}
742
769
743
770
/**
744
- * Sets the time position of the frame to extract from a video.
771
+ * Sets the {@link DownsampleStrategy} to use when decoding {@link Bitmap Bitmaps} using
772
+ * {@link Downsampler}.
745
773
*
746
- * @param frameTimeMicros The time position in microseconds of the desired frame . If negative, the
747
- * Android framework implementation return a representative frame .
774
+ * <p>This is a component option specific to {@link Downsampler} . If the defautlt Bitmap decoder
775
+ * is replaced or skipped because of your configuration, this option may be ignored .
748
776
*/
749
- public RequestOptions frame ( long frameTimeMicros ) {
750
- return set (VideoBitmapDecoder . TARGET_FRAME , frameTimeMicros );
777
+ public RequestOptions downsample ( @ NonNull DownsampleStrategy strategy ) {
778
+ return set (Downsampler . DOWNSAMPLE_STRATEGY , Preconditions . checkNotNull ( strategy ) );
751
779
}
752
780
753
781
/**
754
- * Sets the {@link DownsampleStrategy} to use when decoding {@link Bitmap Bitmaps} using
755
- * {@link Downsampler}.
782
+ * Sets the read and write timeout for the http requests used to load the image.
783
+ *
784
+ * <p>This is a component option specific to Glide's default networking library and
785
+ * {@link com.bumptech.glide.load.model.stream.HttpGlideUrlLoader}. If you use any other
786
+ * networking library including Glide's Volley or OkHttp integration libraries, this option will
787
+ * be ignored.
788
+ *
789
+ * @see com.bumptech.glide.load.model.stream.HttpGlideUrlLoader#TIMEOUT
790
+ * @param timeoutMs The read and write timeout in milliseconds.
756
791
*/
757
- public RequestOptions downsample ( @ NonNull DownsampleStrategy strategy ) {
758
- return set (Downsampler . DOWNSAMPLE_STRATEGY , Preconditions . checkNotNull ( strategy ) );
792
+ public RequestOptions timeout ( int timeoutMs ) {
793
+ return set (HttpGlideUrlLoader . TIMEOUT , timeoutMs );
759
794
}
760
795
761
796
/**
0 commit comments