Skip to content

Sample application that showcases displaying of transportation data.

License

Notifications You must be signed in to change notification settings

Zlate87/sample-transport-app

Repository files navigation

Sample Transport App

Build Status

Screenshot Screenshot Screenshot Screenshot

Intro

Sample application that showcases displaying of transportation data.

It shows:

  • Architecture base practices.
  • How to use RX java for long running tasks instead of AsyncTask.
  • How to work with JSON data.
  • How to handle models not appropriate for the views by introducing view models.
  • How to do simple data manipulation with joda-time.
  • Have compile time dependency injection with Dagger 2.
  • How to do JUnit tests with robolectric, mockito, how to mock final classes with powermock.
  • How to do UI tests with Espresso.
  • Working with flavors.
  • ...

It doesn’t show:

  • As you can see from the screenshots, how to create a fancy UI.
  • How to implement animations
  • How to read data from backend
  • ...

Developer Guide

The application has two flavors:

  • dummyData - It contains flavor specific routing service that will always return a dummy route from a JSON file that is pre-bundled with the application. This flavor allows testing independently from a backend
  • production - It is intended to have specific routing service that will retrieve data from a backend for given routing parameters. However at the moment the routing service is not implemented and it throws a RuntimeException and crashes the application.

Building

  • The application is using Dagger 2 for dependency injection. Since Dagger 2 works at compile time, some classes need to be generated. These classes are generated automatically and are not committed. Because of this, the project must be built once after it is cloned or Android Studio will show errors (missing Dagger generated classes).

  • The application is using Google Maps, and for it to work it needs Maps API key. The API key is committed (see google_maps_api.xml), but it works only if the application is signed with the signing key that the API key is for. The signing key is not committed (it is a secret :)). So in order for the maps to work properly you will need to generate a new API key that will be pared to your signing key. More about how to do this here.

Testing

The application has JUnit tests that focus on testing the services and Espresso tests that focus on testing the activities and UI elements by mocking the services. At the moment there are no end-to-end tests.

JUnit tests

The application comes with robolectric tests (more information about robolectric here). To run the robolectric tests, on the command line run:

gradlew test

Espresso tests

The application comes with espresso tests (more information about espresso here). To run the tests from gradle, on the command line run:

gradlew connectedAndroidTest

NOTE: when running the espresso tests, make sure that:

  • The animations are disabled on the device where the tests are running. More info here.
  • If running the tests on Android 6.0 or up, the ACCESS_FINE_LOCATION permission is granted. This can be done manually of using adb command:
 adb shell pm grant "com.zlate87.sample_transport_app.[FLAVOR_NAME]" android.permission.ACCESS_FINE_LOCATION

Third party libraries

Next Steps

For the next steps see the list of issues [here] (https://github.com/Zlate87/sample-transport-app/issues).

About

Sample application that showcases displaying of transportation data.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages