Giter VIP home page Giter VIP logo

books_jetpack's Introduction

Books Jetpack

This sample demonstrates how to use some of the Android Architecture Components available in Jetpack library.

In this sample I tried to follow the Clean Architecture principles and use some cool Android libraries.

The Application is divided in modules as displayed below:

  • UI - contains all UI related classes (Activities, Fragments, Adapters, etc.).
    The authentication process is also implemented here (I need to improve that) using Firebase Authentication.
    This layer is using Jetpack's Navigation API to implement the "single activity" approach for the navigation flow.
  • Presentation - once this project is folowing (or trying to) the MVVM pattern, this layer is using View Model library to keep data between config changes.
    To expose observable data from the View Models, this module is using LiveData.
    This layer is using Lifecycle library in order to tie the View Model with UI lifecycle (in some cases).
    Finally, this module is also using Data Binding to keep the data in sync during user input.
  • Domain - in this module are declared the application's use cases.
  • Data - declares the basic operations that must be provided by the application's repository and the basic data classes used as DTO.
  • Data Remote - contains a implementation of a remote data source using Firebase Cloud Firestore. The book's cover are stored in the Firebase Cloud Storage.
  • Data Local - contains a implementation of a local data source Room library. The book's cover are stored in the local file system.

The architecture flow is displayed below:


(Source: Lessons learnt using Coroutines Flow article by Manuel Vivo)

Screenshots

Books List

This screen displays all books saved on the repository (local or remote).

Book details

This screen display the details of a book selected in books list.

Book Form

In this screen, the user can add a new book or edit an existing one.

Login Screen

The user must perform the login with their Google account to access the application.

Libraries

This project is written in Kotlin and it's using the following libraries:

Get started

The project is compatible with Android Studio 3.5.2. To run this application, you must have to create a Firebase Project and enable Google Authentication. Afterwards, you must have to download the google_services.json file from the firebase console and add it app module root folder. If you want to save data on Firebase Cloud Firestore, enable this database for your project in Firebase Console. Also enable the Firebase Cloud Storage.

To choose the data source you will save application data, just make the following change in the BooksRepositoryImpl.kt file.

internal class BooksRepositoryImpl(
   // Change RoomLocalData to FBData interface
   private val localData: RoomLocalData,
   private val entityMapper: Mapper<BookData, Book>,
   private val dataMapper: Mapper<Book, BookData>
) : BooksRepository {

    ...
}

And that's it! You're good to go.

Contribute ;)

This project is just a demo, but any feedback and/or PR's are appreciated! :)

books_jetpack's People

Contributors

amadeu01 avatar dsdebastiani avatar gabrielbrasileiro avatar nglauber avatar wellingtoncabral avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

books_jetpack's Issues

What module should be responsible for persistence rules?

Glauber, first congratulations on your exceptional work!
I am using this project as a basis for the development of an App and I would like to take a conceptual question with you, if possible:

I structured the data layers: data_local (Room) and data_remote (Retrofit, consuming a REST API). However, I would like to know what layer would be responsible for any rules related to the source of data persistence (local and remote)?

In this sense, your project currently configures a single data source: local (Room) or remote (Firebase). Conceptually I imagine that the domain layer could be responsible for persistence rules using multiple repositories, but in some references (like this) I see that it is common to have a concrete implementation of the Repository pattern in the "data" layer.

Could you give your opinion, please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.