Android application to list nearby restaurants
This application uses MVVM architecture using Android architecure components like ViewModel
- Kotlin
- Retrofit
- RxJava
- Dagger2
- MockWebServer
The application uses Foursquare api to show nearby restaurants on Google Map. The key for Foursquare Api and Google maps are defined in gradle.properties
You need to add below keys to the gradle.properties
- client_id
- client_secret
- google_maps_key
In build.gradle file the string resources are created during compile time and used in the application.
- FourSquare venue search
Used Retrofit to retrieve the nearby restaurants. Currently this app uses FourSquare userless authentication method.
The Client Id and secret are added to in the interceptor instead of adding it in the network controller.
In future if we need to change the authentication mode we will make changes to the creds interceptor instead of the controller.
Also added error interceptor to log Api failures to Google Analytics or to Crashlytics
Tested this layer using MockWebServer.
Network controller makes the API call and transforms the data from the Api to data Model which is to be used across the application.
The intention of having the data transformation is to minimize the changes when API contract is changed in future.
The purpose of using the view model is to manage the data when the application undergo's lifecycle changes. Reason being not to make the Api calls on screen orientation unless there is a change in the Map events and also updates the UI upon new data from the API.
The application is a Single activity application Activity Currently the Map Fragment is added statically in the Activity layout file. And all the logic of loading the map with restaurants are added to MapViewController The best way to scale the application is to add the map fragment dynamically.
The users current location is fetched using the Current Location Service
The Main Activity extends Restaurant Base Activity. Added the logic to ask for location permission in the application.
All common views will be added to the base activity.
The logic to retrieve new API data is based on the user interaction with the application. Implemented GoogleMap camera state listener for idle, upon calcuating the bounds of the viewable map will determine the distance from the users current location.
- Device location is always enabled.
- The user will be able to see the list of restaurants around him.