Skip to content

Instantly share code, notes, and snippets.

@isneesh
Last active August 29, 2015 14:01
Show Gist options
  • Save isneesh/73978c47f4ce606c9ff5 to your computer and use it in GitHub Desktop.
Save isneesh/73978c47f4ce606c9ff5 to your computer and use it in GitHub Desktop.
Android UI practices

Callbacks

  • Use UICallback to attach to ListenableFutures, whenever you want to do work on UI thread
  • Use NonUICallback to attach to ListenableFutures, whenever you do not want to do work on UI thread

Events

  • Use UIThreadEventHandler to attach to Event, whenever you want to do work on UI thread
  • Use BackgroundEventHandler to delegate work away from UI thread - this is a single threaded executor to ensure sequence

Long running UI tasks

  • Use AsyncTask when you want to do longer running work, like sorting, and need results back on the UI thread

If you have any other use case that is not covered here, discuss.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment