Slide 1

Slide 1 text

Smoothie!

Slide 2

Slide 2 text

Lucas Rocha @lucasratmundo • +LucasRocha

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

AdapterView Children provided by an Adapter. View recycling support. ListView and GridView.

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

AsyncListView Encapsulates async logic. Behaves exactly like a ListView. AsyncGridView is analogous. 1

Slide 11

Slide 11 text

ItemLoader 1. Fetch parameters 2. Memory load 3. Async load (Off main thread) 4. Display API assumes loaded items are cached in memory. 2

Slide 12

Slide 12 text

SimpleItemLoader 2

Slide 13

Slide 13 text

ItemManager Defines the async loading behaviour for an AsyncListView. ItemManager.Builder sample here 3

Slide 14

Slide 14 text

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.

Slide 15

Slide 15 text

Preloading Improve perceived performance by showing placeholders less often. Load off-screen items ahead of scroll position.

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

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.

Slide 19

Slide 19 text

Implementation Custom ThreadPoolExecutor. Dynamic priorities as the user scrolls the view. Checkpoints to invalidate obsolete async operations.

Slide 20

Slide 20 text

That's all! Questions?