Arch change - use event mechanism to synchronise fragments #66
Description
So far to avoid bringing in too many dependencies we havne't had a separate event bus to trigger syncs between note edit/compose and note list, relying on onActivityResult to do it. This is now causing problems:
- Using onActivityResult doesn't work between fragments on the same screen (as a tablet layout would have) and would require extra tablet-specific code to do the syncs
- Going straight to a NoteAcitivty without creating it from NoteListFragment.startActivityForResult means NoteListFragment never gets the result code.
Simplest way to clear this problem is to integrate EventBus https://github.com/greenrobot/EventBus, and have syncs handled like that. The SyncManager and NoteFragment would both trigger a NoteFragmentChanged event at the point that they have updated the disk state. This could be a sticky event, that contains the timestamp. Any fragment that subscribes to it would get the most recent changed timestamp, and could compare it with the last time it ran notifyDataSetChanged, to determine if it needs to again. startActivityForResult can then be removed.
There may be other mechanisms that might be better, discussion here for any that have an opinion.