Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introducing Smoothie

Lucas Rocha
January 23, 2014

Introducing Smoothie

Smoothie is an open-source library that provides a simple API to load ListView/GridView items asynchronously, off the UI thread. Besides the obvious view recycling handling, Smoothie is gesture-aware and supports powerful features such as off-screen item pre-loading and multi-part items. In this session, you will get overview of Smoothie's features and implementation; and learn how to use it in your apps through a series of practical examples.

Lucas Rocha

January 23, 2014
Tweet

More Decks by Lucas Rocha

Other Decks in Technology

Transcript

  1. Android and me Firefox for Android http://bit.ly/firefox-for-android Pattrn Wallpapers http://bit.ly/pattrn-app

    Smoothie http://github.com/lucasr/smoothie TwoWayView http://github.com/lucasr/twoway-view
  2. Smoothie! Easy async item loading for ListViews with all these

    non-trivial bits built in. Factored out from Pattrn. Nice and simple API. Not an image-loading library. (But can be used to load images off UI thread) https://github.com/lucasr/smoothie
  3. How to use it Add an AsyncListView to your layout.

    Implement an ItemLoader with your app-specific logic for loading and displaying items. Instantiate an ItemManager with your ItemLoader and set it on the AsyncListView. 1 https://bit.ly/smoothie-intro 2 3
  4. ItemLoader <Params, Result> 1. Fetch parameters 2. Memory load 3.

    Async load (Off main thread) 4. Display API assumes loaded items are cached in memory. 2
  5. Gesture awareness Async loading is disabled while the ListView is

    scrolling with finger up. Async loading is only enabled when the ListView is either idle or scrolling with finger down. In-memory items are displayed immediately in any ListView state.
  6. Multi-part items Items that require multiple async operations to load.

    Sets relative priorities between item parts. Inherit from ItemLoader instead. loadItem() loadItemPart() → loadItemFromMemory() loadItemPartFromMemory() → displayItem() displayItemPart() → https://bit.ly/smoothie-multipart
  7. Limitations Hard to blend with libraries using custom ListViews or

    GridViews. Hard to blend with your existing async loading libraries e.g. Volley. Preloading logic assumes user is scrolling the list down. Single type for multi-part items.
  8. Implementation Custom ThreadPoolExecutor. Dynamic priorities as the user scrolls the

    view. Checkpoints to invalidate obsolete async operations.