Eye em potato_library_presentation

1,377 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,377
On SlideShare
0
From Embeds
0
Number of Embeds
1,033
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Eye em potato_library_presentation

  1. 1. POTATO POTATO page 1
  2. 2. Why Potato?SQL is so 80’s. Wake me up before you: • Map objects to tables • Write serializers • Write queries • Implement content provider schemes POTATO page 2
  3. 3. Potato v. Android Application needs: • Fetch data from web service • Persistence • UI that relies on objects POTATO page 3
  4. 4. Android API • SQLite - SQLiteOpenHelper - DB Schema - Cursor - ContentValues • ContentProvider • Loader • ListView • Observer POTATO page 4
  5. 5. Potato • Storage - Storage.List - Subscriptions • Poll • PollListView POTATO page 5
  6. 6. Storage• Non-volatile storage via json serialization• Based on generic lrucache<string,t> (least recently used) - size device dependent• Push(t object)• Delete(string id)public class UserStorage extends Storage<User> {.... @Override public String id(User user) { return user.getId(); }...} POTATO page 6
  7. 7. Storage.List• A section of storage• Obtain list from storage• Implements java.Util.List<t>Storage<User>.List friends = UserStorage.obtainList(Const.LIST_FRIENDS);Storage<User>.List followers = UserStorage.obtainList(Const.LIST_FOLLOWERS); POTATO page 7
  8. 8. Storage.Subscription List• Subscribe for a single object or list• React to different actions (PUSH, DELETE … )UserStorage.getInstance().obtainList(Const.LIST_FOLLOWERS).subscribe(new Storage.Subscription() {@Override public void onUpdate(Action action) { mFollowerLabel.post(new Runnable() { @Override public void run() { ... } }); }}); POTATO page 8
  9. 9. Storage.Subscription ObjectUserStorage.getInstance().subscribe(mUserId, new Subscription() { @Override public void onUpdate(Action action) { mUserLabel.post(new Runnable() { @Override public void run() { ... } }); }}); POTATO page 9
  10. 10. PollWhat can it do for you?• Associated to a storage.List• Fetch new data• Fetch old data• States OK / NO_CONTENT / ERROR POTATO page 10
  11. 11. PollWhat you have to do...• setStorage(Storage<T>.List storage)• ArrayList<User> newItems()• ArrayList<User> oldItems()• int appendNewItems(ArrayList<T> newItems, Listener listener, boolean cleanUp)• int appendOldItems(ArrayList<T> newItems, Listener listener) POTATO page 11
  12. 12. PollListView• Extends com.handmark.pulltorefresh.PullToRefreshListView• Bound a poll with a ListView - new data on pull to refresh - old data on scroll• Subscribes for poll’s Storage.List• Attached to Activity/Fragment lifecycle - save/load/update• Different adapters related to poll state POTATO page 12
  13. 13. Potato structure Storage Most used object object object object Storage.List object object object object object object Storage.List Less used object object object object object object Storage.List object object object object object Storage.List object Subscribe to events coming from lists or individual items POTATO page 13
  14. 14. Performance diagram POTATO page 14
  15. 15. Interaction diagram API Poll Storage.List PollListView AnimatedPollAdapter 1. update (UI) (UI) 2. API call return data 3. add Upfront { 4. notify DataWillUpdate Event is published over subscription model 5. notify DataSetChangedWithAction notify DataSetChanged POTATO page 15
  16. 16. Extra potatoPotato can do even more POTATO page 16
  17. 17. Example POTATO page 17
  18. 18. Pota TO DO:• Object revisioning ( createdAt / updatedAt )• More work on UI• Java code generation with universal Boll (to any API) POTATO page 18
  19. 19. EndFork the potatohttps://github.com/eyeem/PotatoLibrary Tobias Heine tobi@eyeem.com @tobias_heine Łukasz Wisniewski lukasz@eyeem.com @vishna POTATO page 19
  20. 20. Join us in building thefuture of photo discoveryWe’re always looking for passionate iOs, Android, Backend, Frontendand DevOps engineers.Jobs@EyeEm.com POTATO page 20

×