2

Loading images to recyclerview is very slow and allways load from online.

private void setBackground(String imageUrl, ImageView background, boolean croped) {
    Picasso.with(contexts).setIndicatorsEnabled(false);
    if (croped)
        Picasso.with(contexts)
                .load(BitmapUrlHelper.getPictureUrl(contexts, imageUrl, 80)).centerInside().resize(((displayWidth) - 10), (Integer) ((displayHigh) / 5)).placeholder(R.drawable.cart)
            .into(background);
}

If i bind images they are not load from cach

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    Product product = Products.get(position);
    if (position < Products.size() - 2 ){
        Picasso.with(contexts).load(BitmapUrlHelper.getPictureUrl(contexts, Products.get(position + 1).getImage(), 80)).fetch();
    }

    if (position > 0 ){
        Picasso.with(contexts).load(BitmapUrlHelper.getPictureUrl(contexts, Products.get(position - 1).getImage(), 80)) .fetch();
    }


    if (product.getImage_preview_android() == null){
       setBackground(product.getImage(), holder.background_view, true);

layout part

 <uk.co.senab.bitmapcache.CacheableImageView
        android:id="@+id/background"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:scaleType="centerCrop"
        tools:src="@drawable/main_background"

        android:layout_gravity="right" />
Денис
  • 41
  • 3

0 Answers0