Skip to main content

Home/ Android Dev/ Group items tagged load

Rss Feed Group items tagged

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~
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."
Vincent Tsao

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

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

android "lazy load" listview tech

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
  •  
    呵呵.我看那框那么小还不太敢复制代码.= =!
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."
Vincent Tsao

Android Endless List - Stack Overflow - 0 views

  • 5 down vote accepted One solution is to implement an OnScrollListener and make changes (like adding items, etc.) to the ListAdapter at a convenient state in its onScrollStateChanged method. The following ListActivity shows a list of integers, starting with 40, adding 10 per scroll-stop.
  • public class Test extends ListActivity implements OnScrollListener {    Aleph0 adapter = new Aleph0();    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setListAdapter(adapter);         getListView().setOnScrollListener(this);    }    public void onScroll(AbsListView v, int i, int j, int k) { }    public void onScrollStateChanged(AbsListView v, int state) {        if(state == OnScrollListener.SCROLL_STATE_IDLE) {                adapter.count += 10;                adapter.notifyDataSetChanged();        }    }    class Aleph0 extends BaseAdapter {        int count = 40;        public int getCount() { return count; }        public Object getItem(int pos) { return pos; }        public long getItemId(int pos) { return pos; }        public View getView(int pos, View v, ViewGroup p) {                TextView view = new TextView(Test.this);                view.setText("entry " + pos);                return view;        }    }}
  • You should obviously use separate threads for long running actions (like loading web-data) and might want to indicate progress in the last list item (like the market or gmail apps do).
Vincent Tsao

ListView/ListActivity limit items until last item reached, like in Android Market - And... - 0 views

  • These applications use an OnScrollListener to detect when the last item is displayed. When this happens, they load more items and add them to the list adapter.
Vincent Tsao

Adding items to a ListView - Android Developers | Google Groups - 0 views

  • SizzlingSkizzorsProgrammer wrote: > After the listview is already initialized, is it possible to add items > to it during runtime? Just add the new items to the adapter, or the data source that backs up the adapter (if it's a CursorAdapter).
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...
Vincent Tsao

webView load Data problem - Android Beginners | Google Groups - 0 views

  • sagar wrote: > Hello, > I have following code to display webview's background. > wv.loadData("<html><body background=\"file:///android_asset/lbh.png > \">"+data[0],"text/html","utf-8"); > here the data[0] contains the data to be displayed... > Data is displayed fine.. > but background is not displayed. > I can only use this method..i dont knw why i can t access android > assets.. > I have placed that image in assets folder already.. Try loadDataWithBaseUrl() instead of loadData(), supplying some bogus value for the base URL (e.g., fake://why/o/why/is/this/needed).
    • Vincent Tsao
       
      用loadDataWithBaseURL接口才能访问asset中的资源文件,且baseurl不能为null
Vincent Tsao

Implementing "Pull To Refresh" in your Android App | Blog // Recursive Awesome // Table... - 1 views

  • For completeness we really should handle the possibility of the task getting cancelled. This can happen when the user navigates away from the app and the task is killed before its completed. This will cause the onPostExecute() method to not be called and so the onRefreshComplete() method won’t be called. Depending on how the user navigates through the app, they could return to this activity without going through the complete onCreate() lifecycle, and you’ll end up with the screen still showing the “loading” progress message in the header. This is common when using tabs between multiple ListViews. Also, the documented best practices for implementing an AsyncTask says that in long running background work you should periodically check if the task has been cancelled and try to gracefully quit your work and exit. So let’s get all of that in there.
1 - 17 of 17
Showing 20 items per page