Lazy load of images in Android

Related tags

ListView LazyList
Overview

LazyList

A simple library to display images in Android ListView. Images are being downloaded asynchronously in the background. Images are being cached on SD card and in memory. Can also be used for GridView and just to display images into an ImageView.

Originally published here.

Basic Usage

ImageLoader imageLoader=new ImageLoader(context);
...
imageLoader.DisplayImage(url, imageView);

Don't forget to add the following permissions to your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Please create only one instance of ImageLoader and reuse it all around your application. This way image caching will be much more efficient.

License

LazyList is released under the MIT license.

Comments
  • ImageLoader with fragments

    ImageLoader with fragments

    Several people have reported me that ImageLoader doesn't display bitmaps correctly if used inside fragments. Unfortunately I can't reproduce this problem - it works just fine for me. It would be great if someone could attach a demo project with the problem inside. Have some ideas how to fix it. But before applying the fix need to be able to reproduce the problem and test it well.

    opened by thest1 13
  • Suddenly stop working

    Suddenly stop working

    Hi,

    I've been using this since time ago, but suddenly has stop working. I've added permissions on execution time, but i'm still reciving the following error:

    java.io.FileNotFoundException: /storage/emulated/0/LazyList/-44270421 (Permission denied)

    The only thing has changed is the app.iml file, could be here the error?

    Any help is apreciated! Thank you!

    opened by WyrnCael 6
  • Threads not closed

    Threads not closed

    Hi,

    According to the DDMS tool, the ImageLoader doesn't close the threads in the thread pool for the executorService.

    This is a rather large memory issue is it not?

    opened by Todd-Davies 6
  • Application get slow/hang when change your code

    Application get slow/hang when change your code

    Hi, Thanks for your code. I needed Lazy Loader to load image from Internal Storage. So I change your code as per my need, My list is in TabHost. At first it works fine, But when I switch from one tab to another application gets slow and may times get Hang. Why so?

    In your getBitmap() I changed code to get Image from Internal Storage.

    opened by AkshayGangurde 5
  • Some image failed to load.

    Some image failed to load.

    Hi,

    i just implement lazylist to my application,but it doesn't work well, some of the image not loaded to the image view, it will load if i scroll the listview to the bottom. is there any fix for this ?, or is this known issue ?

    thanks

    opened by rheza 4
  • Change the scaling/resizing of the images being loaded

    Change the scaling/resizing of the images being loaded

    First of all i want to say thank you very much for this great solution for lazy loading images. I integrated your way succesfully in my already existing arrrayadapter. What i was not able to achieve yet is changing the scaling of the images before they are cached. it seems as if the images always have the same resolution. i can resize them afterwards without problems but this messes up the original resolution. So my question: how to change scaling/resizing to exactly the size the picture should appear in the UI afterwards?

    opened by ghost 4
  • imageView.getContext() can fail - is there another way to get the activity?

    imageView.getContext() can fail - is there another way to get the activity?

    Hi

    I love the lazylist and in particular the ImageLoader. It worked fine for me until i tried something new :

    I created a horizontal Scroller and loaded views into it within the oncreate code oh my activity. After creating a such ImageView (which is in a layout which i add to the horizontal scroller) i used DisplayImage(img, iv) to get a picture from an url into it.

    Well it never worked .. no exceptions, no result at all. I analyzed all the ImageLoader code and used Logcat to find the command which caused the behavior.

    The issue is in the run method of the PhotosLoader class which will try to get the activity the imageView lives in to let its UI Thread set the image bitmap:

    (Activity)photoToLoad.imageView.getContext();
    

    Based on Logcat outputs i think my view will return an application object in this case:

    08-24 12:54:30.895: V/REPMKT(2430): android.app.Application@414626f0
    

    I fixxed the issue by passing my activity into the ImageLoader via constructor and from there pass it into the PhotosLoader. I don't hink that's a clever approach but it works.

    Any ideas how to fix this ?

    Nik

    opened by Niksac 4
  • images fail to load after a while

    images fail to load after a while

    Hi, I've been using your LazyList and it really works well. However, every now and then, images fail to load into my listview using your lazy loading technique. Restarting my app does not fix the issue, but rebooting the phone fixes it. Have you seen this issue or do you know what could be causing this behavior?

    I have not been able to reproduce this issue, so I'm not sure where or how to start debugging. Any helpful tips that you can provide would be greatly appreciated.

    Thank you

    opened by hyoun98 4
  • Query

    Query

    Hello I have one query about this library. If i am loading images into the listview and the images are downloaded then shown . But I in my next activity i repeat the same process. Does the images will be again download or it will apear from memory.

    And if i close the application and internet is turned off then the listview will be populated from Local DB and the image path will be the same . Will it show the image from local cache or NOT ??

    opened by mirmibrahim 2
  • Show new images with animation and allow to set a FileCache dir

    Show new images with animation and allow to set a FileCache dir

    Hi Fedor

    It took me a lot of time to get my head around git and managing forking and stuff.

    Anyway here is my pull request with the changes i discussed earlier.

    I hope you find it usefull. Please let me know if something is not working as expected.

    Bye, Johnny

    opened by johnnycube 2
  • Clarify license -- BSD, MIT, Apache, GPL, etc?

    Clarify license -- BSD, MIT, Apache, GPL, etc?

    I don't know if you've mentioned this anywhere, but it would be appropriate if you mentioned the license on a README.md so everyone that views your code knows what they're allowed to do with it.

    opened by shurane 2
  • path instead url

    path instead url

    hi I want to use path instead of the URl

    /data/user/0/com.androidha.chilan/pic/dariush/۲۰۱۸۰۳۰۴_۲۲۰۸۴۲.jpg

    instead

    "https://pbs.twimg.com/profile_images/1517737798/aam-twitter-right-final_normal.png"

    what do I do?

    opened by dariushEm 0
  • Problem when retrieving images from sdcard

    Problem when retrieving images from sdcard

    Hello I have downloaded this code n tried to retrieve saved images into list-view, but the problem is, it is not showing the way as it is inserted , images are displaying but are in shuffled.

    opened by swanandvaidya 0
  • Refresh Image

    Refresh Image

    Hi, I'm Using your Lazy Loading, But the Problem is

    1. when the image get changed on server it not get reflected on device..
    2. Also I'm setting alphabet If Image not present..

    What are the solution for these problem..I need your help to make changes in LazyList..The first problem is having high priority..

    opened by AkshayGangurde 0
  • LazyList update(refresh) Listview

    LazyList update(refresh) Listview

    Hi,

    I m trying to use searchView with LazyList. In my lazyAdapter I m updating my arraylist , this works smoothly but my listview doesn't update with arrayList. This is my filer method. I suppose notifyDataSetChanged does not work.Please help how can I refresh my listview?

    public void filter(String charText) {
    
        charText = charText.toLowerCase(Locale.getDefault());
        //list.clear();
        list = new ArrayList<HashMap<String, String>>();
        if (charText.length() == 0) {
            list.addAll(arraylist);
        } 
        else 
        {
            for (HashMap<String, String> map : arraylist) 
            {
                if (map.get("radio").toString().toLowerCase(Locale.getDefault()).contains(charText)) 
                {
                    list.add(map);
                }
            }
        }
        notifyDataSetChanged();
    }
    
    opened by sercanerfidan 0
