private SimpleTarget target = new SimpleTarget() {
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation glideAnimation) {
The problem is that in the Java code, you used the type SimpleTarget
as the type of target
. This is a raw type (missing generic parameters), and is one of the big legacy problems in Java generics. Kotlin doesn't allow raw types, and this is why you got problems while converting.
To fix this, you should do the following in Java:
private SimpleTarget target = new SimpleTarget() { ... }
Which will force you to add asBitmap()
to your Glide call:
Glide.with(context)
.load(uri)
.asBitmap()
.override(600, 600)
.fitCenter()
.into(target);
Now that your code is using generics safely, it can be translated to Kotlin without a problem:
Glide.with(context)
.load(uri)
.asBitmap()
.override(600, 600)
.fitCenter()
.into>(target)