I came across an early post regarding lazy loading image in listview, and tried to experiment with a posted answer(the 1st answer with a green check). Lazy load of images in ListView.
However i am still confused with 2 things:
what is the definition of 'lazy loading' in a list view? From what i thought before on UI perspective, if the item images are stored locally in phone, 'lazy loading' means you do not start to load the list item until user can see or scroll to that item (when items are more than 1 screen). But here, with image stored in remote url, it seems to means that 'an image is loaded from url 1st time, afterwards will load from local cache', is this the idea of 'lazy' here?
in the 1st answer in the post, the DrawableManager.fetchDrawable() method can not be used in the getView() method of listview adapter directly, it seems. I am getting below error msg from ddms log (see below), and it's saying sth about 'NetworkOnMainThreadException'. So how can DrawableManager.fetchDrawable() be use in listview here? is it true that only a thread based implementation like DrawableManager.fetchDrawableOnThread() can be used in a list adapter's getView() function?
Could you share some thoughts on these question? Appreciate it.
10-25 04:52:43.628: E/AndroidRuntime(2231): FATAL EXCEPTION: main
10-25 04:52:43.628: E/AndroidRuntime(2231): android.os.NetworkOnMainThreadException
10-25 04:52:43.628: E/AndroidRuntime(2231): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1084)
10-25 04:52:43.628: E/AndroidRuntime(2231): at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
10-25 04:52:43.628: E/AndroidRuntime(2231): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
10-25 04:52:43.628: E/AndroidRuntime(2231): at java.net.InetAddress.getAllByName(InetAddress.java:220)
10-25 04:52:43.628: E/AndroidRuntime(2231): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
10-25 04:52:43.628: E/AndroidRuntime(2231): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
10-25 04:52:43.628: E/AndroidRuntime(2231): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
10-25 04:52:43.628: E/AndroidRuntime(2231): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
10-25 04:52:43.628: E/AndroidRuntime(2231): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
10-25 04:52:43.628: E/AndroidRuntime(2231): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
10-25 04:52:43.628: E/AndroidRuntime(2231): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
10-25 04:52:43.628: E/AndroidRuntime(2231): at com.example.fairfax.MainActivity$DrawableManager.fetch(MainActivity.java:230)
10-25 04:52:43.628: E/AndroidRuntime(2231): at com.example.fairfax.MainActivity$DrawableManager.fetchDrawable(MainActivity.java:187)
10-25 04:52:43.628: E/AndroidRuntime(2231): at com.example.fairfax.MainActivity$LazyAdapter.getView(MainActivity.java:162)