I am trying to send a Bitmap with Intent from a RecyclerView adapter to an Activity. The error I get is:
FAILED BINDER TRANSACTION !!! (parcel size = 6010104)
.
Can anyone find what is wrong? My code is below.
class ClothesAdapter(private var clothesList: List<ClothModel>) :
RecyclerView.Adapter<ClothesAdapter.MyViewHolder>() {
inner class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
var titleView: TextView = view.findViewById(R.id.title_view)
var imageView: ImageView = view.findViewById(R.id.image_view)
}
@NonNull
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
val itemView = LayoutInflater.from(parent.context)
.inflate(R.layout.cloth_row, parent, false)
return MyViewHolder(itemView)
}
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
val cloth = clothesList[position]
holder.titleView.text = cloth.getTitle()
holder.imageView.setImageBitmap(cloth.getBitmap())
var context = holder.itemView.context
holder.imageView.setOnClickListener {
val clothBitmap = cloth.getBitmap()!!
val bStream = ByteArrayOutputStream()
clothBitmap?.compress(Bitmap.CompressFormat.PNG, 100, bStream)
val byteArray: ByteArray = bStream.toByteArray()
val intent = Intent(context, StillImageActivity::class.java)
intent.putExtra("bitmap", byteArray)
context.startActivity(intent) //AT THIS POINT I GET ERROR
}
}
override fun getItemCount(): Int {
return clothesList.size
}
}