An easy to use Drag & Drop List for Android. Direct replacement of the android ListView.

DragNDropListView DragNDropListView is a direct replacement for the stock Android ListView. If you know how to use ListView, you already know how to u

null 187 Dec 22, 2022
Android library to observe scroll events on scrollable views.

Android-ObservableScrollView Android library to observe scroll events on scrollable views. It's easy to interact with the Toolbar introduced in Androi

Soichiro Kashima 9.6k Dec 30, 2022
An android library for section headers that stick to the top

StickyListHeaders StickyListHeaders is an Android library that makes it easy to integrate section headers in your ListView. These section headers stic

Emil Sjölander 5.5k Jan 5, 2023
Easy to use ListView with pinned sections for Android.

Easy to use ListView with pinned sections for Android 2.1 and higher. Pinned section is a header view which sticks to the top of the list until at lea

Sergej Shafarenka 2.6k Dec 21, 2022
This project aims to provide a reusable pull to refresh widget for Android.

Pull To Refresh for Android Note This library is deprecated, a swipe refresh layout is available in the v4 support library. This project aims to provi

Johan Berg 2.5k Jan 2, 2023
An Android custom ListView and ScrollView with pull to zoom-in.

PullZoomView An Android custom ListView and ScrollView with pull to zoom-in. Features Set ZoomView enable Add HeaderView Custom ZoomView Parallax or N

Frank-Zhu 2.3k Dec 26, 2022
Android widget with pull to refresh for all the views,and support loadMore for ListView , RecyclerView, GridView and SwipeRefreshLayout.

CommonPullToRefresh Android widget with pull to refresh for all the views,and support loadMore for ListView,RecyclerView,GridView and SwipeRefreshLayo

null 1.1k Nov 10, 2022
HorizontalListView is an Android ListView widget which scrolls in a horizontal manner (in contrast with the SDK-provided ListView which scrolls vertically).

HorizontalListView HorizontalListView is an Android ListView widget which scrolls in a horizontal manner (in contrast with the SDK-provided ListView w

MeetMe 722 Nov 10, 2022
Android library to achieve in an easy way, the behaviour of the home page in the Expedia app, with a pair of auto-scroll circular parallax ListViews.

ListBuddies This library is not maintained anymore and there will be no further releases Android library of a pair of auto-scroll circular parallax Li

JPARDOGO 970 Dec 29, 2022
Horizontal list view for Android which allows variable items widths

Deprecated This widget is now deprecated and it won't be updated anymore. Use RecyclerView instead Horizontal Variable ListView Horizontal ListView fo

Alessandro Crugnola 862 Nov 15, 2022
A small android library for tagging views inside a ScrollView as "sticky" making them stick to the top of the scroll container until a new sticky view comes and takes it's place

StickyScrollViewItems StickyScrollViewItems is a ScrollView subclass that allowed you to mark items inside the ScrollView as sticky. The items marked

Emil Sjölander 1k Jan 7, 2023
A ListView with pinned section headers for Android

PinnedHeaderListView This library provides a sectioned ListView with pinned headers. It looks and feels much like the default contacts app does on And

James Smith 665 Nov 29, 2022
A generic, customizable, open source Android ListView implementation that has 'Pull to Refresh' functionality.

Android 'Pull to Refresh' ListView library Demo video: http://www.youtube.com/watch?v=VjmdELnm3GI Project A generic, customizable, open source Android

Erik Wallentinsen 639 Nov 17, 2022
This is a very simple library for Android that allows you to stick an header to a scrollable view and easily apply animation to it

StikkyHeader This is a very simple library for Android that allows you to stick an header to a ListView and easily apply animation to it Usage To use

Carlo Marinangeli 847 Dec 30, 2022
Parallax ScrollView and ListView for Android

Parallax Scrolls Parallax ListView and ScrollView for Android This project includes ScrollView with one or more parallaxed views ListView with paralla

Nir Hartmann 851 Dec 3, 2022
Android library to display a ListView whose cells are not rigid but flabby and react to ListView scroll.

FlabbyListView This library is not maintained anymore and there will be no further releases Android library to display a ListView which cells are not

JPARDOGO 762 Nov 23, 2022
Awesome Listview filter functionality in Android.

About Awesome Listview filter functionality in Android. See it in Action: https://www.youtube.com/watch?v=RO54U1ES5CA Listview with beautiful transpar

Bhavya  Mehta 446 Nov 20, 2022
Android library that allows you to bind a LinearLayout with a ListAdapter.

LinearListView Android library that allows you to bind a LinearLayout with a ListAdapter. Download Gradle: dependencies { compile 'com.github.franki

Francesco Sardo 571 Dec 22, 2022
Bringing extended scrolling features to Android's native ListView and ExpandableListView.

About QuickScroll QuickScroll is a library aimed at creating similar scrolling experiences to the native Contacts app's People view. It has the same s

Andras Kindler 461 Nov 11, 2022