Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Kotlin is Propting to create an extension function when set Glide error drawable from resource?

I am new in Kolin and I am converting my old codebase into Kotlin. I am getting an error while loading an image using Glide.

My Code

Glide.with(context)
.load(url)
.apply(options)
.error(R.drawable.ic_no_image)
.into(imageView)

Normally this is correct. But I am getting type mismatch error from Kotlin compiler in the error() builder method.

Required: RequestBuilder

Anyone has any solution without extension function.

like image 356
Nithinjith Avatar asked Dec 13 '25 04:12

Nithinjith


1 Answers

I believe you want to create a class such as MyGlideModule which extends AppGlideModule and is annotated with @GlideModule Then instead of calling Glide.With(...) you call GlideApp.With(...) and these extra methods should be available.

@GlideModule
class MyGlideModule : AppGlideModule

See here: GlideModule

like image 137
TomH Avatar answered Dec 15 '25 17:12

TomH



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!