Skip to content
This repository was archived by the owner on Nov 5, 2019. It is now read-only.
This repository was archived by the owner on Nov 5, 2019. It is now read-only.

Arch change - use event mechanism to synchronise fragments #66

Closed
@deftelf

Description

@deftelf

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:

  1. 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
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions