Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load 1 image to multiple ImageView with Glide

How to load 1 image from server to multiple imageView using Glide? i've try this code :

Glide.with(ViewProductActivity.this)
        .load(LoginActivity.SERVER_URL+"/product/asset/"+listImageUrl.getString(i))
        .asBitmap()
        .placeholder(R.drawable.loading)
        .error(R.drawable.noimage)
        .signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
        .into(new SimpleTarget<Bitmap>() {
            @Override
            public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                ivImageChild.setImageBitmap(resource);
                ivImageMain.setImageBitmap(resource);
            }
        });

but the placeholder() doesn't work.. how to solve?

like image 450
zihadrizkyef Avatar asked Oct 30 '22 16:10

zihadrizkyef


1 Answers

Simply create request for each image :)

Glide.with(ViewProductActivity.this)
  .load(LoginActivity.SERVER_URL+"/product/asset/"+listImageUrl.getString(i))
    .asBitmap()
    .placeholder(R.drawable.loading)
    .error(R.drawable.noimage)
    .signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
    .into(ivImageChild);

Glide.with(ViewProductActivity.this)
  .load(LoginActivity.SERVER_URL+"/product/asset/"+listImageUrl.getString(i))
    .asBitmap()
    .placeholder(R.drawable.loading)
    .error(R.drawable.noimage)
    .signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
    .into(ivImageMain);
like image 194
Inverce Avatar answered Nov 15 '22 05:11

Inverce