glide
glide copied to clipboard
Request: add NonNull annotation for the Bitmap in RequestListener.onResourceReady
I'm using this version of Glide:
implementation 'com.github.bumptech.glide:glide:4.13.2'
And this command to load some bitmap:
Glide.with(context).asBitmap().load(imgFile).addListener(listener).apply(RequestOptions.centerInsideTransform().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE)).submit(screenWidth, screenHeight)
For the listener, I've noticed that there are no nullable annotations, so I get these function callbacks:
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Bitmap>?, isFirstResource: Boolean): Boolean {
override fun onResourceReady(resource: Bitmap?, model: Any?, target: Target<Bitmap>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
I think it's safe to say that at least for onResourceReady , the resource shouldn't be null, because of the docs about it ("resource – The resource that was loaded for the target.") , and because otherwise we have onLoadFailed:
Please add this annotation there, and if possible, also annotations for the rest.
Please feel free to send a pull request
@sjudd OK here: https://github.com/bumptech/glide/pull/4884
But I think there are more similar cases, such as ResourceCallback.
Also, for some reason I can't build the project. I get this error:
warnings found and -Werror specified
FAILURE: Build completed with 3 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':annotation:compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':third_party:disklrucache:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================
3: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':third_party:disklrucache:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================
* Get more help at https://help.gradle.org
BUILD FAILED in 28s
@sjudd I would like to pick up this issue
Hey, @sjudd @AndroidDeveloperLB it's Mudssir Ahmed and I'm starting to work on this issue, If possible you can assign it to me.
@MudssirAhmed I have no way to change it. I don't have the credentials, or something.
This ended up being done in 60b567e5feec70ba810a663e56a10d837f26c56c
Thank you guys. It's a good practice to run the code-analyze feature to find places that need to have nullability annotations.