Home

Awesome

<img alt="Icon" src="presentation/src/main/res/mipmap-xxhdpi/ic_launcher.png?raw=true" align="left" hspace="1" vspace="1">

<a alt='Buy Me a Coffee at ko-fi.com' href='https://ko-fi.com/T6T05M4O' target='_blank' align='right'><img align='right' height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi4.png?v=0' border='0' /></a> <a alt='Try it on Google Play' href='https://play.google.com/store/apps/details?id=com.andremion.theatre' target='_blank' align='right'><img align='right' height='36' style='border:0px;height:36px;' src='https://developer.android.com/images/brand/en_generic_rgb_wo_60.png' border='0' /></a>

Theatre

Pet project using Clean Architecture + MVVM + Reactive Extensions + Android Architecture Components.</br> The data is fetched from LondonTheatreDirect API.</br>

The main purpose is using the latest practices and libraries.

</br>

License Apache 2.0 minSdkVersion 16 compileSdkVersion 27 CircleCI codecov

<p align="center"> <img alt='Sample' src="https://raw.githubusercontent.com/andremion/Theatre/master/art/sample.gif"></br> <i>*Data from <a href='https://www.londontheatredirect.com/'>London Theatre Direct</a></i></br> <i>**UI inspired by <a href='https://www.uplabs.com/posts/cinema-club-interface'>Yaroslav Zubko</a>'s design</i> </p>

Architecture

Uses concepts of the notorious Uncle Bob's architecture called Clean Architecture.</br> The software produced by this architecture is going to be:

<img alt='Clean' src="https://raw.githubusercontent.com/andremion/Theatre/master/art/clean.png" align="right" width="50%"/>

The Dependency Rule

The overriding rule of this architecture says that the source code dependencies always point inwards.</br> The outer tiers can only dependent of inner tiers. Therefore, the inner tiers know nothing about the outer tiers.</br> The more further you go through the concentric circles, the higher level the software becomes. Which means that the level of abstraction increases.

Entities

An entity is a set of data structures. These entities are the business objects of the application and encapsulate the most general and high-level rules, such as Event or Rating.

Use Cases

They are the operations of the application and may contain specific business rules.</br> This layer is isolated from database, UI, or any of the common frameworks.</br> All use case classes extends UseCase abstract class that sets up the schedulers of Reactive Extensions.</br>

Adapters

It is a set of adapters that convert data from the format most convenient for the use cases and entities, to the format most convenient for some external agency such as the UI or Database.</br> It is this layer that will wholly contain the ViewModels of MVVM architectural pattern.</br> The models are likely just data structures that are passed from the view to the use cases, and vice versa.</br> Similarly, data is converted, in this layer, from the form most convenient for entities and use cases, into the form most convenient for whatever persistence framework is being used.

Frameworks

The outermost layer is composed of frameworks and tools such as the Database and the Android Framework.</br> The Repository pattern is used to encapsulate the details about caching mechanism.

The Dependency Inversion

In order to not violate the Dependency Rule, the Dependency Inversion principle must be used whenever complex data needs to be passed across a boundary to an inward layer. Instead of expecting and directly referencing a low-level component (e.g. as a function parameter), the high-level layer provides and references an interface that must be implemented and inherited from by the caller. This way, the conventional dependency relationship is inverted and the high-level layer is decoupled from the low-level component.

<p align="center"> <img alt='Inversion of Control' src="https://raw.githubusercontent.com/andremion/Theatre/master/art/inversion_of_control.png"></br> </p>

The Dependency Injection

To make the application more testable and avoid having to deal with object instantiations in many points, the Dependency Injection technique is used.

Dependency injection is one form of the broader technique of inversion of control. As with other forms of inversion of control, dependency injection supports the dependency inversion principle.

Dagger is the tool used for managing and injection of our dependencies.

Modules: WIP

<p align="center"> <img alt='Modules' src="https://raw.githubusercontent.com/andremion/Theatre/master/art/modules.png"></br> </p>

Data

The LondonTheatreDirect API groups the data into:

Since the data is basically static, a Repository with database caching is used by Gateway.

Due the data volatility, it is used a Repository that caches in memory.

<p align="center"> <img alt='Data' src="https://raw.githubusercontent.com/andremion/Theatre/master/art/data.png"></br> </p>

Presentation: WIP

<p align="center"> <img alt='Presentation' src="https://raw.githubusercontent.com/andremion/Theatre/master/art/presentation.png"></br> </p>

Credentials

Register your account here to get your developer key and put it into gradle.properties file

References

Libraries and tools used in the project

Android

Architecture and Design

Reactive

View and Image

Data Request

Persistence

Debugging and tests

TODO

Contributing

Contributions are always welcome!

Issues: Fell free to open a new issue. Follow the ISSUE_TEMPLATE.MD

Follow the "fork-and-pull" Git workflow.

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Merge with current development branch
  5. Push your work back up to your fork
  6. Submit a Pull request your changes can be reviewed (please refere the issue if reported)

Prevent code-style related changes. Format the code before commiting.

License

Copyright 2018 André Mion

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.