AC-829 Fixed crash at admission form by using live data#804
AC-829 Fixed crash at admission form by using live data#804f4ww4z merged 1 commit intoopenmrs:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #804 +/- ##
=======================================
Coverage 13.47% 13.47%
=======================================
Files 238 238
Lines 9672 9672
Branches 928 925 -3
=======================================
Hits 1303 1303
Misses 8263 8263
Partials 106 106
Continue to review full report at Codecov.
|
| encounterRoles.setValue(response.body().getResults()); | ||
| } else { | ||
| encounterRoles.setValue(null); | ||
| } |
There was a problem hiding this comment.
@rishabh-997 how are we taking care of the UI responses to the user after the callback has been removed all the views which implemented this callback wont get any callback to handle ?
There was a problem hiding this comment.
We were using callbacks because we were not observing data. Now that I have changed return type to LiveData<T>, we don't need to use callbacks, the UI will simply observe results...
LiveData will allow the observer to be removed when the state of the corresponding Lifecycle object changes to DESTROYED. This is useful for activities and fragments because they do not need to worry about leaks—activities and fragments are instantly unsubscribed when their lifecycles are destroyed.
There was a problem hiding this comment.
yes @rishabh-997 actually i missed the changes you made in presenter I thought they were missing .
9670b99 to
c43dea8
Compare
Description of what I changed
We need to observe the encounter roles and locations using live data as in dark mode, activity is re-created immediately and the results cause NPE as the fragment is destroyed on which it needed to show.
Issue I worked on
JIRA Issue: https://issues.openmrs.org/browse/AC-829
Checklist: I completed these to help reviewers :)
(the number above, next to the 'Commits' tab is 1).
existing code that was well tested you do not have to add tests)