projectbuendia / client

Android client app
Apache License 2.0
38 stars 23 forks source link

Rework the LocationForest for robustness, making all location lists dynamic #443

Closed zestyping closed 5 years ago

zestyping commented 5 years ago

Internal changes

The Location object now only contains information about the current location; all information about the relationships between locations now resides in the LocationForest. This fixes the semantics of comparing Location objects and creates a clear division of responsibility.

The logic for reloading and updating the LocationForest is factored into a new LocationProvider class. Listeners for these two events are now at different levels, where they belong. Reloading is considered a replacement of the entire forest, which is an event on the LocationProvider. Updating patient counts is considered a mutation of the forest, which is an event on the forest.

Handling these events sanely makes it possible for all locations and patient counts in the user interface to pick up changes promptly and coherently.

Verification performed

I tried moving patients on one tablet while viewing the locations on another. Patient counts updated properly. Even in the location assignment dialog, the locations and their counts are updated dynamically.

I tried adding, renaming, reparenting, and deleting locations in the OpenMRS web portal while the app was open on the tablet. The location boxes correctly appeared, disappeared, and rearranged themselves quickly and appropriately.