I am using GPUImageView
component from android-gpuimage Library for displaying Images (with filtered applied on them) in my ListView
.
The Images are being loaded perfectly with filters for the First time in my ListView
but when i scroll down the ListView
, all the Scrolled Cells are displayed Blank.
Here is the code of the getView(...)
method of my custom BaseAdapter
:
@Override
public View getView(int position, View convert_view, ViewGroup arg2) {
// TODO Auto-generated method stub
if(convert_view == null)
{
if(inflater == null)
inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convert_view = inflater.inflate( R.layout.filter_item , null);
}
TextView thumb_file_name_tv = (TextView) convert_view.findViewById(R.id.filter_item_thumb_tv);
GPUImageView thumb_giv = (GPUImageView) convert_view.findViewById(R.id.filter_item_thumb_giv);
Log.d(TAG, "Image Uri = "+imageUri);
thumb_file_name_tv.setText(""+filterNames.get(position).toString().trim());
thumb_giv.setFilter(new GPUImageSepiaFilter());
thumb_giv.setImage(imageUri); // this loads image on the current thread, should be run in a thread
thumb_giv.requestRender();
return convert_view;
}
Please tell me what i am doing wrong here ?
Any help is highly appreciated.
It has been a while since I used that library, but from what I remember, if you change the image in the view, you need to call deleteImage()
before settings the new image.
Try calling that method before calling setImage()
You might need to check if the view has an image present before you can call deleteImage()
or it might throw an error.
Edit :
Add the following methods to the GPUImageView.java
class of the android-gpuImage library :
public void deleteImage()
{
mGPUImage.deleteImage();
}