GithubHelp home page GithubHelp logo

raulh82vlc / transactions-viewer Goto Github PK

View Code? Open in Web Editor NEW
22.0 2.0 1.0 10.83 MB

Transactions Viewer

License: Apache License 2.0

Java 100.00%
android clean-architecture clean-code mvp mvp-android mvp-clean json-serialization transactions unit-testing mockito junit

transactions-viewer's Introduction

Transactions viewer

Build Status Hex.pm Platform codecov

Transactions viewer shows a list of products ordered alphabetically as well as its detail view whose transactions reflect their corresponding exchange rate to GBP.

This project uses Material design with Clean architecture by means of Model-View-Presenter (MVP) with Repository pattern as well as Dagger 2 for Dependency Injection, trying to respect SOLID principles as much as possible.

Screenshots

Screencast UX

Overview

At this open-source project, it is decoupled between android and domain modules or high level layers.

This means, android is strongly coupled with the Android framework and domain is decoupled from it, and can be re-used for other purposes when required as is purely Java based, but not framework coupled.

Inside the those modules, there are some good practices being employed, for instance:

  • There is an implementation of the repository pattern with a JSON datasource (it could be extended to have others if required such as InternetDataSource and so on).

Gson library is the responsible of parsing all JSON information to Domain models, for this purpose and properly handling the different requests on background threads with a pool of threads which passes their use cases result and avoids to lock the UI thread.

Architecture design overview

The exchange between the different layers is as follows:

  • Repository layer:
  • from the models coming from a concrete data source to the Repository (repository is the responsible of managing from 1 to n datasources) as well as processing information is there is some, since is Caching in RAM memory the information parsed from each DataSource coming from the rates1.json and transaction1.json.
  • from the Repository to their associated Interactor (or use case)
  • Interactor layer: from the Interactor, which is responsible of the business logic and communicating results to the Presenter
  • Presenter layer: from the Presenter, which provides the final formatted info to a passive View from a UI element (fragments / activities). Finally, this information would be passed through the UI thread.

Material design

  • This code test uses a wide range of Material design widgets from the Design support library such as:
  • AppBarLayout, CoordinatorLayout, Toolbar, RecyclerView as well as Material theme styles.

Features

  • For an easy UI test, on the first screen, a switcher has been hold at the toolbar, to switch between datasource1 (the biggest) and the minimal datasource2
  • At the main screen a summary of products sorted alphabetically is shown, as well as the number of transactions per product as subtitle.
  • Once clicked an item, the transactions detail view of an item is shown, which shows all transactions amounts with the initial currency as well as its corresponding amount on GBP. At this detail view, there is a total amount of all transactions being added.
  • Error handling integrated for JSON or IO issues or indicating no results.
  • To avoid memory problems between Intents (from main to detail activities) there is the minimal set of information, required to retrieve new info, such as the SKU identifier per product, the kind of dataset to look at, etc.
  • There is a small amount of Unit test cases for the most critical parts: mainly the Graph logic, then repository as well as view interaction.

SDK support

Support SDKs from 16 to 25

Disclosure - Libraries used

  • Dagger 2 for Dependency Injection
  • ButterKnife v6.1.0 for Views Injection
  • Gson v2.2.4 for Json parsing
  • Mockito for Mocking artifacts
  • JUnit for Unit testing Graph algorithm and its datastructure or rounding.

References (special thanks) - those are the same I indicated at my personal blog (Insights and projects):

Contributions

Please read first CONTRIBUTING

About the author

Raul Hernandez Lopez,

License

Copyright (C) 2017 Raul Hernandez Lopez

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.

transactions-viewer's People

Contributors

raulh82vlc avatar

Stargazers

 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

Forkers

cfirmo33

transactions-viewer's Issues

Callbacks must be reseted from each presenter

In order to avoid memory leaks as well as NullPointerException of the view
a better approach must be taken to handle with responses coming from the repository
when somethings is being loaded and there is a rotation or an activity / fragment being destroyed.

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.