From 67783961c71639871cc3687894976e6caeb6609e Mon Sep 17 00:00:00 2001
From: Alex Saveau
Requires {@link Build.VERSION_CODES#KITKAT KitKat} or higher.
*/ -@TargetApi(Build.VERSION_CODES.KITKAT) +@RequiresApi(Build.VERSION_CODES.KITKAT) class SizeStrategy implements LruPoolStrategy { private static final int MAX_SIZE_MULTIPLE = 8; private final KeyPool keyPool = new KeyPool(); diff --git a/library/src/main/java/com/bumptech/glide/load/engine/cache/MemorySizeCalculator.java b/library/src/main/java/com/bumptech/glide/load/engine/cache/MemorySizeCalculator.java index b9b06e516b..f044617a7e 100644 --- a/library/src/main/java/com/bumptech/glide/load/engine/cache/MemorySizeCalculator.java +++ b/library/src/main/java/com/bumptech/glide/load/engine/cache/MemorySizeCalculator.java @@ -1,5 +1,6 @@ package com.bumptech.glide.load.engine.cache; +import android.annotation.TargetApi; import android.app.ActivityManager; import android.content.Context; import android.os.Build; @@ -113,6 +114,7 @@ private String toMb(int bytes) { return Formatter.formatFileSize(context, bytes); } + @TargetApi(Build.VERSION_CODES.KITKAT) private static boolean isLowMemoryDevice(ActivityManager activityManager) { // Explicitly check with an if statement, on some devices both parts of boolean expressions // can be evaluated even if we'd normally expect a short circuit. diff --git a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java index f3e605b7a8..0e35bb7d82 100644 --- a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java +++ b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java @@ -108,7 +108,7 @@ public void onObtainBounds() { } @Override - public void onDecodeComplete(BitmapPool bitmapPool, Bitmap downsampled) throws IOException { + public void onDecodeComplete(BitmapPool bitmapPool, Bitmap downsampled) { // Do nothing. } }; diff --git a/library/src/main/java/com/bumptech/glide/manager/RequestManagerRetriever.java b/library/src/main/java/com/bumptech/glide/manager/RequestManagerRetriever.java index bce40689e5..04406f270e 100644 --- a/library/src/main/java/com/bumptech/glide/manager/RequestManagerRetriever.java +++ b/library/src/main/java/com/bumptech/glide/manager/RequestManagerRetriever.java @@ -317,7 +317,6 @@ public RequestManager get(android.app.Fragment fragment) { } } - @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) RequestManagerFragment getRequestManagerFragment( final android.app.FragmentManager fm, android.app.Fragment parentHint) { RequestManagerFragment current = (RequestManagerFragment) fm.findFragmentByTag(FRAGMENT_TAG); diff --git a/library/src/main/java/com/bumptech/glide/request/target/FixedSizeDrawable.java b/library/src/main/java/com/bumptech/glide/request/target/FixedSizeDrawable.java index 12efc9eea7..154bdc3eb5 100644 --- a/library/src/main/java/com/bumptech/glide/request/target/FixedSizeDrawable.java +++ b/library/src/main/java/com/bumptech/glide/request/target/FixedSizeDrawable.java @@ -1,6 +1,5 @@ package com.bumptech.glide.request.target; -import android.annotation.TargetApi; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.ColorFilter; @@ -11,6 +10,7 @@ import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.NonNull; +import android.support.annotation.RequiresApi; import com.bumptech.glide.util.Preconditions; import com.bumptech.glide.util.Synthetic; @@ -90,7 +90,7 @@ public Callback getCallback() { return wrapped.getCallback(); } - @TargetApi(Build.VERSION_CODES.KITKAT) + @RequiresApi(Build.VERSION_CODES.KITKAT) @Override public int getAlpha() { return wrapped.getAlpha(); diff --git a/library/src/main/java/com/bumptech/glide/util/LogTime.java b/library/src/main/java/com/bumptech/glide/util/LogTime.java index 344dbaa124..58ddd62691 100644 --- a/library/src/main/java/com/bumptech/glide/util/LogTime.java +++ b/library/src/main/java/com/bumptech/glide/util/LogTime.java @@ -9,7 +9,7 @@ */ public final class LogTime { private static final double MILLIS_MULTIPLIER = - Build.VERSION_CODES.JELLY_BEAN_MR1 <= Build.VERSION.SDK_INT ? 1d / Math.pow(10, 6) : 1d; + Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 ? 1d / Math.pow(10, 6) : 1d; private LogTime() { // Utility class. @@ -21,7 +21,7 @@ private LogTime() { */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static long getLogTime() { - if (Build.VERSION_CODES.JELLY_BEAN_MR1 <= Build.VERSION.SDK_INT) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { return SystemClock.elapsedRealtimeNanos(); } else { return SystemClock.uptimeMillis(); diff --git a/library/src/test/java/com/bumptech/glide/load/engine/bitmap_recycle/LruArrayPoolTest.java b/library/src/test/java/com/bumptech/glide/load/engine/bitmap_recycle/LruArrayPoolTest.java index 77d5e5e232..1c037b2f50 100644 --- a/library/src/test/java/com/bumptech/glide/load/engine/bitmap_recycle/LruArrayPoolTest.java +++ b/library/src/test/java/com/bumptech/glide/load/engine/bitmap_recycle/LruArrayPoolTest.java @@ -8,8 +8,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import android.annotation.TargetApi; -import android.os.Build; import java.util.Arrays; import java.util.HashSet; import java.util.Set; @@ -21,7 +19,6 @@ @RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE, sdk = 18) -@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public class LruArrayPoolTest { private static final int MAX_SIZE = 10; private static final int MAX_PUT_SIZE = MAX_SIZE / 2; @@ -30,7 +27,7 @@ public class LruArrayPoolTest { private LruArrayPool pool; @Before - public void setUp() throws Exception { + public void setUp() { pool = new LruArrayPool(MAX_SIZE); } diff --git a/library/src/test/java/com/bumptech/glide/load/engine/cache/LruResourceCacheTest.java b/library/src/test/java/com/bumptech/glide/load/engine/cache/LruResourceCacheTest.java index cca4ce3472..ce94ca4315 100644 --- a/library/src/test/java/com/bumptech/glide/load/engine/cache/LruResourceCacheTest.java +++ b/library/src/test/java/com/bumptech/glide/load/engine/cache/LruResourceCacheTest.java @@ -13,9 +13,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import android.annotation.TargetApi; import android.content.ComponentCallbacks2; -import android.os.Build; import android.support.annotation.NonNull; import com.bumptech.glide.load.Key; import com.bumptech.glide.load.engine.Resource; @@ -26,7 +24,6 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) -@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public class LruResourceCacheTest { @Test diff --git a/library/src/test/java/com/bumptech/glide/load/resource/bitmap/BitmapEncoderTest.java b/library/src/test/java/com/bumptech/glide/load/resource/bitmap/BitmapEncoderTest.java index d6a69e72d9..1d04019311 100644 --- a/library/src/test/java/com/bumptech/glide/load/resource/bitmap/BitmapEncoderTest.java +++ b/library/src/test/java/com/bumptech/glide/load/resource/bitmap/BitmapEncoderTest.java @@ -6,9 +6,7 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; -import android.annotation.TargetApi; import android.graphics.Bitmap; -import android.os.Build; import com.bumptech.glide.load.EncodeStrategy; import com.bumptech.glide.load.Options; import com.bumptech.glide.load.engine.Resource; @@ -57,7 +55,6 @@ public void testBitmapIsEncodedWithGivenQuality() throws IOException { } @Test - @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void testEncoderObeysNonNullCompressFormat() throws IOException { Bitmap.CompressFormat format = Bitmap.CompressFormat.WEBP; harness.setFormat(format); diff --git a/library/src/test/java/com/bumptech/glide/manager/Issue117Activity.java b/library/src/test/java/com/bumptech/glide/manager/Issue117Activity.java index 5d760d6979..60c59027d8 100644 --- a/library/src/test/java/com/bumptech/glide/manager/Issue117Activity.java +++ b/library/src/test/java/com/bumptech/glide/manager/Issue117Activity.java @@ -2,11 +2,11 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; -import android.annotation.TargetApi; import android.content.Context; import android.os.Build; import android.os.Bundle; import android.support.annotation.NonNull; +import android.support.annotation.RequiresApi; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; @@ -21,7 +21,7 @@ /** * A test activity to reproduce Issue #117: https://github.com/bumptech/glide/issues/117. */ -@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) +@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1) class Issue117Activity extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/library/src/test/java/com/bumptech/glide/manager/RequestManagerRetrieverTest.java b/library/src/test/java/com/bumptech/glide/manager/RequestManagerRetrieverTest.java index 359a0d7eae..79c5bd9f84 100644 --- a/library/src/test/java/com/bumptech/glide/manager/RequestManagerRetrieverTest.java +++ b/library/src/test/java/com/bumptech/glide/manager/RequestManagerRetrieverTest.java @@ -9,12 +9,12 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import android.annotation.TargetApi; import android.app.Activity; import android.content.Context; import android.content.ContextWrapper; import android.os.Build; import android.os.Looper; +import android.support.annotation.RequiresApi; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import com.bumptech.glide.RequestManager; @@ -309,7 +309,7 @@ public void testCanCallGetInOnAttachToWindowInFragmentInViewPager() { } @Test - @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) + @RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public void testDoesNotThrowIfAskedToGetManagerForActivityPreJellYBeanMr1() { Util.setSdkVersionInt(Build.VERSION_CODES.JELLY_BEAN); Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get(); @@ -320,7 +320,7 @@ public void testDoesNotThrowIfAskedToGetManagerForActivityPreJellYBeanMr1() { } @Test - @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) + @RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public void testDoesNotThrowIfAskedToGetManagerForFragmentPreJellyBeanMr1() { Util.setSdkVersionInt(Build.VERSION_CODES.JELLY_BEAN); Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get(); diff --git a/samples/contacturi/src/main/java/com/bumptech/glide/samples/contacturi/MainActivity.java b/samples/contacturi/src/main/java/com/bumptech/glide/samples/contacturi/MainActivity.java index 71609b6de1..c072483df8 100644 --- a/samples/contacturi/src/main/java/com/bumptech/glide/samples/contacturi/MainActivity.java +++ b/samples/contacturi/src/main/java/com/bumptech/glide/samples/contacturi/MainActivity.java @@ -1,10 +1,6 @@ package com.bumptech.glide.samples.contacturi; -import static android.os.Build.VERSION; -import static android.os.Build.VERSION_CODES; - import android.Manifest; -import android.annotation.TargetApi; import android.app.Activity; import android.content.ContentUris; import android.content.Intent; @@ -45,11 +41,11 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - imageViewContact = (ImageView) findViewById(R.id.image_contact); - imageViewLookup = (ImageView) findViewById(R.id.image_lookup); - imageViewPhoto = (ImageView) findViewById(R.id.image_photo); - imageViewDisplayPhoto = (ImageView) findViewById(R.id.image_display_photo); - numberEntry = (EditText) findViewById(R.id.number_entry); + imageViewContact = findViewById(R.id.image_contact); + imageViewLookup = findViewById(R.id.image_lookup); + imageViewPhoto = findViewById(R.id.image_photo); + imageViewDisplayPhoto = findViewById(R.id.image_display_photo); + numberEntry = findViewById(R.id.number_entry); // Make sure that user gives application required permissions if (ContextCompat.checkSelfPermission( getApplication(), @@ -101,7 +97,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); } - @TargetApi(VERSION_CODES.ICE_CREAM_SANDWICH) private void showContact(long id) { GlideRequests glideRequests = GlideApp.with(this); RequestOptions originalSize = new RequestOptions().override(Target.SIZE_ORIGINAL); @@ -115,9 +110,7 @@ private void showContact(long id) { Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY); glideRequests.load(photoUri).apply(originalSize).into(imageViewPhoto); - if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) { - Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO); - glideRequests.load(displayPhotoUri).apply(originalSize).into(imageViewDisplayPhoto); - } + Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO); + glideRequests.load(displayPhotoUri).apply(originalSize).into(imageViewDisplayPhoto); } } diff --git a/samples/gallery/src/main/java/com/bumptech/glide/samples/gallery/MainActivity.java b/samples/gallery/src/main/java/com/bumptech/glide/samples/gallery/MainActivity.java index cf315b106c..1206230ff6 100644 --- a/samples/gallery/src/main/java/com/bumptech/glide/samples/gallery/MainActivity.java +++ b/samples/gallery/src/main/java/com/bumptech/glide/samples/gallery/MainActivity.java @@ -1,11 +1,11 @@ package com.bumptech.glide.samples.gallery; import android.Manifest.permission; -import android.annotation.TargetApi; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.NonNull; +import android.support.annotation.RequiresApi; import android.support.v4.app.ActivityCompat; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; @@ -16,6 +16,7 @@ /** * Displays a {@link HorizontalGalleryFragment}. */ +@RequiresApi(Build.VERSION_CODES.JELLY_BEAN) public class MainActivity extends FragmentActivity { private static final int REQUEST_READ_STORAGE = 0; @@ -34,7 +35,6 @@ protected void onCreate(Bundle savedInstanceState) { } } - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void requestStoragePermission() { ActivityCompat.requestPermissions(this, new String[]{permission.READ_EXTERNAL_STORAGE},