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

Introducing Smoothie

1f461eee0b22011d0bccf4e882d9149f?s=47 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


  1. Smoothie!

  2. Lucas Rocha @lucasratmundo • +LucasRocha

  3. 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
  4. AdapterView Children provided by an Adapter. View recycling support. ListView

    and GridView.
  5. http://bit.ly/listview-perf How ListView works

  6. Async in ListView Async vs View recycling. Trivial to implement.

  7. Non-trivial bits Gesture awareness. Preloading off-screen items. Multi-part items.

  8. 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
  9. 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
  10. AsyncListView Encapsulates async logic. Behaves exactly like a ListView. AsyncGridView

    is analogous. 1
  11. 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
  12. SimpleItemLoader 2

  13. ItemManager Defines the async loading behaviour for an AsyncListView. ItemManager.Builder

    sample here 3
  14. 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.
  15. Preloading Improve perceived performance by showing placeholders less often. Load

    off-screen items ahead of scroll position.
  16. 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
  17. None
  18. 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.
  19. Implementation Custom ThreadPoolExecutor. Dynamic priorities as the user scrolls the

    view. Checkpoints to invalidate obsolete async operations.
  20. That's all! Questions?