android-gpuimage
android-gpuimage copied to clipboard
GPUIImageView Render Blank/Black in RecyclerView after scroll
I'm using RecyclerView
to show a list of filters applied to same Image.
When the view is scrolled and then get back to the the hidden item the GPUIImageView
is rendered black.
Also, the RecyclerView
is inside a Fragment
and while scrolling it is very laggy, I can even see some part of the activity behind the hosted fragment.
I think it the same as #164
I'm facing with the same problem, did you fix it?
I had the same problem with the black item re entering the view in a Recycler View. The only thing that seems to remove the black view is by overriding the onViewAttachedToWindow method, deleting and setting again the image of the GPUImage.
@Override
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
ViewHolder viewHolder = (ViewHolder) holder;
viewHolder.gpuImage.deleteImage();
viewHolder.gpuImage.setImage(mPicture);
super.onViewAttachedToWindow(holder);
}
I used a GPUImage and a GLSurfaceView but I'm guessing it also work with a GPUImageView.
calimbak is the right answer,it's a bug of gpuimage i thought
@theGlenn Hey bro, have you solved it ? I have the same situation with you to "show a list of filters applied to same Image" with a RecyclerView.
I tried the code as below in my Adapter and it seems to work for the black problem.
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(R.layout.filtericon_layout, parent, false);
ViewHolder vh = new ViewHolder(view);
vh.setIsRecyclable(false);
return vh;
}
But my problem is every single item looks like the same even thought the filters applied are different. I tried to set GPUImageView.setImage() the same thumbnail(Bitmap) or different Bitmap object created by Bitmap.createBitmap(thumbnail), but it doesn't work.
Facing same issues! Any body found the solution ?
I think I've solved it in a different way, I put the ImageView in the ViewHolder instead of GPUImageView, and then create the Bitmap with different filters by GPUImage.getBitmapWithFilterApplied(bitmap), and setBitmap to show the picture in RecyclerView.
public Bitmap getBitmapWithFilterApplied(Context context, Bitmap bitmap, Filter filter) {
if (mImage == null) {
mImage = new GPUImage(context.getApplicationContext());
}
mImage.setFilter(filter.getFilter());
return mImage.getBitmapWithFilterApplied(bitmap);
}
Finally, remember to recycler your bitmap.
@AssassinWayne Cool! And this solution makes recyclerview load faster! Thanks!!!
@AssassinWayne , @calk0115 .... Can anyone post the adapter sample on how you are achieving this please and where you guys are recycling bitmap
@AssassinWayne Thank you, it works well! and scrolling faster
@AssassinWayne @Seddiks can anyone post complete code here. how bitmap load faster ?
@AssassinWayne Thank you, it works well! and scrolling faster
Hai, Can you please share full code here. I'm facing this issue past two past but not yet solved. Please share it here it will help
@AssassinWayne Thank you, it works well! and scrolling faster
Hai, Can you please share full code here. I'm facing this issue past two past but not yet solved. Please share it here it will help
it also done from my side and i am sharing code so that anyone not to wait anmore
All code only for adapters
-
Initialise this globally private var gpuImage : GPUImage? = null
-
Create a method whose return type is Bitmap
private fun getBitmapWithFilterApplied(filter: GPUImageFilter): Bitmap? { if (gpuImage == null) { gpuImage = GPUImage(cContext.applicationContext) } gpuImage?.setFilter(filter) return gpuImage?.getBitmapWithFilterApplied(ActVideoTrimmer.m_bitmap) }
-
Add above method to image view thumbnail.setImageBitmap(getBitmapWithFilterApplied(getCurrentIndex.imageFilter!!))
Here thumbnail is the ImageView which i declare in Layout file