Nithinjith
Nithinjith

Reputation: 1825

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.

Upvotes: 3

Views: 1123

Answers (1)

TomH
TomH

Reputation: 2719

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

Upvotes: 5

Related Questions