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. Potato v. Android
Application needs:
• Fetch data from web service
• Persistence
• UI that relies on objects
POTATO page 3
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. 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. 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
10. Poll
What 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. Poll
What 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. 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. 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
18. Pota TO DO:
• Object revisioning ( createdAt / updatedAt )
• More work on UI
• Java code generation with universal Boll (to any API)
POTATO page 18
20. Join us in building the
future of photo discovery
We’re always looking for passionate iOs, Android, Backend, Frontend
and DevOps engineers.
Jobs@EyeEm.com
POTATO page 20