private SimpleTarget target = new SimpleTarget() {
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation glideAnimation) {
If you only want to set the Bitmap
into the ImageView
using Glide
then you can try out for a Extension Function in Kotlin with which you will only need to pass the parameters like uri/url or size
.
For Example:
class KotlinActivity : AppCompatActivity() {
var sampleImageView : ImageView? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_kotlin)
sampleImageView = findViewById(R.id.imageView) as ImageView?
sampleImageView?.setImage("https://kbob.github.io/images/sample-3.jpg")
}
//Extension function for ImageView
fun ImageView.setImage(url:String, context:Context){
Glide.with(context).load(url).into(this)
}
}