private SimpleTarget target = new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation glideAnimation) {
// do something with the bitmap
// for demonstration purposes, let's just set it to an ImageView
imageView1.setImageBitmap( bitmap );
}
};
private void loadImageSimpleTarget() {
Glide.with(context)
.load(uri)
.override(600, 600)
.fitCenter()
.into(target);
}
Run Code Online (Sandbox Code Playgroud)
我尝试将其转换为Kotlin,如下所示.
val finish_target = object : SimpleTarget<Bitmap>() {
override fun onResourceReady(bitmap: Bitmap?, glideAnimation: GlideAnimation<in Bitmap>?) {
preview_image.setImageBitmap(bitmap)
}
}
Glide.with(context)
.load(uri)
.override(600, 600)
.fitCenter()
.into(finish_target)
Run Code Online (Sandbox Code Playgroud)
但编译错误表明了这一点
public open fun <Y : Target<GlideDrawable!>!> …Run Code Online (Sandbox Code Playgroud)