Android Assignment

Authored by Prafulla Thottasseri

A simple app which displays a list of restaurants from a stored JSON, ordered by opening status, favorites and filter chosen from the dropdown.

The list item displays the restaurant name, opening status and favorite/not indicator. A restaurant can be marked favorite/removed as favorite by clicking on the heart icon in the list.
On selection of an item it shows the details screen. Item details include the restaurant name, opening status, rating, distance, delivery costs and minimum order amount and favorite status.

  • The app is written entirely in Kotlin, using Android KTX. Android KTX is a set of Kotlin extensions that optimizes Jetpack architecture components and Android platform APIs for more concise and idiomatic Kotlin code.
  • The app is built using MVVM architecture with dependency injection using Hilt.
  • The app uses a single Activity with multiple Fragments. Transitions between fragments use the Navigation component and transition animation actions.
  • The screens use fragment layouts, are created using ConstraintLayout and Data Binding, and are scrollable when required to support smaller screen sizes.
  • JSON data from the sample JSON is saved into the Room database using coroutines and is surfaced to the UI through ViewModel.
  • GSON library is used for JSON parsing.
  • A Room database is used to save the information from JSON locally and handle sorting.
  • AppCompat is used to preserve key app functionality on older versions of Android.
  • The app UI is built to support phone and tablet.
  • Few tests are added for testing the database operations in RestaurantsDao and RestaurantDetailHostActivity and can be extended further. These are instrumented tests and need a device/emulator.
  • Lint check and ktlint plugin is used for optimizations and code styling.

The app has the following packages:

  1. di: It handles the dependency injection using Hilt.
  2. model: It contains the RestaurantRepository class and database package with relevant classes for saving the JSON data to a Room database.
  3. ui: It contains a RestaurantDetailHostActivity, adapter, fragments, util packages needed for the UI implementation.
  4. viewmodel: It contains the shared viewmodel called RestaurantsViewModel class that surfaces data to the UI via LiveData object. This is shared by the RestaurantListFragment and RestaurantDetailFragment.

Please note the below:

  • Please note that the distance, delivery and minimum cost are displayed as in the JSON and not converted to any metric systems.
  • Upgrading to latest espresso version in gradle gives dependency conflicts hence using 3.3.0 –


View Github