Skip to main content

Home/ Android Dev/ Group items tagged lazy load

Rss Feed Group items tagged

Vincent Tsao

Android - How do I do a lazy load of images in ListView - Stack Overflow - 2 views

  • public class DrawableManager { private final Map drawableMap; public DrawableManager() { drawableMap = new HashMap(); } public Drawable fetchDrawable(String urlString) { if (drawableMap.containsKey(urlString)) { return drawableMap.get(urlString); } Log.d(this.getClass().getSimpleName(), "image url:" + urlString); try { InputStream is = fetch(urlString); Drawable drawable = Drawable.createFromStream(is, "src"); drawableMap.put(urlString, drawable); Log.d(this.getClass().getSimpleName(), "got a thumbnail drawable: " + drawable.getBounds() + ", " + drawable.getIntrinsicHeight() + "," + drawable.getIntrinsicWidth() + ", " + drawable.getMinimumHeight() + "," + drawable.getMinimumWidth()); return drawable; } catch (MalformedURLException e) { Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e); return null; } catch (IOException e) { Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e); return null; } } public void fetchDrawableOnThread(final String urlString, final ImageView imageView) { if (drawableMap.containsKey(urlString)) { imageView.setImageDrawable(drawableMap.get(urlString)); } final Handler handler = new Handler() { @Override public void handleMessage(Message message) { imageView.setImageDrawable((Drawable) message.obj); } }; Thread thread = new Thread() { @Override public void run() { //TODO : set imageView to a "pending" image Drawable drawable = fetchDrawable(urlString); Message message = handler.obtainMessage(1, drawable); handler.sendMessage(message); } }; thread.start(); } private InputStream fetch(String urlString) throws MalformedURLException, IOException { DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet request = new HttpGet(urlString); HttpResponse response = httpClient.execute(request); return response.getEntity().getContent(); } }
  •  
    shared by Altchen
  •  
    呵呵.我看那框那么小还不太敢复制代码.= =!
Vincent Tsao

Lazy Loading Images in a ListView - consensus approach? - Android Developers | Google G... - 0 views

  • I haven't looked in details at the 3 other approaches but I know that a big difference between what I do in Shelves and what I've seen done in other places is how user interaction is handled. Shelves listens to scroll events on the ListView and tries to identify taps vs scrolls vs fling to always give priority to the UI. For instance, when you touch the screen to stop a fling, Shelves starts loading images, but does so only after a very short delay so that if you are touching the screen to fling some more, the fling animation won't stutter because of the extra work load. But that's details.
    • Vincent Tsao
       
      From Romain Guy, the author of Shelves app
Vincent Tsao

Exploring the world of Android :: Part 2 « JTeam Blog / JTeam: Enterprise Jav... - 1 views

  • But in practice, you will notice that the AsyncTask is limited to 10 threads. This number is hardcoded somewhere in the Android SDK so we cannot change this. In this case it’s a limitation we cannot live with, because often more than 10 images are loaded at the same time.
    • Vincent Tsao
       
      使用AsyncTask类开辟的线程还有数量限制?必须小于10,这个倒是以前没有注意到的,要看看源代码怎么实现的
  • I’ve shown you how to improve performance of a ListView in three different ways: By loading images in a seperate thread By reusing rows in the list By caching views within a row
  • ...1 more annotation...
  • Notice that I used a SoftReference for caching images, to allow the garbage collector to clean the images from the cache when needed. How it works: Call loadDrawable(imageUrl, imageCallback) providing an anonymous implementation of the ImageCallback interface If the image doesn’t exist in the cache yet, the image is downloaded in a separate thread and the ImageCallback is called as soon as the download is complete. If the image DOES exist in the cache, it is immediately returned and the ImageCallback is never called.
  •  
    这个帖子完美解决了Image lazy load的性能问题, it works~
Vincent Tsao

[Disccuss] lasy load of images in ListView - 2 views

ah~ ,看来Diigo groups展示代码的样式得改进了.....

android "lazy load" listview tech

Vincent Tsao

List view with textviews and imageview, best practices - Android Developers | Google Gr... - 0 views

  • 1. you can look at the video from Google IO conference 2009, called Turbo charging your UI's by Romain Guy; he discussed some of the optimizations you can do when working with ListViews. 2. You can read Mark Murphy's series of ListView tutorials at android guys titled Fancy ListViews: http://www.google.co.in/url?sa=t&source=web&ct=res&cd=4&ved=0CBYQFjAD...
Kiran Kuppa

Image Loading Library - 0 views

  •  
    "In this part, we are going to talk about some image libraries using which we can load image(s) asynchronously, can cache images and also can download images into the local storage."
Kiran Kuppa

Card UI - 0 views

  •  
    "Ever wondered about Google play store UI which is built around cards. Card is nothing but a single row item of ListView or GridView. As depicted below, card can be of various sizes and can be either app card, movie, books, games or app suggestions card or birthday card or even it can be a simple list/grid item too. The main benefit of designing app with card UI is it gives consistent looks throughout the application, doesn't matter whether it gets loaded in mobile or tablet."
1 - 11 of 11
Showing 20 items per page