cats-oss / android-gpuimage

Android filters based on OpenGL (idea from GPUImage for iOS)
9k stars 2.27k forks source link

passing the selected GpuImageFilter from recycler view adapter to Activity makes it black #513

Open Hrishita opened 3 years ago

Hrishita commented 3 years ago

I have recycler view that displays various filters on ImageView. when user clicks on recycler view item I am passing the GpuImageFilter through an interface to the activity. In activity, the implemented method of interface receives the GpuImageFilter and set it on GpuImage. The problem Is that when i click on a item of recycler view and scroll the recyclerview, the ImageVIew at that position becomes black or transparent.

Here is my code of onBindViewHolder

    final GPUImageFilter currentFilter = filtersModels.get(position);
    if(gpuImage == null)

    { 

        gpuImage = new GPUImage(context); 

    } 

    gpuImage.setFilter(currentFilter);

    holder.imageView.setImageBitmap(gpuImage.getBitmapWithFilterApplied(original));

    holder.itemView.setOnClickListener(new View.OnClickListener() {

        @Override

        public void onClick(View v) {

            mCallback.onFilterSelected((currentFilter));

        }

    });

and in the onFilterSelectedMethod this is code

     `arrayList.set(PRE_FILTER_INDEX, filter);

    filters = new GPUImageFilterGroup(arrayList);

    mainImage.setFilter(filters);`

How can i prevent the Image View in recyclerview from turning black? Thanks

kasem-sm commented 3 years ago

Well, I have managed to achieve this. (in kotlin) Ask me if you need a sample project.

svanegas commented 2 years ago

Well, I have managed to achieve this. (in kotlin) Ask me if you need a sample project.

Hi @kasem-sm. Could you please share details about how you achieved this?