ListView get stuck when loading remote image in imageView

464 views Asked by At

In an application for Android TV, i have a vertical ListView showing a remote image in each cell.

Scrolling down the list with the remote control keys this is suppose to show the next element, but it get stuck, if i go back, up, a couple of item (with the focus) and then i scroll down it loads 2-4 items more and get stuck again, and so on and so forth.

The images are loaded remotely through ion, but the same behaviour happens using UniversalImageLoader. Using only a placeholder image the list run smoothly.

It looks like it is an issue on loading the remote images on a separate task, but ion is suppose to cover this.

class DayImagesAdapter extends BaseAdapter {

    Context context;
    List<String> data; //just an array of URL strings

    private static LayoutInflater inflater = null;

    public DayImagesAdapter(Context context, List<String> data) {
        this.context = context;
        this.data = data;
        inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override public int getCount() { return data.size(); }

    @Override public Object getItem(int position) {  return data.get(position);  }

    @Override public long getItemId(int position) { return position; }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View vi = convertView;
        if (vi == null)
            vi = inflater.inflate(R.layout.layout_image_cell, null);
        ImageView imageView = (ImageView) vi.findViewById(R.id.imageDayImagesCell);
        String url = Constants.BASE_URL + data.get(position);

        Ion.with(imageView).placeholder(R.drawable.placholder_image).load(url); // <-problem

        return vi;
    }
}
0

There are 0 answers