Skip to content Skip to sidebar Skip to footer

How To Load Image By Image Using Glide Library?

I have an application contains a range of image appears by links using glide library, my app takes a long time to load all images so is it possible to load image by image ( one by

Solution 1:

Try this

Glide.with(context)
        .load(imageId.get(position))
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .priority(Priority.HIGH)
        .listener(newRequestListener<String, GlideDrawable>() {
            @OverridepublicbooleanonException(Exception e, String  model, Target<GlideDrawable> target, boolean isFirstResource) {   
                   returnfalse;
            }
            @OverridepublicbooleanonResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                progressBar.setVisibility(View.GONE);
                returnfalse;
            }
        })
        .thumbnail(0.1f) // this will do the trick
        .into(holder.CategoryImage);

if it does not work, Try this way,

Glide.with(context)
        .load(imageId.get(position))
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .priority(Priority.HIGH)
        .override(100,100)
        .listener(newRequestListener<String, GlideDrawable>() {
            @OverridepublicbooleanonException(Exception e, String  model, Target<GlideDrawable> target, boolean isFirstResource) {   
                   returnfalse;
            }
            @OverridepublicbooleanonResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                progressBar.setVisibility(View.GONE);
                Glide.with(context).load(imageId.get(position))
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .priority(Priority.HIGH)
                    .into(holder.CategoryImage);
                returnfalse;
            }
        })
        .into(holder.CategoryImage);

Solution 2:

Use this code :

 Glide.with(this)
            .load(sharePref.getUserImage())
            .asBitmap()
            //.centerCrop()
            .placeholder(R.drawable.ic_account_circle_black_48dp)     // .placeholder(R.drawable.user)
            .into(new BitmapImageViewTarget(user_Image) {
                @Override
                protectedvoidsetResource(Bitmap resource) {
                    RoundedBitmapDrawable circularBitmapDrawable =
                            RoundedBitmapDrawableFactory.create(getResources(), resource);
                    circularBitmapDrawable.setCircular(true);
                    user_Image.setImageDrawable(circularBitmapDrawable);
                }
            });

Post a Comment for "How To Load Image By Image Using Glide Library?"