-3

I was wondering about, how to implement Glide along with using Bitmap compression in Kotlin and thought that any of the code below would work. But unfortunately, the app closes as soon as I add an image into any of the imageView for the fourth time. Here's the code which I tried to implement

val selectedImage = data?.data
val bitmap = MediaStore.Images.Media.getBitmap(contentResolver, selectedImage) 
//method 1
Glide.with(this).asBitmap().load(compressBitmap(bitmap,5)).into(imageView!!)
//method 2
var bitmapDrawable = BitmapDrawable( resources , compressBitmap(bitmap,5))
Glide.with(this).load(bitmapDrawable).into(imageView!!)

What would be the correct code, if i'm somewhere wrong here. Thankyou in advance

Zoe
  • 27,060
  • 21
  • 118
  • 148
  • 2
    Possible duplicate of [Unfortunately MyApp has stopped. How can I solve this?](https://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this) – Zoe Mar 01 '19 at 09:07
  • Add the Crash stacktrace with question .. – ADM Mar 01 '19 at 09:08
  • Too many images? if you want smaller images, then you load more? – AIMIN PAN Mar 01 '19 at 09:40

1 Answers1

1

Try using Recycler View or another component to load the images in. They will handle the load.

Ryan Godlonton-Shaw
  • 584
  • 1
  • 5
  • 18