-
Description: Demo application to show long form for a given acronym. We are using http://www.nactem.ac.uk/software/acromine/rest.html API, no api-key required.
-
Design and architecture: App is desinged with single Activity approach in mind and navigation component, currently it has only one fragment, but it is easily scalable.
-
App uses following tech:
Wetworking - Retrofit
Networking - Coroutines
Jetpack - Navigation
DI - Hilt
DataBinding
JUnit - Testing -
How app is designed:
Retrofit object in injected to Repository class which is in charge of making a network call. Repository and response object are injected to ViewModel so it can setup LiveData variables based on response results for UI to observe. UI then decides which widgets to show. ViewModel is also injected into SearchFragment. Databinding is used for RecyclerView, but could not be used with search bar listeners due to complications from ViewModel injection. -
Notes and thoughts:
-
Testing:
1- Used Charles Proxy for mac to simulate slow commenction, no problems observed.
2- Tested across configuration changes, and sending app to background and bringing back to foreground to make sure it preserves the app state.
Please see: https://youtu.be/Rcs0OzhEWig
App does not run a query if internet is unavailable:
-
App ANR'ed only once during many dry runs, looking at the stack i believe this is due to pressure from starting emulator on my mac while having other processes running.
-
Wrote four unit tests, including:
1- Make sure reponse analyzer class is able to detect unauthorized response.
2- Make sure reponse analyzer class is able to detect empty body response.
3- Make sure reponse analyzer class is able to detect null response.
4- Make sure reponse analyzer class is able to detect OK response. -
Other thoughts and notes:
App has a clean build with one warning on generated hilt files, probably outside of author's control.
-
Possible improvements:
1- Use Room to cache results so we do not make a web call every time.
2- Use expose annotation to only filter for what we actually need.
3- Add timeout to Retrofit request.
4- Use Generic Api Response from Google samples and wrap Retrofit response.
5- Add Exception handling to Coroutine job.