RecyclerView: Async image-loading

前端 未结 7 808
被撕碎了的回忆
被撕碎了的回忆 2020-12-28 15:58

Im using RecyclerView to display a list containing an imageView. To make the UI more fluently, I load 58dp thumbnails saved on sd card into these i

7条回答
  •  有刺的猬
    2020-12-28 16:39

    you must cancel old request in "onBindViewHolder" method:

    try{
            ((SpecialOfferViewHolder)viewHolder).imageContainer.cancelRequest();
    }catch(Exception e) {
    
    }
    

    remember to save image container in the viewHolder:

    public void onResponse(ImageContainer response, boolean arg1) {
                    ((SpecialOfferViewHolder)viewHolder).imageContainer=response;
    

    }

提交回复
热议问题