This is an android app which talk to two dummy Apis a food tags comes in pages the page has eight tags each of which has a list of of food items which comes from the scond api in a static list of items this app mainly consists of two activities one for tags and it's items and the other one for the item details.
- I used MVVM with the modern architecture components in the architecture of the app and the new paging technology in the infinite tag list: because I'm using room the data layer handled in Room itself the data source and it's factory, I just implemented the Boundary Callback.
- The API retured name including the page number i.e.
1 - Pizza
I beautified the name and make it configurable throw the constant in Constants file so the default names are beautified if you need to see the api names just change the constant to true in the filecom.elmenus.assignment.constants.AppConstants
make the variable value to false:SHOW_BEAUTIFIED_NAMES = false
- The connection state changes are observed be noted that there are different states in offline mode:
- There is no cached data: you will see a dionsaur in this state after you getting online automatically we try loading data to get in this state make mobile offline in a fresh install and open the app
- There is cached data: you will see a snack bar tells you you're offline and whenever you get connected it will disappear
- Error handling, I didn't handled the error well, but I made two basic error handling:
- If there are a error in connecting or parsing data it will try up to 10 times to reconnect and get data
- If any error occures including the offline state while loading the list of items (not tags) you will see error message with retry button
- also if any loading of images errors occurred the error place holder image will be shown.
- There is always a room for improvments I like to begin with more test cases to cover more scenarios, also the item details needs some enhancements
- The Api needs a header of Content-Type to be Application/json which is only supposed to be needed in POST requests only, but it's seems it's removed as a condition in a request
- There is a fast splash screen with default wait time of a half second The main activity is big a little bit due to ui handling including show/hide errors and progress bars and views
- I named the app El-Menus with dash to be different from the elmenus app
- Naming: I'm not familiar with this kind of apps, you might be confused of names,btw I considerd the tags as FoodTags and list of items as TagItems or SelectedTagItems ^_^
- Retrofit Used as RESTful client,also I made the ok http client loges the apis response in only debug builds!
- Glide For loading and caching images
- Anko Used in:
- Multithreading & Background Work e.g.
doAsync{
.... coroutine to run in background thread
uiThread{
....coroutine to run in main thread
}
}
- Start activties e.g.
startActivity<MainActivity>()
- Room used to cache both of food tags and food items in a local sqlite database.
- https://developer.android.com/topic/libraries/architecture/paging/
- https://codelabs.developers.google.com/codelabs/android-paging/index.html
Thank you! ๐