-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AC-819 Added repository layer for formAdmission package #784
Conversation
@f4ww4z Please review !! |
Codecov Report
@@ Coverage Diff @@
## master #784 +/- ##
==========================================
+ Coverage 13.69% 13.88% +0.19%
==========================================
Files 226 224 -2
Lines 9221 9194 -27
Branches 887 887
==========================================
+ Hits 1263 1277 +14
+ Misses 7861 7817 -44
- Partials 97 100 +3
Continue to review full report at Codecov.
|
can you rebase your branch with master and see if the PR passes the continuous-integration test as this fails in the latest commit at 0cdbaea . if not, then we might need a fix for that |
@rishabh-997 actually I rebased with master before making a PR will check again!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LuGO0 Good work, please address my comments.
openmrs-client/src/main/java/org/openmrs/mobile/api/repository/ProviderRepository.java
Outdated
Show resolved
Hide resolved
openmrs-client/src/main/java/org/openmrs/mobile/api/repository/ProviderRepository.java
Outdated
Show resolved
Hide resolved
|
||
import java.util.List; | ||
|
||
public interface CustomEncounterResponseCallback { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename the file and class to EncounterResponseCallback
. Also start using Kotlin, convert this file to Kotlin please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also extend from DefaultResponseCallbackListener
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@f4ww4z will it be possible to do I think we wont be able to override methods with different signatures if we extend from DefaultResponseCallbackListener
, maybe I couldnt get it can you explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LuGO0 You just need to extend from the default callback so the onErrorMessage
is consistent for all callbacks, and onResponse
can be customized. Try this:
interface EncounterResponseCallback: DefaultResponseCallbackListener {
fun onResponse(encounterRoleList: List<Resource?>?)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then there would be 2 onResponse
's to implement, just leave the default empty-parameter one empty for now.
public void getLocation(String url) {
providerRepository.getLocation(restApi, url, new LocationResponseCallback() {
@Override
public void onResponse(List<LocationEntity> locationList) {
view.updateLocationAdapter(locationList);
}
@Override
public void onResponse() {
}
@Override
public void onErrorResponse(String errorMessage) {
view.showToast(errorMessage);
view.enableSubmitButton(false);
}
});
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could theoretically use this way instead, then it would also mean we don't need to write the custom callbacks, the default callback with class type parameter is enough. Thoughts @LuGO0 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@f4ww4z if I am getting you correctly, then should I declare the interface methods in default callback listener as default so that when we override it there wont be any empty method like the onResponse
above ??
I am doing this locally for now, just confirm this for me and I will push in the final changes 👍 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could theoretically use this way instead, then it would also mean we don't need to write the custom callbacks, the default callback with class type parameter is enough. Thoughts @LuGO0 ?
@LuGO0 This is for the near future, we can refactor later. Right now it's ok to just inherit from the default callback and make a custom onResponse
for each interface, according to what resource want to get.
...ient/src/main/java/org/openmrs/mobile/listeners/retrofit/CustomLocationResponseCallback.java
Outdated
Show resolved
Hide resolved
openmrs-client/src/main/java/org/openmrs/mobile/listeners/retrofit/LocationResponseCallback.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LuGO0 See my comments and take care of the merge conflict.
openmrs-client/src/main/java/org/openmrs/mobile/listeners/retrofit/EncounterResponseCallback.kt
Outdated
Show resolved
Hide resolved
openmrs-client/src/main/java/org/openmrs/mobile/listeners/retrofit/EncounterResponseCallback.kt
Outdated
Show resolved
Hide resolved
openmrs-client/src/main/java/org/openmrs/mobile/listeners/retrofit/LocationResponseCallback.kt
Outdated
Show resolved
Hide resolved
openmrs-client/src/main/java/org/openmrs/mobile/listeners/retrofit/LocationResponseCallback.kt
Outdated
Show resolved
Hide resolved
1. Added and fixed violations of repository layer Abstraction 2. converted callback interfaces into kotlin 3. Added default method to default interface to handle extensions gracefully without empty methods 4. renamed custom callbacks for uniformity
@f4ww4z the build fails but I think its because some dependency repo returns error code 503 and maybe is down can you see and confirm for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LuGO0 Clever use of the default
keyword. LGTM
Description of what I changed
Issue I worked on
JIRA Issue: https://issues.openmrs.org/browse/AC-819
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)