Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] java – How to Lazy Load image using Glide android studio?

Posted on November 11, 2022 By

Solution 1 :

Use the transition effect to load the image smoothly and fast.

GlideApp  
.with(context)
.load(url)
.transition(DrawableTransitionOptions.withCrossFade()) //for loading image smoothly and fastly.
.placeholder(placeHolderUrl)
.error(errorImageUrl)
.fitCenter()
.into(imageView);

want more animation and smooth loading of images. See here
https://bumptech.github.io/glide/doc/transitions.html

Let me know if you have any problem

Problem :

I want to lazy load image inside my cardview but it’s not working below is my code but i am confused how to lazy load image using glide

        int width = metrics.widthPixels;
        int height = metrics.heightPixels;
        BitmapRequestBuilder builder =
                Glide.with(context)
                        .load(Constants.IMAGE_DOWNLOAD + pathName)
                        .asBitmap();
        FutureTarget futureTarget = builder.into(width, height);
        return (Bitmap) futureTarget.get();
    }

    private Bitmap loadImageForNoti(Context context, String pathName) throws ExecutionException, InterruptedException {
        DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
        int width = metrics.widthPixels;
        int height = metrics.heightPixels;
        BitmapRequestBuilder builder =
                Glide.with(context)
                        .load(pathName)
                        .asBitmap();
        FutureTarget futureTarget = builder.into(width, height);
        return (Bitmap) futureTarget.get();
    }```
[This is my [code][1] 1 ][1]


[This is my [second][2] code ][2]

i am confused where to add code to lazy load image using glide


  [1]: https://i.stack.imgur.com/851dp.png
  [2]: https://i.stack.imgur.com/CHnJQ.png

Comments

Comment posted by How to lazy load images in ListView in Android

Does this answer your question?

Comment posted by suraj gaikwad

Basically the problem is that when i am opening the app and click on any image then related to that images are showing below in cardview but when i am using mobile data it’s loading only half images of cardview and other images are not loaded so how to load remaining images in above code.

Comment posted by M DEV

@surajgaikwad you have to mention this problem in your question and also want to share images and code of that issue. Please mention this issue and code in your question.

READ  [FIXED] android - Thin question: how can I take out an old sign from my original .apk-file, is there any method?
Powered by Inline Related Posts

Android Tags:android, android-glide, android-studio, java

Post navigation

Previous Post: [FIXED] android developer api – there is a ‘Late Initialization Error’ during flutter development
Next Post: [FIXED] android – How to set SSL pinning using retrofit for Firebase Realtime Database Url?

Related Posts

[FIXED] android – Some of the multiple concurrent calls to set LiveData are not observed Android
[FIXED] android studio – Dynamically set event listener on textview included in linearLayout Android
[FIXED] c# – Pass data between two Content Page; Android
[FIXED] firebase – Android:I dont understand why if block is always true here? Android
[FIXED] android studio – How can i use infinite PageView? Android
[FIXED] android – Custom view default style not wokring without style tag Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can VPN be traced by police?
  • Where were Kaiser-Frazer cars built?
  • How do you make gold rose gold paint?
  • What are the newest type of dentures?
  • Can you wear joggers as dress pants?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme