Sample android application to visualize restaurant list provided via JSON file.
The goal of this test is to implement a sample project, where you visualize a restaurant list. You are able to sort the restaurant list based on its current openings state, you can favorite a restaurant and you can select a sort value to further sort the list. Finally we would like to see you add the option to filter the restaurant list, based on a restaurant’s name. In the attachments you can find a JSON file (sample.json), this file contains all the necessary data to complete this assignment. Parse the JSON file and use it for the visualization and sorting of the list. Use the following priority of the sorting (from the highest to the lowest priority):
- Favorites: Favorite restaurants are at the top of the list; your current favorite restaurants are stored locally on the phone.
- Openings state: Restaurant is either open (top), you can order ahead (middle) or a restaurant is currently closed (bottom). (Values available in sample.json)
- Sort options: Always one sort option is chosen and this can be best match, newest, rating average, distance, popularity, average product price, delivery costs or the minimum cost. (Values available in sample.json)
- Filtering: It’s up to you how you how you want to search by restaurant name.
- Please visualize the name of the restaurants, the current opening state, the selected sort, the sort value for a restaurant and if it’s a favorite or not.
- Remember if you have multiple favorite restaurants, they are also sorted based on their current openings state and current selected sort.
- We expect valid test cases
- Readme file with all the needed information, how to get the sample project working and verify the test cases.
A native android application will be created from scratch. Kotlin will be used as main development language. The application will contain android architecture components such as ViewModel, Repository, LiveData, Room, etc. Following diagram will be used as reference which shows basic form of MVVM architecture.
The application will read JSON content from sample.json. Thanks to GSON library this content will be converted into Kotlin data classes.
As dependency injection, Dagger-Hilt library will be used. Dagger-Hilt takes care of injecting members into the Android class as well as handling and instantiating the proper Hilt components at the right point in the lifecycle. Dagger-Hilt library will provide Singleton instances of Room database and DAO. Room is where storing data locally and data access object (DAO) contains functions for database queries.
Repository object will be responsible to retrieve data from data sources and provide this data to ViewModel. Coroutines and suspend functions will be used for running background operations.
Main Activity is the main UI which all user interactions will be handled and also restaurants list will be displayed in MainActivity.
Spinner UI element is used for sorting options. Spinners provides a quick way to select one value from sorting options. In the default state, "bestMatches" used for restaurant list. Touching the spinner displays a dropdown menu with all other available values which can be;
- best match
- newest
- average
- distance
- popularity
- average product price
- delivery costs
- the minimum cost.
Similar to WhatsApp app search toolbar added for search(or filtering) functionality. Text changes in search field is applied to restaurant list and if any Restaurant has name contains queried text, then these items will be listed in RecyclerView.
A compressed apk file build and added to /output/apk directory. This apk can be installed easily and used to run application.
This application uses the Gradle build system. To build this project use "Import Project" in Android Studio and use the following command.
> gradlew build
Test suite class (UITestSuite.class) created to run all instrumentation test cases with single click. Following command can be used to run all test cases.
> adb shell am instrument -w -m -e class 'ercanduman.visualizerestaurant.UITestSuite' ercanduman.visualizerestaurant.test/ercanduman.visualizerestaurant.HiltTestRunner
Notice: Before running command make sure that your device is up and running. To check running devices following command can be used.
> adb devices
Running all tests: adb shell am instrument -w ercanduman.visualizerestaurant.test/ercanduman.visualizerestaurant.HiltTestRunner
Running all tests in a MainActivityTest: adb shell am instrument -w -m -e debug false -e class 'ercanduman.visualizerestaurant.ui.main.MainActivityTest' ercanduman.visualizerestaurant.test/ercanduman.visualizerestaurant.HiltTestRunner
Running a single test in MainActivityTest: adb shell am instrument -w -m -e debug false -e class 'ercanduman.visualizerestaurant.ui.main.MainActivityTest#test_check_if_recyclerView_displayed' ercanduman.visualizerestaurant.test/ercanduman.visualizerestaurant.HiltTestRunner
All classes and functions comment added.
Happy coding! 👍 🥇
ENB Creative, Copyright (C) 2020