Skip to content

Commit b2fb229

Browse files
committed
Fix and suppress a variety of deprecation warnings.
1 parent 56368d0 commit b2fb229

File tree

14 files changed

+27
-13
lines changed

14 files changed

+27
-13
lines changed

integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpGlideModule.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.bumptech.glide.GlideBuilder;
66
import com.bumptech.glide.Registry;
77
import com.bumptech.glide.load.model.GlideUrl;
8-
import com.bumptech.glide.module.GlideModule;
98
import java.io.InputStream;
109

1110
/**
@@ -20,7 +19,7 @@
2019
* @deprecated replaced with com.bumptech.glide.integration.okhttp3.OkHttpGlideModule.
2120
*/
2221
@Deprecated
23-
public class OkHttpGlideModule implements GlideModule {
22+
public class OkHttpGlideModule implements com.bumptech.glide.module.GlideModule {
2423
@Override
2524
public void applyOptions(Context context, GlideBuilder builder) {
2625
// Do nothing.

integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpLibraryGlideModule.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
* <p>For Applications that depend on this library and include an
1616
* {@link AppGlideModule} and Glide's annotation processor, this class
1717
* will be automatically included.
18+
*
19+
* @deprecated Prefer the okhttp3 version instead.
1820
*/
1921
@GlideModule
22+
@Deprecated
2023
public class OkHttpLibraryGlideModule extends LibraryGlideModule {
2124
@Override
2225
public void registerComponents(Context context, Glide glide, Registry registry) {

integration/okhttp3/src/main/java/com/bumptech/glide/integration/okhttp3/OkHttpGlideModule.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.bumptech.glide.GlideBuilder;
66
import com.bumptech.glide.Registry;
77
import com.bumptech.glide.load.model.GlideUrl;
8-
import com.bumptech.glide.module.GlideModule;
98
import java.io.InputStream;
109

1110
/**
@@ -21,7 +20,7 @@
2120
* annotations.
2221
*/
2322
@Deprecated
24-
public class OkHttpGlideModule implements GlideModule {
23+
public class OkHttpGlideModule implements com.bumptech.glide.module.GlideModule {
2524
@Override
2625
public void applyOptions(Context context, GlideBuilder builder) {
2726
// Do nothing.

integration/volley/src/main/java/com/bumptech/glide/integration/volley/VolleyGlideModule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.bumptech.glide.GlideBuilder;
66
import com.bumptech.glide.Registry;
77
import com.bumptech.glide.load.model.GlideUrl;
8-
import com.bumptech.glide.module.GlideModule;
98
import java.io.InputStream;
109

1110
/**
@@ -20,7 +19,8 @@
2019
* @deprecated Replaced with {@link VolleyLibraryGlideModule}.
2120
*/
2221
@Deprecated
23-
public class VolleyGlideModule implements GlideModule {
22+
@SuppressWarnings("deprecation")
23+
public class VolleyGlideModule implements com.bumptech.glide.module.GlideModule {
2424
@Override
2525
public void applyOptions(Context context, GlideBuilder builder) {
2626
// Do nothing.

library/src/main/java/com/bumptech/glide/Glide.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,15 +298,16 @@ private static GeneratedAppGlideModule getAnnotationGeneratedGlideModules() {
298298
ByteBufferGifDecoder byteBufferGifDecoder =
299299
new ByteBufferGifDecoder(context, registry.getImageHeaderParsers(), bitmapPool, arrayPool);
300300

301-
registry.register(ByteBuffer.class, new ByteBufferEncoder())
302-
.register(InputStream.class, new StreamEncoder(arrayPool))
301+
registry
302+
.append(ByteBuffer.class, new ByteBufferEncoder())
303+
.append(InputStream.class, new StreamEncoder(arrayPool))
303304
/* Bitmaps */
304305
.append(ByteBuffer.class, Bitmap.class,
305306
new ByteBufferBitmapDecoder(downsampler))
306307
.append(InputStream.class, Bitmap.class,
307308
new StreamBitmapDecoder(downsampler, arrayPool))
308309
.append(ParcelFileDescriptor.class, Bitmap.class, new VideoBitmapDecoder(bitmapPool))
309-
.register(Bitmap.class, new BitmapEncoder())
310+
.append(Bitmap.class, new BitmapEncoder())
310311
/* GlideBitmapDrawables */
311312
.append(ByteBuffer.class, BitmapDrawable.class,
312313
new BitmapDrawableDecoder<>(resources, bitmapPool,
@@ -316,12 +317,12 @@ private static GeneratedAppGlideModule getAnnotationGeneratedGlideModules() {
316317
new StreamBitmapDecoder(downsampler, arrayPool)))
317318
.append(ParcelFileDescriptor.class, BitmapDrawable.class,
318319
new BitmapDrawableDecoder<>(resources, bitmapPool, new VideoBitmapDecoder(bitmapPool)))
319-
.register(BitmapDrawable.class, new BitmapDrawableEncoder(bitmapPool, new BitmapEncoder()))
320+
.append(BitmapDrawable.class, new BitmapDrawableEncoder(bitmapPool, new BitmapEncoder()))
320321
/* GIFs */
321322
.prepend(InputStream.class, GifDrawable.class,
322323
new StreamGifDecoder(registry.getImageHeaderParsers(), byteBufferGifDecoder, arrayPool))
323324
.prepend(ByteBuffer.class, GifDrawable.class, byteBufferGifDecoder)
324-
.register(GifDrawable.class, new GifDrawableEncoder())
325+
.append(GifDrawable.class, new GifDrawableEncoder())
325326
/* GIF Frames */
326327
.append(GifDecoder.class, GifDecoder.class, new UnitModelLoader.Factory<GifDecoder>())
327328
.append(GifDecoder.class, Bitmap.class, new GifFrameResourceDecoder(bitmapPool))

library/src/main/java/com/bumptech/glide/load/engine/prefill/BitmapPreFiller.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public BitmapPreFiller(MemoryCache memoryCache, BitmapPool bitmapPool,
3030
this.defaultFormat = defaultFormat;
3131
}
3232

33+
@SuppressWarnings("deprecation")
3334
public void preFill(PreFillType.Builder... bitmapAttributeBuilders) {
3435
if (current != null) {
3536
current.cancel();

library/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public Resource<Bitmap> decode(InputStream is, int outWidth, int outHeight,
186186
* @return A new bitmap containing the image from the given InputStream, or recycle if recycle is
187187
* not null.
188188
*/
189-
@SuppressWarnings("resource")
189+
@SuppressWarnings({"resource", "deprecation"})
190190
public Resource<Bitmap> decode(InputStream is, int requestedWidth, int requestedHeight,
191191
Options options, DecodeCallbacks callbacks) throws IOException {
192192
Preconditions.checkArgument(is.markSupported(), "You must provide an InputStream that supports"
@@ -476,6 +476,7 @@ private boolean shouldUsePool(ImageType imageType) throws IOException {
476476
return TYPES_THAT_USE_POOL_PRE_KITKAT.contains(imageType);
477477
}
478478

479+
@SuppressWarnings("deprecation")
479480
private void calculateConfig(
480481
InputStream is,
481482
DecodeFormat format,
@@ -672,6 +673,7 @@ private static void releaseOptions(BitmapFactory.Options decodeBitmapOptions) {
672673
}
673674
}
674675

676+
@SuppressWarnings("deprecation")
675677
private static void resetOptions(BitmapFactory.Options decodeBitmapOptions) {
676678
decodeBitmapOptions.inTempStorage = null;
677679
decodeBitmapOptions.inDither = false;

library/src/main/java/com/bumptech/glide/load/resource/bitmap/HardwareConfigState.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ private HardwareConfigState() {
7272
}
7373

7474
@TargetApi(Build.VERSION_CODES.O)
75+
@SuppressWarnings("deprecation")
7576
boolean setHardwareConfigIfAllowed(
7677
int targetWidth,
7778
int targetHeight,

library/src/main/java/com/bumptech/glide/manager/RequestManagerFragment.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ private void unregisterFragmentWithRoot() {
159159
}
160160
}
161161

162+
@SuppressWarnings("deprecation")
162163
@Override
163164
public void onAttach(Activity activity) {
164165
super.onAttach(activity);

library/src/main/java/com/bumptech/glide/request/target/FixedSizeDrawable.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public int getChangingConfigurations() {
7171
return wrapped.getChangingConfigurations();
7272
}
7373

74+
@Deprecated
7475
@Override
7576
public void setDither(boolean dither) {
7677
wrapped.setDither(dither);

library/src/test/java/com/bumptech/glide/load/engine/prefill/BitmapPreFillerTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ public void testAllocationOrderRoundRobinsDifferentSizes() {
258258
}
259259

260260
@Test
261+
@SuppressWarnings("deprecation")
261262
public void testSetsConfigOnBuildersToDefaultIfNotSet() {
262263
PreFillType.Builder builder = mock(PreFillType.Builder.class);
263264
when(builder.build())

library/src/test/java/com/bumptech/glide/load/resource/gif/GifDrawableTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616

1717
import android.graphics.Bitmap;
1818
import android.graphics.Canvas;
19+
import android.graphics.Color;
1920
import android.graphics.ColorFilter;
2021
import android.graphics.Paint;
2122
import android.graphics.PixelFormat;
23+
import android.graphics.PorterDuff.Mode;
24+
import android.graphics.PorterDuffColorFilter;
2225
import android.graphics.Rect;
2326
import android.graphics.drawable.Drawable;
2427
import android.os.Build;
@@ -544,7 +547,7 @@ public void testSetAlphaSetsAlphaOnPaint() {
544547

545548
@Test
546549
public void testSetColorFilterSetsColorFilterOnPaint() {
547-
ColorFilter colorFilter = new ColorFilter();
550+
ColorFilter colorFilter = new PorterDuffColorFilter(Color.RED, Mode.ADD);
548551
drawable.setColorFilter(colorFilter);
549552
verify(paint).setColorFilter(eq(colorFilter));
550553
}

library/src/test/java/com/bumptech/glide/request/RequestOptionsTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ public void testApplyingDefaultOptions_withTransform_retrainsTransform() {
253253
}
254254

255255
@Test
256+
@SuppressWarnings({"unchecked", "varargs"})
256257
public void testApplyMultiTransform() {
257258
options.transforms(new CircleCrop(), new CenterCrop());
258259
assertThat(options.isTransformationRequired()).isTrue();

third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/StandardGifDecoder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public void resetFrameIndex() {
198198
framePointer = INITIAL_FRAME_POINTER;
199199
}
200200

201+
@Deprecated
201202
@Override
202203
public int getLoopCount() {
203204
if (header.loopCount == GifHeader.NETSCAPE_LOOP_COUNT_DOES_NOT_EXIST) {

0 commit comments

Comments
 (0)