Commute Sample is android application that display the list of vehicle and all the related information available in response. List of vehicles includes Taxi & Pool Vehicles from the nearby area. It also includes maps that show the points where the vehicle is available and whenever the user selects any vehicle it shows a window where all the information regarding the vehicle is displayed. Users can also get routes from Source to Destination on click of a window in Maps
Pre-requisites
✔️ Android studio installed in your system.
✔️ Android Device or Emulator to run your app.
Setup 🔨
- You can clone the project using below line in your command prompt or download it directly.
git clone https://github.com/dwarshb/Commute.git
Once the setup is done you can run the project in Android Studio.
Technical Details
👉 Currently, it uses https://fake-poi-api.mytaxi.com API to get a list of vehicles.
👉 Commute Sample App uses the API during SplashActivity and once data get fetched successfully, it passes the data to MainActivity. MainActivity includes BottomSheetNavigator with two Fragments "VehicleListFragment & DashboardFragment".
👉 VehicleListFragment is used to display the list of vehicles received in response. It arranges the list from String format using the below method which takes String as a parameter and returns a list of vehicles.
Utils.parseJSONToList(jsonObject: String)MutableList<Vehicle>
👉 Once VehicleListFragment
receives the list, it sets the same list to VehicleListAdapter
which handles the view of each vehicle item in the list. VehicleListAdapter
is a subclass of RecyclerView.Adapter which includes certain native methods that bind the data with UI. On click of each vehicle list item, a MapsActivity
will be opened which will help to display the current position of the vehicle with its bound, and at the top window will be displayed which shows information regarding the vehicle. If users wish to get navigation from Source to Destination then, they can click on Window at the top which will redirect them to Google Maps App with Source & Destination Information.
Folder Structure
📁 data/
📄 data/API.kt - API class is used to query the API used within App. It adds parameters such as
p1Lat={Latitude1}&p1Lon={Longitude1}&p2Lat={Latitude2}&p2Lon={Longitude}
in the API.📄 data/Vehicle.kt - Vehicle is a data class that is used to handle each item of the vehicle list.
📁 domain/
- 📄 domain/FetchVehicles.kt - This method is used to execute the API. It passes the required data and returns the response.
📁 presentation
-
presentation/mainScreen/ui/vehicle/
- 📄 VehicleFragment.kt - VehicleFragment is used to display a list of vehicles fetched from API. With the help of VehicleListViewModelit manages the list and helps to filter it based on its parameter. It also includes VehicleListAdapter which is used to manage each item of vehicles. On click of each item in VehicleList. It will open MapsActivity which will display the current position of the vehicle and other information.
- 📄 VehicleListViewModel.kt - VehicleListViewModel is used to handle the operation which is used to manage VehicleListFragment.
- 📄 VehicleListAdapter.kt - VehicleListAdapter is an Adapter class that is used to manage the list of vehicles. It is used to manage each item of the vehicle list and perform required operations such as OnItemClick. ---
📄 presentation/mainScreen/ui/FilterActionSheet.kt - FilterActionSheet is subclass of BottomSheetDialogFragment which is used to display filter operations for the vehicle list shown in VehicleListFragment.
📄 presentation/mainScreen/MainActivity.kt - It is Main Screen that includes BottomNavigationBar to navigate between two fragments i.eVehicleFragment& DashboardFragment
-
presentation/mapScreen/
- 📄 MapsActivity.kt - MapsActivity is used to display various vehicles from the list to the map. It shows the vehicle icon at the designated position and displays its information. Whenever the user selects any marker from the map, then it will redirect the camera of the map to its location. Also on click of the dialog shown at the top, google will be opened with the route of that direction which includes origin & destination as well.
- 📄 MapsViewModel.kt - MapsViewModel is a class that is used to handle the operation of MapsActivity
-
presentation/splashScreen/
- 📄 SplashActivity.kt - SplashActivity is the Entry Point of an application. It displays loading animation on the app icon till the data gets fetched from API successfully.
- 📄 SplashViewModel.kt- SplashViewModel is used to get the trigger the fetch request from the API.
📄 presentation/App.kt- It is a custom application class that can be used to perform global operations in future
📄 presentation/NetworkErrorException.kt - It is a subclass of the Exception class that is used to parse Network-related errors and help to bind the response with UI.
📄 presentation/State.kt - It is used to handle the Loading, Error & Success State whenever API operation is performed
📁 utils
- 📄 utils/Constants.kt - It contains the constant's value used across apps.
- 📄 utils/DI.kt - It contains all the required functionality to make retrofit calls easier and more convenient to understand.
- 📄 utils/Utils.kt - Utils class is used to handle the independent operations. It is used accross app.
Libraries
//required if you want to use Espresso Test
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
//UI Automator
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
// required if you want to use Mockito for unit tests
testImplementation 'org.mockito:mockito-core:3.7.7'
// required if you want to use Mockito for Android tests
androidTestImplementation 'org.mockito:mockito-android:3.7.7'
//Co-routines Dependency
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
//Hilt Dependencies
implementation 'com.google.dagger:hilt-android:2.35'
kapt 'com.google.dagger:hilt-android-compiler:2.35'
//Retrofit Dependencies
implementation"com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
//Google Play Services
implementation "com.google.android.gms:play-services-places:$playServicesVersion"
implementation "com.google.android.gms:play-services-maps:$playServicesVersion"
implementation "com.google.maps.android:android-maps-utils:0.4+"
implementation "com.google.android.gms:play-services-location:$playServicesVersion"
//Dooka Documentation
dokkaGfmPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.6.10")
TestCases
The project contains required testcases that will help us to test the app thoroughly.
⛏️ TestSuite.kt - It is a suite of test cases files that runs multiple test cases sequentially.
⛏️ SplashActivityTest.kt - It is a test case file that includes tests related to SplashActivity. It checks whether apps get loaded in 5 seconds, 10 seconds, or 15 seconds.
⛏️ MainActivityTest.kt - It is a test case file that includes tests related to VehicleFragment which is part of MainActivity. It checks whether the data is loaded properly in the list or not. It also checks whether data is getting filtered properly based on certain filter parameters.
⛏️ MapsActivityTest.kt - It is a test case file that includes tests related to MapsActivity. It checks whether the operation performed on the marker are working fine.
Screenshots
Github Repo
Commute
Commute Sample display the list of vehicle and all the related information available in response. It also includes maps that show the points where the vehicle is available and whenever the user selects any vehicle it shows a window where all the information regarding the vehicle is displayed. Users can also get routes from Source to Destination on click of a window in Maps.
Pre-requisites
Setup 🔨
- You can clone the project from the Commute repository.
git clone https://github.com/dwarshb/Commute.git
Once the setup is done you can run the project in Android Studio.
Documentation
Check below links to learn more about this project
Top comments (0)