From 0cffd1da977e9ca334032ebc1d798213a177aab7 Mon Sep 17 00:00:00 2001 From: Alex Saveau Date: Mon, 11 Dec 2017 17:57:05 -0800 Subject: [PATCH] Add nullability annotations to library module (1/n) (#2681) * Add nullability annotations Signed-off-by: Alex Saveau --- .../EmptyAppGlideModuleTest/GlideApp.java | 42 +++++------ .../EmptyAppGlideModuleTest/GlideRequest.java | 15 ++++ .../GlideRequests.java | 22 ++++-- .../MemoizeStaticMethod/GlideRequest.java | 15 ++++ .../OverrideExtend/GlideRequest.java | 15 ++++ .../GlideRequest.java | 15 ++++ .../OverrideReplace/GlideRequest.java | 15 ++++ .../SkipStaticMethod/GlideRequest.java | 15 ++++ .../StaticMethodName/GlideRequest.java | 15 ++++ .../GlideRequest.java | 15 ++++ .../GlideRequests.java | 22 ++++-- .../MemoizeStaticMethod/GlideRequest.java | 15 ++++ .../OverrideExtend/GlideRequest.java | 15 ++++ .../OverrideReplace/GlideRequest.java | 15 ++++ .../SkipStaticMethod/GlideRequest.java | 15 ++++ .../StaticMethodName/GlideRequest.java | 15 ++++ .../GlideRequest.java | 15 ++++ .../GlideRequests.java | 22 ++++-- .../glide/GenericTransitionOptions.java | 9 ++- .../main/java/com/bumptech/glide/Glide.java | 66 +++++++++++------- .../java/com/bumptech/glide/GlideBuilder.java | 41 +++++++---- .../java/com/bumptech/glide/GlideContext.java | 23 ++++--- .../java/com/bumptech/glide/ModelTypes.java | 13 +++- .../com/bumptech/glide/RequestBuilder.java | 34 +++++++-- .../com/bumptech/glide/RequestManager.java | 39 ++++++++--- .../com/bumptech/glide/TransitionOptions.java | 10 ++- .../bitmap/BitmapTransitionOptions.java | 27 ++++++-- .../drawable/DrawableTransitionOptions.java | 21 ++++-- .../manager/RequestManagerRetriever.java | 69 +++++++++++-------- .../target/ImageViewTargetFactory.java | 6 +- .../bumptech/glide/util/Preconditions.java | 16 +++-- 31 files changed, 547 insertions(+), 145 deletions(-) diff --git a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideApp.java b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideApp.java index dd7816ef6d..685506a887 100644 --- a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideApp.java +++ b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideApp.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.app.Fragment; import android.content.Context; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.v4.app.FragmentActivity; @@ -31,23 +32,24 @@ private GlideApp() { * @see Glide#getPhotoCacheDir(Context) */ @Nullable - public static File getPhotoCacheDir(Context context) { - return Glide.getPhotoCacheDir(context); + public static File getPhotoCacheDir(Context arg0) { + return Glide.getPhotoCacheDir(arg0); } /** * @see Glide#getPhotoCacheDir(Context, String) */ @Nullable - public static File getPhotoCacheDir(Context context, String cacheName) { - return Glide.getPhotoCacheDir(context, cacheName); + public static File getPhotoCacheDir(Context arg0, String arg1) { + return Glide.getPhotoCacheDir(arg0, arg1); } /** * @see Glide#get(Context) */ - public static Glide get(Context context) { - return Glide.get(context); + @NonNull + public static Glide get(Context arg0) { + return Glide.get(arg0); } /** @@ -65,8 +67,8 @@ public static void init(Glide glide) { */ @VisibleForTesting @SuppressLint("VisibleForTests") - public static void init(Context context, GlideBuilder builder) { - Glide.init(context, builder); + public static void init(Context arg0, GlideBuilder arg1) { + Glide.init(arg0, arg1); } /** @@ -81,42 +83,42 @@ public static void tearDown() { /** * @see Glide#with(Context) */ - public static GlideRequests with(Context context) { - return (GlideRequests) Glide.with(context); + public static GlideRequests with(Context arg0) { + return (GlideRequests) Glide.with(arg0); } /** * @see Glide#with(Activity) */ - public static GlideRequests with(Activity activity) { - return (GlideRequests) Glide.with(activity); + public static GlideRequests with(Activity arg0) { + return (GlideRequests) Glide.with(arg0); } /** * @see Glide#with(FragmentActivity) */ - public static GlideRequests with(FragmentActivity activity) { - return (GlideRequests) Glide.with(activity); + public static GlideRequests with(FragmentActivity arg0) { + return (GlideRequests) Glide.with(arg0); } /** * @see Glide#with(Fragment) */ - public static GlideRequests with(Fragment fragment) { - return (GlideRequests) Glide.with(fragment); + public static GlideRequests with(Fragment arg0) { + return (GlideRequests) Glide.with(arg0); } /** * @see Glide#with(Fragment) */ - public static GlideRequests with(android.support.v4.app.Fragment fragment) { - return (GlideRequests) Glide.with(fragment); + public static GlideRequests with(android.support.v4.app.Fragment arg0) { + return (GlideRequests) Glide.with(arg0); } /** * @see Glide#with(View) */ - public static GlideRequests with(View view) { - return (GlideRequests) Glide.with(view); + public static GlideRequests with(View arg0) { + return (GlideRequests) Glide.with(arg0); } } diff --git a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequest.java b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequest.java index 6ddaf2c818..64329582ef 100644 --- a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequest.java @@ -608,35 +608,41 @@ public GlideRequest dontAnimate() { } @Override + @NonNull @CheckResult public GlideRequest apply(@NonNull RequestOptions arg0) { return (GlideRequest) super.apply(arg0); } @Override + @NonNull @CheckResult public GlideRequest transition(@NonNull TransitionOptions arg0) { return (GlideRequest) super.transition(arg0); } @Override + @NonNull @CheckResult public GlideRequest listener(@Nullable RequestListener arg0) { return (GlideRequest) super.listener(arg0); } @Override + @NonNull public GlideRequest error(@Nullable RequestBuilder arg0) { return (GlideRequest) super.error(arg0); } @Override + @NonNull @CheckResult public GlideRequest thumbnail(@Nullable RequestBuilder arg0) { return (GlideRequest) super.thumbnail(arg0); } @Override + @NonNull @CheckResult @SafeVarargs @SuppressWarnings("varargs") @@ -645,48 +651,56 @@ public final GlideRequest thumbnail(@Nullable RequestBuilder thumbnail(float sizeMultiplier) { return (GlideRequest) super.thumbnail(sizeMultiplier); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@RawRes @DrawableRes @Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -700,6 +714,7 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); diff --git a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequests.java b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequests.java index 9a658eb842..f89121f9cb 100644 --- a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequests.java +++ b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequests.java @@ -43,64 +43,73 @@ public GlideRequest as(Class resource } @Override - public GlideRequests applyDefaultRequestOptions(RequestOptions requestOptions) { - return (GlideRequests) super.applyDefaultRequestOptions(requestOptions); + public GlideRequests applyDefaultRequestOptions(@NonNull RequestOptions arg0) { + return (GlideRequests) super.applyDefaultRequestOptions(arg0); } @Override - public GlideRequests setDefaultRequestOptions(RequestOptions requestOptions) { - return (GlideRequests) super.setDefaultRequestOptions(requestOptions); + public GlideRequests setDefaultRequestOptions(@NonNull RequestOptions arg0) { + return (GlideRequests) super.setDefaultRequestOptions(arg0); } @Override + @NonNull @CheckResult public GlideRequest asBitmap() { return (GlideRequest) super.asBitmap(); } @Override + @NonNull @CheckResult public GlideRequest asGif() { return (GlideRequest) super.asGif(); } @Override + @NonNull @CheckResult public GlideRequest asDrawable() { return (GlideRequest) super.asDrawable(); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -114,30 +123,35 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest downloadOnly() { return (GlideRequest) super.downloadOnly(); } @Override + @NonNull @CheckResult public GlideRequest download(@Nullable Object arg0) { return (GlideRequest) super.download(arg0); } @Override + @NonNull @CheckResult public GlideRequest asFile() { return (GlideRequest) super.asFile(); diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java index 7dffdd3a8c..e95fd0b0b1 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java @@ -621,35 +621,41 @@ public GlideRequest test() { } @Override + @NonNull @CheckResult public GlideRequest apply(@NonNull RequestOptions arg0) { return (GlideRequest) super.apply(arg0); } @Override + @NonNull @CheckResult public GlideRequest transition(@NonNull TransitionOptions arg0) { return (GlideRequest) super.transition(arg0); } @Override + @NonNull @CheckResult public GlideRequest listener(@Nullable RequestListener arg0) { return (GlideRequest) super.listener(arg0); } @Override + @NonNull public GlideRequest error(@Nullable RequestBuilder arg0) { return (GlideRequest) super.error(arg0); } @Override + @NonNull @CheckResult public GlideRequest thumbnail(@Nullable RequestBuilder arg0) { return (GlideRequest) super.thumbnail(arg0); } @Override + @NonNull @CheckResult @SafeVarargs @SuppressWarnings("varargs") @@ -658,48 +664,56 @@ public final GlideRequest thumbnail(@Nullable RequestBuilder thumbnail(float sizeMultiplier) { return (GlideRequest) super.thumbnail(sizeMultiplier); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@RawRes @DrawableRes @Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -713,6 +727,7 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideRequest.java index 81b363561c..665cc9c552 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideRequest.java @@ -608,35 +608,41 @@ public GlideRequest centerCrop() { } @Override + @NonNull @CheckResult public GlideRequest apply(@NonNull RequestOptions arg0) { return (GlideRequest) super.apply(arg0); } @Override + @NonNull @CheckResult public GlideRequest transition(@NonNull TransitionOptions arg0) { return (GlideRequest) super.transition(arg0); } @Override + @NonNull @CheckResult public GlideRequest listener(@Nullable RequestListener arg0) { return (GlideRequest) super.listener(arg0); } @Override + @NonNull public GlideRequest error(@Nullable RequestBuilder arg0) { return (GlideRequest) super.error(arg0); } @Override + @NonNull @CheckResult public GlideRequest thumbnail(@Nullable RequestBuilder arg0) { return (GlideRequest) super.thumbnail(arg0); } @Override + @NonNull @CheckResult @SafeVarargs @SuppressWarnings("varargs") @@ -645,48 +651,56 @@ public final GlideRequest thumbnail(@Nullable RequestBuilder thumbnail(float sizeMultiplier) { return (GlideRequest) super.thumbnail(sizeMultiplier); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@RawRes @DrawableRes @Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -700,6 +714,7 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideRequest.java index d9e88c5352..dea6ceff36 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideRequest.java @@ -608,35 +608,41 @@ public GlideRequest override(int width, int height) { } @Override + @NonNull @CheckResult public GlideRequest apply(@NonNull RequestOptions arg0) { return (GlideRequest) super.apply(arg0); } @Override + @NonNull @CheckResult public GlideRequest transition(@NonNull TransitionOptions arg0) { return (GlideRequest) super.transition(arg0); } @Override + @NonNull @CheckResult public GlideRequest listener(@Nullable RequestListener arg0) { return (GlideRequest) super.listener(arg0); } @Override + @NonNull public GlideRequest error(@Nullable RequestBuilder arg0) { return (GlideRequest) super.error(arg0); } @Override + @NonNull @CheckResult public GlideRequest thumbnail(@Nullable RequestBuilder arg0) { return (GlideRequest) super.thumbnail(arg0); } @Override + @NonNull @CheckResult @SafeVarargs @SuppressWarnings("varargs") @@ -645,48 +651,56 @@ public final GlideRequest thumbnail(@Nullable RequestBuilder thumbnail(float sizeMultiplier) { return (GlideRequest) super.thumbnail(sizeMultiplier); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@RawRes @DrawableRes @Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -700,6 +714,7 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideRequest.java index 81b363561c..665cc9c552 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideRequest.java @@ -608,35 +608,41 @@ public GlideRequest centerCrop() { } @Override + @NonNull @CheckResult public GlideRequest apply(@NonNull RequestOptions arg0) { return (GlideRequest) super.apply(arg0); } @Override + @NonNull @CheckResult public GlideRequest transition(@NonNull TransitionOptions arg0) { return (GlideRequest) super.transition(arg0); } @Override + @NonNull @CheckResult public GlideRequest listener(@Nullable RequestListener arg0) { return (GlideRequest) super.listener(arg0); } @Override + @NonNull public GlideRequest error(@Nullable RequestBuilder arg0) { return (GlideRequest) super.error(arg0); } @Override + @NonNull @CheckResult public GlideRequest thumbnail(@Nullable RequestBuilder arg0) { return (GlideRequest) super.thumbnail(arg0); } @Override + @NonNull @CheckResult @SafeVarargs @SuppressWarnings("varargs") @@ -645,48 +651,56 @@ public final GlideRequest thumbnail(@Nullable RequestBuilder thumbnail(float sizeMultiplier) { return (GlideRequest) super.thumbnail(sizeMultiplier); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@RawRes @DrawableRes @Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -700,6 +714,7 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java index 7dffdd3a8c..e95fd0b0b1 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java @@ -621,35 +621,41 @@ public GlideRequest test() { } @Override + @NonNull @CheckResult public GlideRequest apply(@NonNull RequestOptions arg0) { return (GlideRequest) super.apply(arg0); } @Override + @NonNull @CheckResult public GlideRequest transition(@NonNull TransitionOptions arg0) { return (GlideRequest) super.transition(arg0); } @Override + @NonNull @CheckResult public GlideRequest listener(@Nullable RequestListener arg0) { return (GlideRequest) super.listener(arg0); } @Override + @NonNull public GlideRequest error(@Nullable RequestBuilder arg0) { return (GlideRequest) super.error(arg0); } @Override + @NonNull @CheckResult public GlideRequest thumbnail(@Nullable RequestBuilder arg0) { return (GlideRequest) super.thumbnail(arg0); } @Override + @NonNull @CheckResult @SafeVarargs @SuppressWarnings("varargs") @@ -658,48 +664,56 @@ public final GlideRequest thumbnail(@Nullable RequestBuilder thumbnail(float sizeMultiplier) { return (GlideRequest) super.thumbnail(sizeMultiplier); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@RawRes @DrawableRes @Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -713,6 +727,7 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideRequest.java index 7dffdd3a8c..e95fd0b0b1 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideRequest.java @@ -621,35 +621,41 @@ public GlideRequest test() { } @Override + @NonNull @CheckResult public GlideRequest apply(@NonNull RequestOptions arg0) { return (GlideRequest) super.apply(arg0); } @Override + @NonNull @CheckResult public GlideRequest transition(@NonNull TransitionOptions arg0) { return (GlideRequest) super.transition(arg0); } @Override + @NonNull @CheckResult public GlideRequest listener(@Nullable RequestListener arg0) { return (GlideRequest) super.listener(arg0); } @Override + @NonNull public GlideRequest error(@Nullable RequestBuilder arg0) { return (GlideRequest) super.error(arg0); } @Override + @NonNull @CheckResult public GlideRequest thumbnail(@Nullable RequestBuilder arg0) { return (GlideRequest) super.thumbnail(arg0); } @Override + @NonNull @CheckResult @SafeVarargs @SuppressWarnings("varargs") @@ -658,48 +664,56 @@ public final GlideRequest thumbnail(@Nullable RequestBuilder thumbnail(float sizeMultiplier) { return (GlideRequest) super.thumbnail(sizeMultiplier); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@RawRes @DrawableRes @Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -713,6 +727,7 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideRequest.java index ff97af38bf..73a5fb86b2 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideRequest.java @@ -621,35 +621,41 @@ public GlideRequest squareThumb() { } @Override + @NonNull @CheckResult public GlideRequest apply(@NonNull RequestOptions arg0) { return (GlideRequest) super.apply(arg0); } @Override + @NonNull @CheckResult public GlideRequest transition(@NonNull TransitionOptions arg0) { return (GlideRequest) super.transition(arg0); } @Override + @NonNull @CheckResult public GlideRequest listener(@Nullable RequestListener arg0) { return (GlideRequest) super.listener(arg0); } @Override + @NonNull public GlideRequest error(@Nullable RequestBuilder arg0) { return (GlideRequest) super.error(arg0); } @Override + @NonNull @CheckResult public GlideRequest thumbnail(@Nullable RequestBuilder arg0) { return (GlideRequest) super.thumbnail(arg0); } @Override + @NonNull @CheckResult @SafeVarargs @SuppressWarnings("varargs") @@ -658,48 +664,56 @@ public final GlideRequest thumbnail(@Nullable RequestBuilder thumbnail(float sizeMultiplier) { return (GlideRequest) super.thumbnail(sizeMultiplier); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@RawRes @DrawableRes @Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -713,6 +727,7 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideRequests.java b/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideRequests.java index 7d02b4b5a9..ac9063d4c5 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideRequests.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideRequests.java @@ -51,64 +51,73 @@ public GlideRequest asNumber() { } @Override - public GlideRequests applyDefaultRequestOptions(RequestOptions requestOptions) { - return (GlideRequests) super.applyDefaultRequestOptions(requestOptions); + public GlideRequests applyDefaultRequestOptions(@NonNull RequestOptions arg0) { + return (GlideRequests) super.applyDefaultRequestOptions(arg0); } @Override - public GlideRequests setDefaultRequestOptions(RequestOptions requestOptions) { - return (GlideRequests) super.setDefaultRequestOptions(requestOptions); + public GlideRequests setDefaultRequestOptions(@NonNull RequestOptions arg0) { + return (GlideRequests) super.setDefaultRequestOptions(arg0); } @Override + @NonNull @CheckResult public GlideRequest asBitmap() { return (GlideRequest) super.asBitmap(); } @Override + @NonNull @CheckResult public GlideRequest asGif() { return (GlideRequest) super.asGif(); } @Override + @NonNull @CheckResult public GlideRequest asDrawable() { return (GlideRequest) super.asDrawable(); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -122,30 +131,35 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest downloadOnly() { return (GlideRequest) super.downloadOnly(); } @Override + @NonNull @CheckResult public GlideRequest download(@Nullable Object arg0) { return (GlideRequest) super.download(arg0); } @Override + @NonNull @CheckResult public GlideRequest asFile() { return (GlideRequest) super.asFile(); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java index 7dffdd3a8c..e95fd0b0b1 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java @@ -621,35 +621,41 @@ public GlideRequest test() { } @Override + @NonNull @CheckResult public GlideRequest apply(@NonNull RequestOptions arg0) { return (GlideRequest) super.apply(arg0); } @Override + @NonNull @CheckResult public GlideRequest transition(@NonNull TransitionOptions arg0) { return (GlideRequest) super.transition(arg0); } @Override + @NonNull @CheckResult public GlideRequest listener(@Nullable RequestListener arg0) { return (GlideRequest) super.listener(arg0); } @Override + @NonNull public GlideRequest error(@Nullable RequestBuilder arg0) { return (GlideRequest) super.error(arg0); } @Override + @NonNull @CheckResult public GlideRequest thumbnail(@Nullable RequestBuilder arg0) { return (GlideRequest) super.thumbnail(arg0); } @Override + @NonNull @CheckResult @SafeVarargs @SuppressWarnings("varargs") @@ -658,48 +664,56 @@ public final GlideRequest thumbnail(@Nullable RequestBuilder thumbnail(float sizeMultiplier) { return (GlideRequest) super.thumbnail(sizeMultiplier); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@RawRes @DrawableRes @Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -713,6 +727,7 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideExtend/GlideRequest.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideExtend/GlideRequest.java index 81b363561c..665cc9c552 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideExtend/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideExtend/GlideRequest.java @@ -608,35 +608,41 @@ public GlideRequest centerCrop() { } @Override + @NonNull @CheckResult public GlideRequest apply(@NonNull RequestOptions arg0) { return (GlideRequest) super.apply(arg0); } @Override + @NonNull @CheckResult public GlideRequest transition(@NonNull TransitionOptions arg0) { return (GlideRequest) super.transition(arg0); } @Override + @NonNull @CheckResult public GlideRequest listener(@Nullable RequestListener arg0) { return (GlideRequest) super.listener(arg0); } @Override + @NonNull public GlideRequest error(@Nullable RequestBuilder arg0) { return (GlideRequest) super.error(arg0); } @Override + @NonNull @CheckResult public GlideRequest thumbnail(@Nullable RequestBuilder arg0) { return (GlideRequest) super.thumbnail(arg0); } @Override + @NonNull @CheckResult @SafeVarargs @SuppressWarnings("varargs") @@ -645,48 +651,56 @@ public final GlideRequest thumbnail(@Nullable RequestBuilder thumbnail(float sizeMultiplier) { return (GlideRequest) super.thumbnail(sizeMultiplier); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@RawRes @DrawableRes @Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -700,6 +714,7 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideReplace/GlideRequest.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideReplace/GlideRequest.java index 81b363561c..665cc9c552 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideReplace/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideReplace/GlideRequest.java @@ -608,35 +608,41 @@ public GlideRequest centerCrop() { } @Override + @NonNull @CheckResult public GlideRequest apply(@NonNull RequestOptions arg0) { return (GlideRequest) super.apply(arg0); } @Override + @NonNull @CheckResult public GlideRequest transition(@NonNull TransitionOptions arg0) { return (GlideRequest) super.transition(arg0); } @Override + @NonNull @CheckResult public GlideRequest listener(@Nullable RequestListener arg0) { return (GlideRequest) super.listener(arg0); } @Override + @NonNull public GlideRequest error(@Nullable RequestBuilder arg0) { return (GlideRequest) super.error(arg0); } @Override + @NonNull @CheckResult public GlideRequest thumbnail(@Nullable RequestBuilder arg0) { return (GlideRequest) super.thumbnail(arg0); } @Override + @NonNull @CheckResult @SafeVarargs @SuppressWarnings("varargs") @@ -645,48 +651,56 @@ public final GlideRequest thumbnail(@Nullable RequestBuilder thumbnail(float sizeMultiplier) { return (GlideRequest) super.thumbnail(sizeMultiplier); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@RawRes @DrawableRes @Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -700,6 +714,7 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java index 7dffdd3a8c..e95fd0b0b1 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java @@ -621,35 +621,41 @@ public GlideRequest test() { } @Override + @NonNull @CheckResult public GlideRequest apply(@NonNull RequestOptions arg0) { return (GlideRequest) super.apply(arg0); } @Override + @NonNull @CheckResult public GlideRequest transition(@NonNull TransitionOptions arg0) { return (GlideRequest) super.transition(arg0); } @Override + @NonNull @CheckResult public GlideRequest listener(@Nullable RequestListener arg0) { return (GlideRequest) super.listener(arg0); } @Override + @NonNull public GlideRequest error(@Nullable RequestBuilder arg0) { return (GlideRequest) super.error(arg0); } @Override + @NonNull @CheckResult public GlideRequest thumbnail(@Nullable RequestBuilder arg0) { return (GlideRequest) super.thumbnail(arg0); } @Override + @NonNull @CheckResult @SafeVarargs @SuppressWarnings("varargs") @@ -658,48 +664,56 @@ public final GlideRequest thumbnail(@Nullable RequestBuilder thumbnail(float sizeMultiplier) { return (GlideRequest) super.thumbnail(sizeMultiplier); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@RawRes @DrawableRes @Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -713,6 +727,7 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/StaticMethodName/GlideRequest.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/StaticMethodName/GlideRequest.java index 7dffdd3a8c..e95fd0b0b1 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/StaticMethodName/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/StaticMethodName/GlideRequest.java @@ -621,35 +621,41 @@ public GlideRequest test() { } @Override + @NonNull @CheckResult public GlideRequest apply(@NonNull RequestOptions arg0) { return (GlideRequest) super.apply(arg0); } @Override + @NonNull @CheckResult public GlideRequest transition(@NonNull TransitionOptions arg0) { return (GlideRequest) super.transition(arg0); } @Override + @NonNull @CheckResult public GlideRequest listener(@Nullable RequestListener arg0) { return (GlideRequest) super.listener(arg0); } @Override + @NonNull public GlideRequest error(@Nullable RequestBuilder arg0) { return (GlideRequest) super.error(arg0); } @Override + @NonNull @CheckResult public GlideRequest thumbnail(@Nullable RequestBuilder arg0) { return (GlideRequest) super.thumbnail(arg0); } @Override + @NonNull @CheckResult @SafeVarargs @SuppressWarnings("varargs") @@ -658,48 +664,56 @@ public final GlideRequest thumbnail(@Nullable RequestBuilder thumbnail(float sizeMultiplier) { return (GlideRequest) super.thumbnail(sizeMultiplier); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@RawRes @DrawableRes @Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -713,6 +727,7 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithOptionTest/GlideRequest.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithOptionTest/GlideRequest.java index ff97af38bf..73a5fb86b2 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithOptionTest/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithOptionTest/GlideRequest.java @@ -621,35 +621,41 @@ public GlideRequest squareThumb() { } @Override + @NonNull @CheckResult public GlideRequest apply(@NonNull RequestOptions arg0) { return (GlideRequest) super.apply(arg0); } @Override + @NonNull @CheckResult public GlideRequest transition(@NonNull TransitionOptions arg0) { return (GlideRequest) super.transition(arg0); } @Override + @NonNull @CheckResult public GlideRequest listener(@Nullable RequestListener arg0) { return (GlideRequest) super.listener(arg0); } @Override + @NonNull public GlideRequest error(@Nullable RequestBuilder arg0) { return (GlideRequest) super.error(arg0); } @Override + @NonNull @CheckResult public GlideRequest thumbnail(@Nullable RequestBuilder arg0) { return (GlideRequest) super.thumbnail(arg0); } @Override + @NonNull @CheckResult @SafeVarargs @SuppressWarnings("varargs") @@ -658,48 +664,56 @@ public final GlideRequest thumbnail(@Nullable RequestBuilder thumbnail(float sizeMultiplier) { return (GlideRequest) super.thumbnail(sizeMultiplier); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@RawRes @DrawableRes @Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -713,6 +727,7 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithTypeTest/GlideRequests.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithTypeTest/GlideRequests.java index 287ab61715..2bde90dd42 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithTypeTest/GlideRequests.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithTypeTest/GlideRequests.java @@ -53,64 +53,73 @@ public GlideRequest asInteger() { } @Override - public GlideRequests applyDefaultRequestOptions(RequestOptions requestOptions) { - return (GlideRequests) super.applyDefaultRequestOptions(requestOptions); + public GlideRequests applyDefaultRequestOptions(@NonNull RequestOptions arg0) { + return (GlideRequests) super.applyDefaultRequestOptions(arg0); } @Override - public GlideRequests setDefaultRequestOptions(RequestOptions requestOptions) { - return (GlideRequests) super.setDefaultRequestOptions(requestOptions); + public GlideRequests setDefaultRequestOptions(@NonNull RequestOptions arg0) { + return (GlideRequests) super.setDefaultRequestOptions(arg0); } @Override + @NonNull @CheckResult public GlideRequest asBitmap() { return (GlideRequest) super.asBitmap(); } @Override + @NonNull @CheckResult public GlideRequest asGif() { return (GlideRequest) super.asGif(); } @Override + @NonNull @CheckResult public GlideRequest asDrawable() { return (GlideRequest) super.asDrawable(); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Bitmap arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Drawable arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable String arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Uri arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable File arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Integer arg0) { return (GlideRequest) super.load(arg0); @@ -124,30 +133,35 @@ public GlideRequest load(@Nullable URL arg0) { } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable byte[] arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest load(@Nullable Object arg0) { return (GlideRequest) super.load(arg0); } @Override + @NonNull @CheckResult public GlideRequest downloadOnly() { return (GlideRequest) super.downloadOnly(); } @Override + @NonNull @CheckResult public GlideRequest download(@Nullable Object arg0) { return (GlideRequest) super.download(arg0); } @Override + @NonNull @CheckResult public GlideRequest asFile() { return (GlideRequest) super.asFile(); diff --git a/library/src/main/java/com/bumptech/glide/GenericTransitionOptions.java b/library/src/main/java/com/bumptech/glide/GenericTransitionOptions.java index f1d226e8cd..a630b4f86d 100644 --- a/library/src/main/java/com/bumptech/glide/GenericTransitionOptions.java +++ b/library/src/main/java/com/bumptech/glide/GenericTransitionOptions.java @@ -1,5 +1,6 @@ package com.bumptech.glide; +import android.support.annotation.NonNull; import com.bumptech.glide.request.transition.TransitionFactory; import com.bumptech.glide.request.transition.ViewPropertyTransition; @@ -18,6 +19,7 @@ public final class GenericTransitionOptions extends * * @see GenericTransitionOptions#dontTransition() */ + @NonNull public static GenericTransitionOptions withNoTransition() { return new GenericTransitionOptions().dontTransition(); } @@ -27,6 +29,7 @@ public static GenericTransitionOptions withNoTran * * @see GenericTransitionOptions#transition(int) */ + @NonNull public static GenericTransitionOptions with( int viewAnimationId) { return new GenericTransitionOptions().transition(viewAnimationId); @@ -37,8 +40,9 @@ public static GenericTransitionOptions with( * * @see GenericTransitionOptions#transition(ViewPropertyTransition.Animator) */ + @NonNull public static GenericTransitionOptions with( - ViewPropertyTransition.Animator animator) { + @NonNull ViewPropertyTransition.Animator animator) { return new GenericTransitionOptions().transition(animator); } @@ -47,8 +51,9 @@ public static GenericTransitionOptions with( * * @see GenericTransitionOptions#transition(TransitionFactory) */ + @NonNull public static GenericTransitionOptions with( - TransitionFactory transitionFactory) { + @NonNull TransitionFactory transitionFactory) { return new GenericTransitionOptions().transition(transitionFactory); } } diff --git a/library/src/main/java/com/bumptech/glide/Glide.java b/library/src/main/java/com/bumptech/glide/Glide.java index be50104bcc..051cc3f418 100644 --- a/library/src/main/java/com/bumptech/glide/Glide.java +++ b/library/src/main/java/com/bumptech/glide/Glide.java @@ -10,6 +10,7 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.ParcelFileDescriptor; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.v4.app.Fragment; @@ -116,7 +117,7 @@ public class Glide implements ComponentCallbacks2 { * @see #getPhotoCacheDir(android.content.Context, String) */ @Nullable - public static File getPhotoCacheDir(Context context) { + public static File getPhotoCacheDir(@NonNull Context context) { return getPhotoCacheDir(context, DEFAULT_DISK_CACHE_DIR); } @@ -129,7 +130,7 @@ public static File getPhotoCacheDir(Context context) { * @see #getPhotoCacheDir(android.content.Context) */ @Nullable - public static File getPhotoCacheDir(Context context, String cacheName) { + public static File getPhotoCacheDir(@NonNull Context context, @NonNull String cacheName) { File cacheDir = context.getCacheDir(); if (cacheDir != null) { File result = new File(cacheDir, cacheName); @@ -150,7 +151,8 @@ public static File getPhotoCacheDir(Context context, String cacheName) { * * @return the singleton */ - public static Glide get(Context context) { + @NonNull + public static Glide get(@NonNull Context context) { if (glide == null) { synchronized (Glide.class) { if (glide == null) { @@ -162,7 +164,7 @@ public static Glide get(Context context) { return glide; } - private static void checkAndInitializeGlide(Context context) { + private static void checkAndInitializeGlide(@NonNull Context context) { // In the thread running initGlide(), one or more classes may call Glide.get(context). // Without this check, those calls could trigger infinite recursion. if (isInitializing) { @@ -190,7 +192,7 @@ public static synchronized void init(Glide glide) { } @VisibleForTesting - public static synchronized void init(Context context, GlideBuilder builder) { + public static synchronized void init(@NonNull Context context, @NonNull GlideBuilder builder) { if (Glide.glide != null) { tearDown(); } @@ -208,12 +210,12 @@ public static synchronized void tearDown() { glide = null; } - private static void initializeGlide(Context context) { + private static void initializeGlide(@NonNull Context context) { initializeGlide(context, new GlideBuilder()); } @SuppressWarnings("deprecation") - private static void initializeGlide(Context context, GlideBuilder builder) { + private static void initializeGlide(@NonNull Context context, @NonNull GlideBuilder builder) { Context applicationContext = context.getApplicationContext(); GeneratedAppGlideModule annotationGeneratedModule = getAnnotationGeneratedGlideModules(); List manifestModules = Collections.emptyList(); @@ -295,16 +297,16 @@ private static GeneratedAppGlideModule getAnnotationGeneratedGlideModules() { } Glide( - Context context, - Engine engine, - MemoryCache memoryCache, - BitmapPool bitmapPool, - ArrayPool arrayPool, - RequestManagerRetriever requestManagerRetriever, - ConnectivityMonitorFactory connectivityMonitorFactory, + @NonNull Context context, + @NonNull Engine engine, + @NonNull MemoryCache memoryCache, + @NonNull BitmapPool bitmapPool, + @NonNull ArrayPool arrayPool, + @NonNull RequestManagerRetriever requestManagerRetriever, + @NonNull ConnectivityMonitorFactory connectivityMonitorFactory, int logLevel, - RequestOptions defaultRequestOptions, - Map, TransitionOptions> defaultTransitionOptions) { + @NonNull RequestOptions defaultRequestOptions, + @NonNull Map, TransitionOptions> defaultTransitionOptions) { this.engine = engine; this.bitmapPool = bitmapPool; this.arrayPool = arrayPool; @@ -475,10 +477,12 @@ Uri.class, Bitmap.class, new ResourceBitmapDecoder(resourceDrawableDecoder, bitm * {@link com.bumptech.glide.load.Transformation}s. Use outside of these classes is not generally * recommended.

*/ + @NonNull public BitmapPool getBitmapPool() { return bitmapPool; } + @NonNull public ArrayPool getArrayPool() { return arrayPool; } @@ -486,6 +490,7 @@ public ArrayPool getArrayPool() { /** * @return The context associated with this instance. */ + @NonNull public Context getContext() { return glideContext.getBaseContext(); } @@ -494,6 +499,7 @@ ConnectivityMonitorFactory getConnectivityMonitorFactory() { return connectivityMonitorFactory; } + @NonNull GlideContext getGlideContext() { return glideContext; } @@ -523,7 +529,7 @@ GlideContext getGlideContext() { * {@link com.bumptech.glide.load.engine.prefill.PreFillType.Builder Builders} representing * individual sizes and configurations of {@link android.graphics.Bitmap}s to be pre-filled. */ - public void preFillBitmapPool(PreFillType.Builder... bitmapAttributeBuilders) { + public void preFillBitmapPool(@NonNull PreFillType.Builder... bitmapAttributeBuilders) { bitmapPreFiller.preFill(bitmapAttributeBuilders); } @@ -573,6 +579,7 @@ public void clearDiskCache() { /** * Internal method. */ + @NonNull public RequestManagerRetriever getRequestManagerRetriever() { return requestManagerRetriever; } @@ -589,7 +596,8 @@ public RequestManagerRetriever getRequestManagerRetriever() { * * @return the previous MemoryCategory used by Glide. */ - public MemoryCategory setMemoryCategory(MemoryCategory memoryCategory) { + @NonNull + public MemoryCategory setMemoryCategory(@NonNull MemoryCategory memoryCategory) { // Engine asserts this anyway when removing resources, fail faster and consistently Util.assertMainThread(); // memory cache needs to be trimmed before bitmap pool to trim re-pooled Bitmaps too. See #687. @@ -600,6 +608,7 @@ public MemoryCategory setMemoryCategory(MemoryCategory memoryCategory) { return oldCategory; } + @NonNull private static RequestManagerRetriever getRetriever(@Nullable Context context) { // Context could be null for other reasons (ie the user passes in null), but in practice it will // only occur due to errors with the Fragment lifecycle. @@ -633,7 +642,8 @@ private static RequestManagerRetriever getRetriever(@Nullable Context context) { * @see #with(android.support.v4.app.Fragment) * @see #with(android.support.v4.app.FragmentActivity) */ - public static RequestManager with(Context context) { + @NonNull + public static RequestManager with(@NonNull Context context) { return getRetriever(context).get(context); } @@ -644,7 +654,8 @@ public static RequestManager with(Context context) { * @param activity The activity to use. * @return A RequestManager for the given activity that can be used to start a load. */ - public static RequestManager with(Activity activity) { + @NonNull + public static RequestManager with(@NonNull Activity activity) { return getRetriever(activity).get(activity); } @@ -656,7 +667,8 @@ public static RequestManager with(Activity activity) { * @param activity The activity to use. * @return A RequestManager for the given FragmentActivity that can be used to start a load. */ - public static RequestManager with(FragmentActivity activity) { + @NonNull + public static RequestManager with(@NonNull FragmentActivity activity) { return getRetriever(activity).get(activity); } @@ -667,7 +679,8 @@ public static RequestManager with(FragmentActivity activity) { * @param fragment The fragment to use. * @return A RequestManager for the given Fragment that can be used to start a load. */ - public static RequestManager with(android.app.Fragment fragment) { + @NonNull + public static RequestManager with(@NonNull android.app.Fragment fragment) { return getRetriever(fragment.getActivity()).get(fragment); } @@ -679,7 +692,8 @@ public static RequestManager with(android.app.Fragment fragment) { * @param fragment The fragment to use. * @return A RequestManager for the given Fragment that can be used to start a load. */ - public static RequestManager with(Fragment fragment) { + @NonNull + public static RequestManager with(@NonNull Fragment fragment) { return getRetriever(fragment.getActivity()).get(fragment); } @@ -708,15 +722,17 @@ public static RequestManager with(Fragment fragment) { * @param view The view to search for a containing Fragment or Activity from. * @return A RequestManager that can be used to start a load. */ - public static RequestManager with(View view) { + @NonNull + public static RequestManager with(@NonNull View view) { return getRetriever(view.getContext()).get(view); } + @NonNull public Registry getRegistry() { return registry; } - boolean removeFromManagers(Target target) { + boolean removeFromManagers(@NonNull Target target) { synchronized (managers) { for (RequestManager requestManager : managers) { if (requestManager.untrack(target)) { diff --git a/library/src/main/java/com/bumptech/glide/GlideBuilder.java b/library/src/main/java/com/bumptech/glide/GlideBuilder.java index f3dd75777d..ce908233b3 100644 --- a/library/src/main/java/com/bumptech/glide/GlideBuilder.java +++ b/library/src/main/java/com/bumptech/glide/GlideBuilder.java @@ -55,7 +55,8 @@ public final class GlideBuilder { * @param bitmapPool The pool to use. * @return This builder. */ - public GlideBuilder setBitmapPool(BitmapPool bitmapPool) { + @NonNull + public GlideBuilder setBitmapPool(@Nullable BitmapPool bitmapPool) { this.bitmapPool = bitmapPool; return this; } @@ -67,7 +68,8 @@ public GlideBuilder setBitmapPool(BitmapPool bitmapPool) { * @param arrayPool The pool to use. * @return This builder. */ - public GlideBuilder setArrayPool(ArrayPool arrayPool) { + @NonNull + public GlideBuilder setArrayPool(@Nullable ArrayPool arrayPool) { this.arrayPool = arrayPool; return this; } @@ -79,7 +81,8 @@ public GlideBuilder setArrayPool(ArrayPool arrayPool) { * @param memoryCache The cache to use. * @return This builder. */ - public GlideBuilder setMemoryCache(MemoryCache memoryCache) { + @NonNull + public GlideBuilder setMemoryCache(@Nullable MemoryCache memoryCache) { this.memoryCache = memoryCache; return this; } @@ -112,7 +115,8 @@ public DiskCache build() { * @param diskCacheFactory The disk cache factory to use. * @return This builder. */ - public GlideBuilder setDiskCache(DiskCache.Factory diskCacheFactory) { + @NonNull + public GlideBuilder setDiskCache(@Nullable DiskCache.Factory diskCacheFactory) { this.diskCacheFactory = diskCacheFactory; return this; } @@ -135,7 +139,7 @@ public GlideBuilder setDiskCache(DiskCache.Factory diskCacheFactory) { * @deprecated Use {@link #setSourceExecutor(GlideExecutor)} */ @Deprecated - public GlideBuilder setResizeExecutor(GlideExecutor service) { + public GlideBuilder setResizeExecutor(@Nullable GlideExecutor service) { return setSourceExecutor(service); } @@ -154,7 +158,8 @@ public GlideBuilder setResizeExecutor(GlideExecutor service) { * @see #setDiskCacheExecutor(GlideExecutor) * @see GlideExecutor */ - public GlideBuilder setSourceExecutor(GlideExecutor service) { + @NonNull + public GlideBuilder setSourceExecutor(@Nullable GlideExecutor service) { this.sourceExecutor = service; return this; } @@ -174,7 +179,8 @@ public GlideBuilder setSourceExecutor(GlideExecutor service) { * @see #setSourceExecutor(GlideExecutor) * @see GlideExecutor */ - public GlideBuilder setDiskCacheExecutor(GlideExecutor service) { + @NonNull + public GlideBuilder setDiskCacheExecutor(@Nullable GlideExecutor service) { this.diskCacheExecutor = service; return this; } @@ -191,7 +197,8 @@ public GlideBuilder setDiskCacheExecutor(GlideExecutor service) { * @param service The {@link GlideExecutor} to use. * @return This builder. */ - public GlideBuilder setAnimationExecutor(GlideExecutor service) { + @NonNull + public GlideBuilder setAnimationExecutor(@Nullable GlideExecutor service) { this.animationExecutor = service; return this; } @@ -206,7 +213,8 @@ public GlideBuilder setAnimationExecutor(GlideExecutor service) { * @param requestOptions The options to use by default. * @return This builder. */ - public GlideBuilder setDefaultRequestOptions(RequestOptions requestOptions) { + @NonNull + public GlideBuilder setDefaultRequestOptions(@Nullable RequestOptions requestOptions) { this.defaultRequestOptions = requestOptions; return this; } @@ -227,6 +235,7 @@ public GlideBuilder setDefaultRequestOptions(RequestOptions requestOptions) { * {@link android.graphics.drawable.BitmapDrawable}s, the transition you registered for * {@link android.graphics.drawable.BitmapDrawable}s will be used. */ + @NonNull public GlideBuilder setDefaultTransitionOptions( @NonNull Class clazz, @Nullable TransitionOptions options) { defaultTransitionOptions.put(clazz, options); @@ -261,7 +270,8 @@ public GlideBuilder setDecodeFormat(DecodeFormat decodeFormat) { * @param builder The builder to use (will not be modified). * @return This builder. */ - public GlideBuilder setMemorySizeCalculator(MemorySizeCalculator.Builder builder) { + @NonNull + public GlideBuilder setMemorySizeCalculator(@NonNull MemorySizeCalculator.Builder builder) { return setMemorySizeCalculator(builder.build()); } @@ -275,7 +285,8 @@ public GlideBuilder setMemorySizeCalculator(MemorySizeCalculator.Builder builder * @param calculator The calculator to use. * @return This builder. */ - public GlideBuilder setMemorySizeCalculator(MemorySizeCalculator calculator) { + @NonNull + public GlideBuilder setMemorySizeCalculator(@Nullable MemorySizeCalculator calculator) { this.memorySizeCalculator = calculator; return this; } @@ -288,7 +299,8 @@ public GlideBuilder setMemorySizeCalculator(MemorySizeCalculator calculator) { * @param factory The factory to use * @return This builder. */ - public GlideBuilder setConnectivityMonitorFactory(ConnectivityMonitorFactory factory) { + @NonNull + public GlideBuilder setConnectivityMonitorFactory(@Nullable ConnectivityMonitorFactory factory) { this.connectivityMonitorFactory = factory; return this; } @@ -318,6 +330,7 @@ public GlideBuilder setConnectivityMonitorFactory(ConnectivityMonitorFactory fac * @param logLevel The log level to use from {@link Log}. * @return This builder. */ + @NonNull public GlideBuilder setLogLevel(int logLevel) { if (logLevel < Log.VERBOSE || logLevel > Log.ERROR) { throw new IllegalArgumentException("Log level must be one of Log.VERBOSE, Log.DEBUG," @@ -360,6 +373,7 @@ public GlideBuilder setLogLevel(int logLevel) { * * @return This builder. */ + @NonNull public GlideBuilder setIsActiveResourceRetentionAllowed( boolean isActiveResourceRetentionAllowed) { this.isActiveResourceRetentionAllowed = isActiveResourceRetentionAllowed; @@ -376,7 +390,8 @@ GlideBuilder setEngine(Engine engine) { return this; } - public Glide build(Context context) { + @NonNull + public Glide build(@NonNull Context context) { if (sourceExecutor == null) { sourceExecutor = GlideExecutor.newSourceExecutor(); } diff --git a/library/src/main/java/com/bumptech/glide/GlideContext.java b/library/src/main/java/com/bumptech/glide/GlideContext.java index 257ac88897..eeb98cc5f7 100644 --- a/library/src/main/java/com/bumptech/glide/GlideContext.java +++ b/library/src/main/java/com/bumptech/glide/GlideContext.java @@ -33,13 +33,13 @@ public class GlideContext extends ContextWrapper { private final int logLevel; public GlideContext( - Context context, - ArrayPool arrayPool, - Registry registry, - ImageViewTargetFactory imageViewTargetFactory, - RequestOptions defaultRequestOptions, - Map, TransitionOptions> defaultTransitionOptions, - Engine engine, + @NonNull Context context, + @NonNull ArrayPool arrayPool, + @NonNull Registry registry, + @NonNull ImageViewTargetFactory imageViewTargetFactory, + @NonNull RequestOptions defaultRequestOptions, + @NonNull Map, TransitionOptions> defaultTransitionOptions, + @NonNull Engine engine, int logLevel) { super(context.getApplicationContext()); this.arrayPool = arrayPool; @@ -59,7 +59,7 @@ public RequestOptions getDefaultRequestOptions() { @SuppressWarnings("unchecked") @NonNull - public TransitionOptions getDefaultTransitionOptions(Class transcodeClass) { + public TransitionOptions getDefaultTransitionOptions(@NonNull Class transcodeClass) { TransitionOptions result = defaultTransitionOptions.get(transcodeClass); if (result == null) { for (Entry, TransitionOptions> value : defaultTransitionOptions.entrySet()) { @@ -74,19 +74,23 @@ public TransitionOptions getDefaultTransitionOptions(Class transcod return (TransitionOptions) result; } + @NonNull public ViewTarget buildImageViewTarget( - ImageView imageView, Class transcodeClass) { + @NonNull ImageView imageView, @NonNull Class transcodeClass) { return imageViewTargetFactory.buildTarget(imageView, transcodeClass); } + @NonNull public Handler getMainHandler() { return mainHandler; } + @NonNull public Engine getEngine() { return engine; } + @NonNull public Registry getRegistry() { return registry; } @@ -95,6 +99,7 @@ public int getLogLevel() { return logLevel; } + @NonNull public ArrayPool getArrayPool() { return arrayPool; } diff --git a/library/src/main/java/com/bumptech/glide/ModelTypes.java b/library/src/main/java/com/bumptech/glide/ModelTypes.java index 71c77fb1c8..42a14053e9 100644 --- a/library/src/main/java/com/bumptech/glide/ModelTypes.java +++ b/library/src/main/java/com/bumptech/glide/ModelTypes.java @@ -5,6 +5,7 @@ import android.net.Uri; import android.support.annotation.CheckResult; import android.support.annotation.DrawableRes; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.RawRes; import java.io.File; @@ -15,21 +16,27 @@ * API surface. */ interface ModelTypes { + @NonNull @CheckResult T load(@Nullable Bitmap bitmap); + @NonNull @CheckResult - T load(@Nullable Drawable drawable); + T load(@Nullable Drawable drawable); + @NonNull @CheckResult T load(@Nullable String string); + @NonNull @CheckResult T load(@Nullable Uri uri); + @NonNull @CheckResult T load(@Nullable File file); + @NonNull @CheckResult T load(@RawRes @DrawableRes @Nullable Integer resourceId); @@ -37,9 +44,11 @@ interface ModelTypes { @CheckResult T load(@Nullable URL url); + @NonNull @CheckResult - T load(@Nullable byte[] model); + T load(@Nullable byte[] model); + @NonNull @CheckResult @SuppressWarnings("unchecked") T load(@Nullable Object model); diff --git a/library/src/main/java/com/bumptech/glide/RequestBuilder.java b/library/src/main/java/com/bumptech/glide/RequestBuilder.java index 37ab7dd7cf..7012ec3a75 100644 --- a/library/src/main/java/com/bumptech/glide/RequestBuilder.java +++ b/library/src/main/java/com/bumptech/glide/RequestBuilder.java @@ -99,6 +99,7 @@ protected RequestBuilder(Class transcodeClass, RequestBuilder * @see RequestOptions#apply(RequestOptions) * @return This request builder. */ + @NonNull @CheckResult public RequestBuilder apply(@NonNull RequestOptions requestOptions) { Preconditions.checkNotNull(requestOptions); @@ -106,6 +107,7 @@ public RequestBuilder apply(@NonNull RequestOptions requestOption return this; } + @NonNull protected RequestOptions getMutableOptions() { return defaultRequestOptions == this.requestOptions ? this.requestOptions.clone() : this.requestOptions; @@ -120,6 +122,7 @@ protected RequestOptions getMutableOptions() { * * @return This request builder. */ + @NonNull @CheckResult public RequestBuilder transition( @NonNull TransitionOptions transitionOptions) { @@ -136,6 +139,7 @@ public RequestBuilder transition( * @param requestListener The request listener to use. * @return This request builder. */ + @NonNull @CheckResult @SuppressWarnings("unchecked") public RequestBuilder listener( @@ -167,6 +171,7 @@ public RequestBuilder listener( * * @return This {@link RequestBuilder}. */ + @NonNull public RequestBuilder error(@Nullable RequestBuilder errorBuilder) { this.errorBuilder = errorBuilder; return this; @@ -190,6 +195,7 @@ public RequestBuilder error(@Nullable RequestBuilder thumbnail( @@ -228,6 +234,7 @@ public RequestBuilder thumbnail( * @return This request builder. */ @SuppressWarnings({"CheckResult", "unchecked"}) + @NonNull @CheckResult public RequestBuilder thumbnail( @Nullable RequestBuilder... thumbnails) { @@ -289,6 +296,7 @@ public RequestBuilder thumbnail( * the thumbnail. * @return This request builder. */ + @NonNull @CheckResult @SuppressWarnings("unchecked") public RequestBuilder thumbnail(float sizeMultiplier) { @@ -306,6 +314,7 @@ public RequestBuilder thumbnail(float sizeMultiplier) { * @param model The model to load data for, or null. * @return This request builder. */ + @NonNull @CheckResult @SuppressWarnings("unchecked") @Override @@ -313,6 +322,7 @@ public RequestBuilder load(@Nullable Object model) { return loadGeneric(model); } + @NonNull private RequestBuilder loadGeneric(@Nullable Object model) { this.model = model; isModelSet = true; @@ -337,6 +347,7 @@ private RequestBuilder loadGeneric(@Nullable Object model) { * * @see #load(Object) */ + @NonNull @CheckResult @Override public RequestBuilder load(@Nullable Bitmap bitmap) { @@ -363,6 +374,7 @@ public RequestBuilder load(@Nullable Bitmap bitmap) { * * @see #load(Object) */ + @NonNull @CheckResult @Override public RequestBuilder load(@Nullable Drawable drawable) { @@ -389,6 +401,7 @@ public RequestBuilder load(@Nullable Drawable drawable) { * @param string A file path, or a uri or url handled by * {@link com.bumptech.glide.load.model.UriLoader}. */ + @NonNull @Override @CheckResult public RequestBuilder load(@Nullable String string) { @@ -413,6 +426,7 @@ public RequestBuilder load(@Nullable String string) { * @param uri The Uri representing the image. Must be of a type handled by * {@link com.bumptech.glide.load.model.UriLoader}. */ + @NonNull @CheckResult @Override public RequestBuilder load(@Nullable Uri uri) { @@ -436,6 +450,7 @@ public RequestBuilder load(@Nullable Uri uri) { * * @param file The File containing the image */ + @NonNull @CheckResult @Override public RequestBuilder load(@Nullable File file) { @@ -474,6 +489,7 @@ public RequestBuilder load(@Nullable File file) { * @see #load(Integer) * @see com.bumptech.glide.signature.ApplicationVersionSignature */ + @NonNull @CheckResult @Override public RequestBuilder load(@RawRes @DrawableRes @Nullable Integer resourceId) { @@ -504,6 +520,7 @@ public RequestBuilder load(@Nullable URL url) { * @param model the data to load. * @see #load(Object) */ + @NonNull @CheckResult @Override public RequestBuilder load(@Nullable byte[] model) { @@ -546,10 +563,12 @@ public RequestBuilder clone() { * @return The given target. * @see RequestManager#clear(Target) */ + @NonNull public > Y into(@NonNull Y target) { return into(target, /*targetListener=*/ null); } + @NonNull private > Y into( @NonNull Y target, @Nullable RequestListener targetListener) { @@ -559,7 +578,7 @@ private > Y into( private > Y into( @NonNull Y target, @Nullable RequestListener targetListener, - RequestOptions options) { + @NonNull RequestOptions options) { Util.assertMainThread(); Preconditions.checkNotNull(target); if (!isModelSet) { @@ -614,7 +633,8 @@ private boolean isSkipMemoryCacheWithCompletePreviousRequest( * @return The * {@link com.bumptech.glide.request.target.Target} used to wrap the given {@link ImageView}. */ - public ViewTarget into(ImageView view) { + @NonNull + public ViewTarget into(@NonNull ImageView view) { Util.assertMainThread(); Preconditions.checkNotNull(view); @@ -685,6 +705,7 @@ public FutureTarget into(int width, int height) { * @see #submit(int, int) * @see #into(Target) */ + @NonNull public FutureTarget submit() { return submit(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL); } @@ -701,6 +722,7 @@ public FutureTarget submit() { * {@link com.bumptech.glide.request.RequestOptions#override(int, int)}} if * previously called). */ + @NonNull public FutureTarget submit(int width, int height) { final RequestFutureTarget target = new RequestFutureTarget<>(glideContext.getMainHandler(), width, height); @@ -739,6 +761,7 @@ public void run() { * {@link RequestManager#clear(Target)}. * @see com.bumptech.glide.ListPreloader */ + @NonNull public Target preload(int width, int height) { final PreloadTarget target = PreloadTarget.obtain(requestManager, width, height); return into(target); @@ -753,6 +776,7 @@ public Target preload(int width, int height) { * {@link RequestManager#clear(Target)} * @see #preload(int, int) */ + @NonNull public Target preload() { return preload(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL); } @@ -769,7 +793,7 @@ public Target preload() { */ @Deprecated @CheckResult - public > Y downloadOnly(Y target) { + public > Y downloadOnly(@NonNull Y target) { return getDownloadOnlyRequest().into(target); } @@ -791,12 +815,14 @@ public FutureTarget downloadOnly(int width, int height) { return getDownloadOnlyRequest().submit(width, height); } + @NonNull @CheckResult protected RequestBuilder getDownloadOnlyRequest() { return new RequestBuilder<>(File.class, this).apply(DOWNLOAD_ONLY_OPTIONS); } - private Priority getThumbnailPriority(Priority current) { + @NonNull + private Priority getThumbnailPriority(@NonNull Priority current) { switch (current) { case LOW: return Priority.NORMAL; diff --git a/library/src/main/java/com/bumptech/glide/RequestManager.java b/library/src/main/java/com/bumptech/glide/RequestManager.java index 63af009a9e..d4553d1c70 100644 --- a/library/src/main/java/com/bumptech/glide/RequestManager.java +++ b/library/src/main/java/com/bumptech/glide/RequestManager.java @@ -71,7 +71,8 @@ public void run() { private RequestOptions requestOptions; public RequestManager( - Glide glide, Lifecycle lifecycle, RequestManagerTreeNode treeNode, Context context) { + @NonNull Glide glide, @NonNull Lifecycle lifecycle, + @NonNull RequestManagerTreeNode treeNode, @NonNull Context context) { this( glide, lifecycle, @@ -121,7 +122,7 @@ protected void setRequestOptions(@NonNull RequestOptions toSet) { requestOptions = toSet.clone().autoClone(); } - private void updateRequestOptions(RequestOptions toUpdate) { + private void updateRequestOptions(@NonNull RequestOptions toUpdate) { requestOptions = requestOptions.apply(toUpdate); } @@ -143,7 +144,8 @@ private void updateRequestOptions(RequestOptions toUpdate) { * * @return This request manager. */ - public RequestManager applyDefaultRequestOptions(RequestOptions requestOptions) { + @NonNull + public RequestManager applyDefaultRequestOptions(@NonNull RequestOptions requestOptions) { updateRequestOptions(requestOptions); return this; } @@ -164,7 +166,8 @@ public RequestManager applyDefaultRequestOptions(RequestOptions requestOptions) * * @return This request manager. */ - public RequestManager setDefaultRequestOptions(RequestOptions requestOptions) { + @NonNull + public RequestManager setDefaultRequestOptions(@NonNull RequestOptions requestOptions) { setRequestOptions(requestOptions); return this; } @@ -333,6 +336,7 @@ public void onDestroy() { * * @return A new request builder for loading a {@link android.graphics.Bitmap} */ + @NonNull @CheckResult public RequestBuilder asBitmap() { return as(Bitmap.class).apply(DECODE_TYPE_BITMAP); @@ -351,6 +355,7 @@ public RequestBuilder asBitmap() { * @return A new request builder for loading a * {@link com.bumptech.glide.load.resource.gif.GifDrawable}. */ + @NonNull @CheckResult public RequestBuilder asGif() { return as(GifDrawable.class).apply(DECODE_TYPE_GIF); @@ -366,6 +371,7 @@ public RequestBuilder asGif() { * * @return A new request builder for loading a {@link Drawable}. */ + @NonNull @CheckResult public RequestBuilder asDrawable() { return as(Drawable.class); @@ -376,6 +382,7 @@ public RequestBuilder asDrawable() { * * @return A new request builder for loading a {@link Drawable} using the given model. */ + @NonNull @CheckResult @Override public RequestBuilder load(@Nullable Bitmap bitmap) { @@ -387,6 +394,7 @@ public RequestBuilder load(@Nullable Bitmap bitmap) { * * @return A new request builder for loading a {@link Drawable} using the given model. */ + @NonNull @CheckResult @Override public RequestBuilder load(@Nullable Drawable drawable) { @@ -398,6 +406,7 @@ public RequestBuilder load(@Nullable Drawable drawable) { * * @return A new request builder for loading a {@link Drawable} using the given model. */ + @NonNull @CheckResult @Override public RequestBuilder load(@Nullable String string) { @@ -409,6 +418,7 @@ public RequestBuilder load(@Nullable String string) { * * @return A new request builder for loading a {@link Drawable} using the given model. */ + @NonNull @CheckResult @Override public RequestBuilder load(@Nullable Uri uri) { @@ -420,6 +430,7 @@ public RequestBuilder load(@Nullable Uri uri) { * * @return A new request builder for loading a {@link Drawable} using the given model. */ + @NonNull @CheckResult @Override public RequestBuilder load(@Nullable File file) { @@ -432,6 +443,7 @@ public RequestBuilder load(@Nullable File file) { * @return A new request builder for loading a {@link Drawable} using the given model. */ @SuppressWarnings("deprecation") + @NonNull @CheckResult @Override public RequestBuilder load(@Nullable Integer resourceId) { @@ -457,6 +469,7 @@ public RequestBuilder load(@Nullable URL url) { * * @return A new request builder for loading a {@link Drawable} using the given model. */ + @NonNull @CheckResult @Override public RequestBuilder load(@Nullable byte[] model) { @@ -469,6 +482,7 @@ public RequestBuilder load(@Nullable byte[] model) { * * @return A new request builder for loading a {@link Drawable} using the given model. */ + @NonNull @CheckResult @Override public RequestBuilder load(@Nullable Object model) { @@ -486,6 +500,7 @@ public RequestBuilder load(@Nullable Object model) { * * @return A new request builder for downloading content to cache and returning the cache File. */ + @NonNull @CheckResult public RequestBuilder downloadOnly() { return as(File.class).apply(DOWNLOAD_ONLY_OPTIONS); @@ -497,6 +512,7 @@ public RequestBuilder downloadOnly() { * * @return A new request builder for loading a {@link Drawable} using the given model. */ + @NonNull @CheckResult public RequestBuilder download(@Nullable Object model) { return downloadOnly().load(model); @@ -511,6 +527,7 @@ public RequestBuilder download(@Nullable Object model) { * * @return A new request builder for obtaining File paths to content. */ + @NonNull @CheckResult public RequestBuilder asFile() { return as(File.class).apply(skipMemoryCacheOf(true)); @@ -524,8 +541,10 @@ public RequestBuilder asFile() { * @param resourceClass The resource to decode. * @return A new request builder for loading the given resource class. */ + @NonNull @CheckResult - public RequestBuilder as(Class resourceClass) { + public RequestBuilder as( + @NonNull Class resourceClass) { return new RequestBuilder<>(glide, this, resourceClass, context); } @@ -541,7 +560,7 @@ public RequestBuilder as(Class resour * tag. * @see #clear(Target) */ - public void clear(View view) { + public void clear(@NonNull View view) { clear(new ClearTarget(view)); } @@ -568,7 +587,7 @@ public void run() { } } - private void untrackOrDelegate(Target target) { + private void untrackOrDelegate(@NonNull Target target) { boolean isOwnedByUs = untrack(target); // We'll end up here if the Target was cleared after the RequestManager that started the request // is destroyed. That can happen for at least two reasons: @@ -594,7 +613,7 @@ private void untrackOrDelegate(Target target) { } } - boolean untrack(Target target) { + boolean untrack(@NonNull Target target) { Request request = target.getRequest(); // If the Target doesn't have a request, it's already been cleared. if (request == null) { @@ -633,7 +652,7 @@ private static class RequestManagerConnectivityListener implements ConnectivityM .ConnectivityListener { private final RequestTracker requestTracker; - RequestManagerConnectivityListener(RequestTracker requestTracker) { + RequestManagerConnectivityListener(@NonNull RequestTracker requestTracker) { this.requestTracker = requestTracker; } @@ -647,7 +666,7 @@ public void onConnectivityChanged(boolean isConnected) { private static class ClearTarget extends ViewTarget { - ClearTarget(View view) { + ClearTarget(@NonNull View view) { super(view); } diff --git a/library/src/main/java/com/bumptech/glide/TransitionOptions.java b/library/src/main/java/com/bumptech/glide/TransitionOptions.java index 51ec4a1d1d..99eda46dd0 100644 --- a/library/src/main/java/com/bumptech/glide/TransitionOptions.java +++ b/library/src/main/java/com/bumptech/glide/TransitionOptions.java @@ -1,5 +1,6 @@ package com.bumptech.glide; +import android.support.annotation.NonNull; import com.bumptech.glide.request.transition.NoTransition; import com.bumptech.glide.request.transition.TransitionFactory; import com.bumptech.glide.request.transition.ViewAnimationFactory; @@ -23,6 +24,7 @@ public abstract class TransitionOptions(viewAnimationId)); } @@ -49,7 +52,8 @@ public final CHILD transition(int viewAnimationId) { * .Animator} to run. * @return This request builder. */ - public final CHILD transition(ViewPropertyTransition.Animator animator) { + @NonNull + public final CHILD transition(@NonNull ViewPropertyTransition.Animator animator) { return transition(new ViewPropertyAnimationFactory<>(animator)); } @@ -60,7 +64,9 @@ public final CHILD transition(ViewPropertyTransition.Animator animator) { * * @return This request builder. */ - public final CHILD transition(TransitionFactory transitionFactory) { + @NonNull + public final CHILD transition( + @NonNull TransitionFactory transitionFactory) { this.transitionFactory = Preconditions.checkNotNull(transitionFactory); return self(); } diff --git a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/BitmapTransitionOptions.java b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/BitmapTransitionOptions.java index 1d6b8874f5..e5e335bc4b 100644 --- a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/BitmapTransitionOptions.java +++ b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/BitmapTransitionOptions.java @@ -2,6 +2,7 @@ import android.graphics.Bitmap; import android.graphics.drawable.Drawable; +import android.support.annotation.NonNull; import com.bumptech.glide.TransitionOptions; import com.bumptech.glide.request.transition.BitmapTransitionFactory; import com.bumptech.glide.request.transition.DrawableCrossFadeFactory; @@ -20,6 +21,7 @@ public final class BitmapTransitionOptions extends * * @see #crossFade() */ + @NonNull public static BitmapTransitionOptions withCrossFade() { return new BitmapTransitionOptions().crossFade(); } @@ -29,6 +31,7 @@ public static BitmapTransitionOptions withCrossFade() { * * @see #crossFade(int) */ + @NonNull public static BitmapTransitionOptions withCrossFade(int duration) { return new BitmapTransitionOptions().crossFade(duration); } @@ -38,8 +41,9 @@ public static BitmapTransitionOptions withCrossFade(int duration) { * * @see #crossFade(DrawableCrossFadeFactory) */ + @NonNull public static BitmapTransitionOptions withCrossFade( - DrawableCrossFadeFactory drawableCrossFadeFactory) { + @NonNull DrawableCrossFadeFactory drawableCrossFadeFactory) { return new BitmapTransitionOptions().crossFade(drawableCrossFadeFactory); } @@ -48,8 +52,9 @@ public static BitmapTransitionOptions withCrossFade( * * @see #crossFade(DrawableCrossFadeFactory.Builder) */ + @NonNull public static BitmapTransitionOptions withCrossFade( - DrawableCrossFadeFactory.Builder builder) { + @NonNull DrawableCrossFadeFactory.Builder builder) { return new BitmapTransitionOptions().crossFade(builder); } @@ -59,8 +64,9 @@ public static BitmapTransitionOptions withCrossFade( * * @see #transitionUsing(TransitionFactory) */ + @NonNull public static BitmapTransitionOptions withWrapped( - TransitionFactory drawableCrossFadeFactory) { + @NonNull TransitionFactory drawableCrossFadeFactory) { return new BitmapTransitionOptions().transitionUsing(drawableCrossFadeFactory); } @@ -69,8 +75,9 @@ public static BitmapTransitionOptions withWrapped( * * @see com.bumptech.glide.GenericTransitionOptions#with(TransitionFactory) */ + @NonNull public static BitmapTransitionOptions with( - TransitionFactory transitionFactory) { + @NonNull TransitionFactory transitionFactory) { return new BitmapTransitionOptions().transition(transitionFactory); } @@ -78,6 +85,7 @@ public static BitmapTransitionOptions with( * Enables a cross fade animation between both the placeholder and the first resource and between * subsequent resources (if thumbnails are used). */ + @NonNull public BitmapTransitionOptions crossFade() { return crossFade(new DrawableCrossFadeFactory.Builder()); } @@ -90,6 +98,7 @@ public BitmapTransitionOptions crossFade() { * {@code DrawableCrossFadeFactory.Builder(int)}. * @see com.bumptech.glide.request.transition.DrawableCrossFadeFactory.Builder */ + @NonNull public BitmapTransitionOptions crossFade(int duration) { return crossFade(new DrawableCrossFadeFactory.Builder(duration)); } @@ -98,15 +107,18 @@ public BitmapTransitionOptions crossFade(int duration) { * Enables a cross fade animation between both the placeholder and the first resource and between * subsequent resources (if thumbnails are used). */ - public BitmapTransitionOptions crossFade(DrawableCrossFadeFactory drawableCrossFadeFactory) { + @NonNull + public BitmapTransitionOptions crossFade( + @NonNull DrawableCrossFadeFactory drawableCrossFadeFactory) { return transitionUsing(drawableCrossFadeFactory); } /** * Enables a any Drawable based animation to run on Bitmaps as well. */ + @NonNull public BitmapTransitionOptions transitionUsing( - TransitionFactory drawableCrossFadeFactory) { + @NonNull TransitionFactory drawableCrossFadeFactory) { return transition(new BitmapTransitionFactory(drawableCrossFadeFactory)); } @@ -114,7 +126,8 @@ public BitmapTransitionOptions transitionUsing( * Enables a cross fade animation between both the placeholder and the first resource and between * subsequent resources (if thumbnails are used). */ - public BitmapTransitionOptions crossFade(DrawableCrossFadeFactory.Builder builder) { + @NonNull + public BitmapTransitionOptions crossFade(@NonNull DrawableCrossFadeFactory.Builder builder) { return transitionUsing(builder.build()); } } diff --git a/library/src/main/java/com/bumptech/glide/load/resource/drawable/DrawableTransitionOptions.java b/library/src/main/java/com/bumptech/glide/load/resource/drawable/DrawableTransitionOptions.java index 7d255cf1a0..8eec675619 100644 --- a/library/src/main/java/com/bumptech/glide/load/resource/drawable/DrawableTransitionOptions.java +++ b/library/src/main/java/com/bumptech/glide/load/resource/drawable/DrawableTransitionOptions.java @@ -1,6 +1,7 @@ package com.bumptech.glide.load.resource.drawable; import android.graphics.drawable.Drawable; +import android.support.annotation.NonNull; import com.bumptech.glide.TransitionOptions; import com.bumptech.glide.request.transition.DrawableCrossFadeFactory; import com.bumptech.glide.request.transition.TransitionFactory; @@ -18,6 +19,7 @@ public final class DrawableTransitionOptions extends * * @see #crossFade() */ + @NonNull public static DrawableTransitionOptions withCrossFade() { return new DrawableTransitionOptions().crossFade(); } @@ -27,6 +29,7 @@ public static DrawableTransitionOptions withCrossFade() { * * @see #crossFade(int) */ + @NonNull public static DrawableTransitionOptions withCrossFade(int duration) { return new DrawableTransitionOptions().crossFade(duration); } @@ -36,8 +39,9 @@ public static DrawableTransitionOptions withCrossFade(int duration) { * * @see #crossFade(DrawableCrossFadeFactory) */ + @NonNull public static DrawableTransitionOptions withCrossFade( - DrawableCrossFadeFactory drawableCrossFadeFactory) { + @NonNull DrawableCrossFadeFactory drawableCrossFadeFactory) { return new DrawableTransitionOptions().crossFade(drawableCrossFadeFactory); } @@ -46,8 +50,9 @@ public static DrawableTransitionOptions withCrossFade( * * @see #crossFade(DrawableCrossFadeFactory.Builder) */ + @NonNull public static DrawableTransitionOptions withCrossFade( - DrawableCrossFadeFactory.Builder builder) { + @NonNull DrawableCrossFadeFactory.Builder builder) { return new DrawableTransitionOptions().crossFade(builder); } @@ -56,8 +61,9 @@ public static DrawableTransitionOptions withCrossFade( * * @see com.bumptech.glide.GenericTransitionOptions#with(TransitionFactory) */ + @NonNull public static DrawableTransitionOptions with( - TransitionFactory transitionFactory) { + @NonNull TransitionFactory transitionFactory) { return new DrawableTransitionOptions().transition(transitionFactory); } @@ -65,6 +71,7 @@ public static DrawableTransitionOptions with( * Enables a cross fade animation between both the placeholder and the first resource and between * subsequent resources (if thumbnails are used). */ + @NonNull public DrawableTransitionOptions crossFade() { return crossFade(new DrawableCrossFadeFactory.Builder()); } @@ -77,6 +84,7 @@ public DrawableTransitionOptions crossFade() { * {@code DrawableCrossFadeFactory.Builder(int)} * @see com.bumptech.glide.request.transition.DrawableCrossFadeFactory.Builder */ + @NonNull public DrawableTransitionOptions crossFade(int duration) { return crossFade(new DrawableCrossFadeFactory.Builder(duration)); } @@ -85,7 +93,9 @@ public DrawableTransitionOptions crossFade(int duration) { * Enables a cross fade animation between both the placeholder and the first resource and between * subsequent resources (if thumbnails are used). */ - public DrawableTransitionOptions crossFade(DrawableCrossFadeFactory drawableCrossFadeFactory) { + @NonNull + public DrawableTransitionOptions crossFade( + @NonNull DrawableCrossFadeFactory drawableCrossFadeFactory) { return transition(drawableCrossFadeFactory); } @@ -93,7 +103,8 @@ public DrawableTransitionOptions crossFade(DrawableCrossFadeFactory drawableCros * Enables a cross fade animation between both the placeholder and the first resource and between * subsequent resources (if thumbnails are used). */ - public DrawableTransitionOptions crossFade(DrawableCrossFadeFactory.Builder builder) { + @NonNull + public DrawableTransitionOptions crossFade(@NonNull DrawableCrossFadeFactory.Builder builder) { return crossFade(builder.build()); } } 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 04406f270e..8465e2bab8 100644 --- a/library/src/main/java/com/bumptech/glide/manager/RequestManagerRetriever.java +++ b/library/src/main/java/com/bumptech/glide/manager/RequestManagerRetriever.java @@ -12,6 +12,7 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.v4.app.Fragment; @@ -79,7 +80,7 @@ public RequestManagerRetriever(@Nullable RequestManagerFactory factory) { handler = new Handler(Looper.getMainLooper(), this /* Callback */); } - private RequestManager getApplicationManager(Context context) { + private RequestManager getApplicationManager(@NonNull Context context) { // Either an application context or we're on a background thread. if (applicationManager == null) { synchronized (this) { @@ -104,7 +105,8 @@ private RequestManager getApplicationManager(Context context) { return applicationManager; } - public RequestManager get(Context context) { + @NonNull + public RequestManager get(@NonNull Context context) { if (context == null) { throw new IllegalArgumentException("You cannot start a load on a null Context"); } else if (Util.isOnMainThread() && !(context instanceof Application)) { @@ -120,7 +122,8 @@ public RequestManager get(Context context) { return getApplicationManager(context); } - public RequestManager get(FragmentActivity activity) { + @NonNull + public RequestManager get(@NonNull FragmentActivity activity) { if (Util.isOnBackgroundThread()) { return get(activity.getApplicationContext()); } else { @@ -130,7 +133,8 @@ public RequestManager get(FragmentActivity activity) { } } - public RequestManager get(Fragment fragment) { + @NonNull + public RequestManager get(@NonNull Fragment fragment) { Preconditions.checkNotNull(fragment.getActivity(), "You cannot start a load on a fragment before it is attached or after it is destroyed"); if (Util.isOnBackgroundThread()) { @@ -141,7 +145,8 @@ public RequestManager get(Fragment fragment) { } } - public RequestManager get(Activity activity) { + @NonNull + public RequestManager get(@NonNull Activity activity) { if (Util.isOnBackgroundThread()) { return get(activity.getApplicationContext()); } else { @@ -151,7 +156,8 @@ public RequestManager get(Activity activity) { } } - public RequestManager get(View view) { + @NonNull + public RequestManager get(@NonNull View view) { if (Util.isOnBackgroundThread()) { return get(view.getContext().getApplicationContext()); } @@ -184,7 +190,7 @@ public RequestManager get(View view) { private static void findAllSupportFragmentsWithViews( @Nullable Collection topLevelFragments, - Map result) { + @NonNull Map result) { if (topLevelFragments == null) { return; } @@ -199,7 +205,7 @@ private static void findAllSupportFragmentsWithViews( } @Nullable - private Fragment findSupportFragment(View target, FragmentActivity activity) { + private Fragment findSupportFragment(@NonNull View target, @NonNull FragmentActivity activity) { tempViewToSupportFragment.clear(); findAllSupportFragmentsWithViews( activity.getSupportFragmentManager().getFragments(), tempViewToSupportFragment); @@ -223,7 +229,7 @@ private Fragment findSupportFragment(View target, FragmentActivity activity) { } @Nullable - private android.app.Fragment findFragment(View target, Activity activity) { + private android.app.Fragment findFragment(@NonNull View target, @NonNull Activity activity) { tempViewToFragment.clear(); findAllFragmentsWithViews(activity.getFragmentManager(), tempViewToFragment); @@ -231,7 +237,7 @@ private android.app.Fragment findFragment(View target, Activity activity) { View activityRoot = activity.findViewById(android.R.id.content); View current = target; - while (!current.equals(activityRoot)) { + while (!current.equals(activityRoot)) { result = tempViewToFragment.get(current); if (result != null) { break; @@ -250,7 +256,8 @@ private android.app.Fragment findFragment(View target, Activity activity) { // non-support Fragments. @TargetApi(Build.VERSION_CODES.O) private void findAllFragmentsWithViews( - android.app.FragmentManager fragmentManager, ArrayMap result) { + @NonNull android.app.FragmentManager fragmentManager, + @NonNull ArrayMap result) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { for (android.app.Fragment fragment : fragmentManager.getFragments()) { if (fragment.getView() != null) { @@ -264,7 +271,8 @@ private void findAllFragmentsWithViews( } private void findAllFragmentsWithViewsPreO( - android.app.FragmentManager fragmentManager, ArrayMap result) { + @NonNull android.app.FragmentManager fragmentManager, + @NonNull ArrayMap result) { int index = 0; while (true) { tempBundle.putInt(FRAGMENT_INDEX_KEY, index++); @@ -286,7 +294,8 @@ private void findAllFragmentsWithViewsPreO( } } - private Activity findActivity(Context context) { + @Nullable + private Activity findActivity(@NonNull Context context) { if (context instanceof Activity) { return (Activity) context; } else if (context instanceof ContextWrapper) { @@ -297,14 +306,15 @@ private Activity findActivity(Context context) { } @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) - private static void assertNotDestroyed(Activity activity) { + private static void assertNotDestroyed(@NonNull Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed()) { throw new IllegalArgumentException("You cannot start a load for a destroyed activity"); } } + @NonNull @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) - public RequestManager get(android.app.Fragment fragment) { + public RequestManager get(@NonNull android.app.Fragment fragment) { if (fragment.getActivity() == null) { throw new IllegalArgumentException( "You cannot start a load on a fragment before it is attached"); @@ -318,7 +328,7 @@ public RequestManager get(android.app.Fragment fragment) { } RequestManagerFragment getRequestManagerFragment( - final android.app.FragmentManager fm, android.app.Fragment parentHint) { + @NonNull final android.app.FragmentManager fm, @Nullable android.app.Fragment parentHint) { RequestManagerFragment current = (RequestManagerFragment) fm.findFragmentByTag(FRAGMENT_TAG); if (current == null) { current = pendingRequestManagerFragments.get(fm); @@ -333,8 +343,10 @@ RequestManagerFragment getRequestManagerFragment( return current; } - private RequestManager fragmentGet(Context context, android.app.FragmentManager fm, - android.app.Fragment parentHint) { + @NonNull + private RequestManager fragmentGet(@NonNull Context context, + @NonNull android.app.FragmentManager fm, + @Nullable android.app.Fragment parentHint) { RequestManagerFragment current = getRequestManagerFragment(fm, parentHint); RequestManager requestManager = current.getRequestManager(); if (requestManager == null) { @@ -349,7 +361,7 @@ private RequestManager fragmentGet(Context context, android.app.FragmentManager } SupportRequestManagerFragment getSupportRequestManagerFragment( - final FragmentManager fm, Fragment parentHint) { + @NonNull final FragmentManager fm, @Nullable Fragment parentHint) { SupportRequestManagerFragment current = (SupportRequestManagerFragment) fm.findFragmentByTag(FRAGMENT_TAG); if (current == null) { @@ -365,8 +377,9 @@ SupportRequestManagerFragment getSupportRequestManagerFragment( return current; } - private RequestManager supportFragmentGet(Context context, FragmentManager fm, - Fragment parentHint) { + @NonNull + private RequestManager supportFragmentGet(@NonNull Context context, @NonNull FragmentManager fm, + @Nullable Fragment parentHint) { SupportRequestManagerFragment current = getSupportRequestManagerFragment(fm, parentHint); RequestManager requestManager = current.getRequestManager(); if (requestManager == null) { @@ -410,17 +423,19 @@ public boolean handleMessage(Message message) { * Used internally to create {@link RequestManager}s. */ public interface RequestManagerFactory { + @NonNull RequestManager build( - Glide glide, - Lifecycle lifecycle, - RequestManagerTreeNode requestManagerTreeNode, - Context context); + @NonNull Glide glide, + @NonNull Lifecycle lifecycle, + @NonNull RequestManagerTreeNode requestManagerTreeNode, + @NonNull Context context); } private static final RequestManagerFactory DEFAULT_FACTORY = new RequestManagerFactory() { + @NonNull @Override - public RequestManager build(Glide glide, Lifecycle lifecycle, - RequestManagerTreeNode requestManagerTreeNode, Context context) { + public RequestManager build(@NonNull Glide glide, @NonNull Lifecycle lifecycle, + @NonNull RequestManagerTreeNode requestManagerTreeNode, @NonNull Context context) { return new RequestManager(glide, lifecycle, requestManagerTreeNode, context); } }; diff --git a/library/src/main/java/com/bumptech/glide/request/target/ImageViewTargetFactory.java b/library/src/main/java/com/bumptech/glide/request/target/ImageViewTargetFactory.java index fa51504a30..2e91ac594f 100644 --- a/library/src/main/java/com/bumptech/glide/request/target/ImageViewTargetFactory.java +++ b/library/src/main/java/com/bumptech/glide/request/target/ImageViewTargetFactory.java @@ -2,6 +2,7 @@ import android.graphics.Bitmap; import android.graphics.drawable.Drawable; +import android.support.annotation.NonNull; import android.widget.ImageView; /** @@ -9,9 +10,10 @@ * {@link com.bumptech.glide.request.target.Target} for a given {@link android.view.View} subclass. */ public class ImageViewTargetFactory { - + @NonNull @SuppressWarnings("unchecked") - public ViewTarget buildTarget(ImageView view, Class clazz) { + public ViewTarget buildTarget(@NonNull ImageView view, + @NonNull Class clazz) { if (Bitmap.class.equals(clazz)) { return (ViewTarget) new BitmapImageViewTarget(view); } else if (Drawable.class.isAssignableFrom(clazz)) { diff --git a/library/src/main/java/com/bumptech/glide/util/Preconditions.java b/library/src/main/java/com/bumptech/glide/util/Preconditions.java index 121ead84c4..4ca650fc7a 100644 --- a/library/src/main/java/com/bumptech/glide/util/Preconditions.java +++ b/library/src/main/java/com/bumptech/glide/util/Preconditions.java @@ -1,5 +1,7 @@ package com.bumptech.glide.util; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.text.TextUtils; import java.util.Collection; @@ -12,31 +14,35 @@ private Preconditions() { // Utility class. } - public static void checkArgument(boolean expression, String message) { + public static void checkArgument(boolean expression, @NonNull String message) { if (!expression) { throw new IllegalArgumentException(message); } } - public static T checkNotNull(T arg) { + @NonNull + public static T checkNotNull(@Nullable T arg) { return checkNotNull(arg, "Argument must not be null"); } - public static T checkNotNull(T arg, String message) { + @NonNull + public static T checkNotNull(@Nullable T arg, @NonNull String message) { if (arg == null) { throw new NullPointerException(message); } return arg; } - public static String checkNotEmpty(String string) { + @NonNull + public static String checkNotEmpty(@Nullable String string) { if (TextUtils.isEmpty(string)) { throw new IllegalArgumentException("Must not be null or empty"); } return string; } - public static , Y> T checkNotEmpty(T collection) { + @NonNull + public static , Y> T checkNotEmpty(@NonNull T collection) { if (collection.isEmpty()) { throw new IllegalArgumentException("Must not be empty."); }