Reputation: 1
I have a problem using Glide load image android.I will present it simply as follows: First I load image using glide I want to choose image using Intent.ACTION_PICK but when I using image.setImageBitmap on onActivityResult but it not working
Glide.with(context!!).load(url).centerCrop().error(R.drawable.avata_boy).into(imgAvata)
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == PICK_IMAGE_REQUEST && resultCode == Activity.RESULT_OK
&& data != null && data.data != null
) {
filePath = data.data
try {
val bitmap = BitmapFactory.decodeStream(activity!!.contentResolver.openInputStream(filePath!!))
imgAvata.setImageBitmap(bitmap)
Glide.with(context!!)
.load(bitmap)
.placeholder(R.drawable.avata_boy)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.into(imgAvata)
} catch (e: IOException) {
}
Upvotes: 0
Views: 229
Reputation: 100
Try this!!
val myBitmap = BitmapFactory.decodeFile(filePath!!.getAbsolutePath())
imgview.setImageBitmap(myBitmap)
Upvotes: 0