Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/Eli-Fox/LEGO-Catalog

A LEGO® Catalog app illustrating current Android Architecture state using Android development best practices.
https://github.com/Eli-Fox/LEGO-Catalog

Last synced: 13 days ago
JSON representation

A LEGO® Catalog app illustrating current Android Architecture state using Android development best practices.

Awesome Lists containing this project

README

        

LEGO® Catalog
=========================

A LEGO® Catalog app illustrating current Android Architecture state using Android development best
practices.

[To get started you can find project and Architecture overview in the Medium article](https://medium.com/@eli.fox/android-architecture-starring-kotlin-coroutines-jetpack-mvvm-room-paging-retrofit-and-dagger-7749b2bae5f7?sk=9c5a7af2fbf5d4a04e72322bfb245489).

NOTE: LEGO® and the LEGO® logo are trademarks of the LEGO® Group, which does not sponsor, authorize
or endorse this app.

Introduction
------------

The application uses Clean Architecture based on MVVM and Repository patterns. Implemented
Architecture principles follow Google recommended [Guide to app architecture](https://developer.android.com/jetpack/docs/guide).

![Guide to app architecture](screenshots/guide-to-app-architecture.png "Guide to app architecture")

The application is written entirely in Kotlin.

Android Jetpack is used as an Architecture glue including but not limited to ViewModel, LiveData,
Lifecycles, Navigation, Room and Data Binding. See a complete list in "Libraries used" section.

The application does network HTTP requests via Retrofit, OkHttp and GSON. Loaded data is saved to
SQL based database Room, which serves as single source of truth and support offline mode.
Paging library is used for data pagination online and offline.

Kotlin Coroutines manage background threads with simplified code and reducing needs for callbacks.
Combination of Coroutines and Kotlin build in functions (transformation, collections) are preferred
over RxJava 2.

Work manager does synchronisation job being compatible with Doze Mode and using battery efficiently.
Navigation component manages in-app navigation.

Dagger 2 is used for dependency injection.

Glide is used for image loading and Timber for logging.

Stetho is used to empower debugging skills (like Network calls log, Database content overview,
UI Hierarchy view, etc).

A sample app consist of 3 screens: List of LEGO® themes, list of sets and set details.

Getting Started
---------------
This project uses the Gradle build system. To build this project, use the
`gradlew build` command or use "Import Project" in Android Studio.

There are two Gradle tasks for testing the project:
* `connectedAndroidTest` - for running Espresso on a connected device
* `test` - for running unit tests

Screenshots
-----------

![LegoThemeFragment](screenshots/phone_legotheme.png "Browse Themes ")
![LegoSetsFragment Grid](screenshots/phone_legosets_grid.png "Browse sets in grid view")
![LegoSetFragment](screenshots/phone_legoset.png "Lego set")

Libraries Used
--------------

The application goal is to show case current Android Architecture state using out of box
Android tools made by Google (Android Jetpack) and 3rd party community driven libraries.

Android Jetpack is a set of components, tools and guidance to make great Android apps. They bring
together the existing Support Library and Architecture Components and arranges them into four
categories:

![Android Jetpack](screenshots/jetpack_donut.png "Android Jetpack Components")

* [Foundation][0] - Components for core system capabilities, Kotlin extensions and support for
multidex and automated testing.
* [AppCompat][1] - Degrade gracefully on older versions of Android.
* [Android KTX][2] - Write more concise, idiomatic Kotlin code.
* [Test][4] - An Android testing framework for unit and runtime UI tests.
* [Architecture][10] - A collection of libraries that help you design robust, testable, and
maintainable apps. Start with classes for managing your UI component lifecycle and handling data
persistence.
* [Data Binding][11] - Declaratively bind observable data to UI elements.
* [Lifecycles][12] - Create a UI that automatically responds to lifecycle events.
* [LiveData][13] - Build data objects that notify views when the underlying database changes.
* [Navigation][14] - Handle everything needed for in-app navigation.
* [Room][16] - SQLite database with in-app objects and compile-time checks.
* [ViewModel][17] - Store UI-related data that isn't destroyed on app rotations. Easily schedule
asynchronous tasks for optimal execution.
* [WorkManager][18] - Manage your Android background jobs.
* [Paging][19] - Load and display small chunks of data at a time.
* [UI][30] - Details on why and how to use UI Components in your apps - together or separate.
* [Animations & Transitions][31] - Move widgets and transition between screens.
* [Fragment][34] - A basic unit of composable UI.
* [Layout][35] - Lay out widgets using different algorithms.
* [Material][36] - Material Components.
* Third party
* [Kotlin Coroutines][91] for managing background threads with simplified code
and reducing needs for callbacks.
* [Dagger 2][92] A fast dependency injector.
* [Retrofit 2][93] A configurable REST client.
* [OkHttp 3][94] A type-safe HTTP client.
* [GSON][95] A Json - Object converter using reflection.
* [Glide][90] Image loading.
* [Timber][96] A logger.
* [Stetho][97] Sophisticated debug bridge.

[0]: https://developer.android.com/jetpack/components
[1]: https://developer.android.com/topic/libraries/support-library/packages#v7-appcompat
[2]: https://developer.android.com/kotlin/ktx
[4]: https://developer.android.com/training/testing/
[10]: https://developer.android.com/jetpack/arch/
[11]: https://developer.android.com/topic/libraries/data-binding/
[12]: https://developer.android.com/topic/libraries/architecture/lifecycle
[13]: https://developer.android.com/topic/libraries/architecture/livedata
[14]: https://developer.android.com/topic/libraries/architecture/navigation/
[16]: https://developer.android.com/topic/libraries/architecture/room
[17]: https://developer.android.com/topic/libraries/architecture/viewmodel
[18]: https://developer.android.com/topic/libraries/architecture/workmanager
[19]: https://developer.android.com/topic/libraries/architecture/paging
[30]: https://developer.android.com/guide/topics/ui
[31]: https://developer.android.com/training/animation/
[34]: https://developer.android.com/guide/components/fragments
[35]: https://developer.android.com/guide/topics/ui/declaring-layout
[36]: https://material.io/develop/android/docs/getting-started/
[90]: https://bumptech.github.io/glide/
[91]: https://kotlinlang.org/docs/reference/coroutines-overview.html
[92]: https://dagger.dev/users-guide
[93]: https://square.github.io/retrofit/
[94]: https://square.github.io/okhttp/
[95]: https://github.com/google/gson
[96]: https://github.com/JakeWharton/timber
[97]: http://facebook.github.io/stetho/

Android Studio IDE setup
------------------------
For development, the latest version of Android Studio is required. The latest version can be
downloaded from [here](https://developer.android.com/studio/).

App uses [ktlint](https://ktlint.github.io/) to enforce Kotlin coding styles.
Here's how to configure it for use with Android Studio (instructions adapted
from the ktlint [README](https://github.com/shyiko/ktlint/blob/master/README.md)):

- Close Android Studio if it's open

- Download ktlint using these [installation instructions](https://github.com/shyiko/ktlint/blob/master/README.md#installation)

- Inside the project root directory run:

`./ktlint --apply-to-idea-project --android`

- Start Android Studio

License
-------

Copyright 2019 Eli Fox.

Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for
additional information regarding copyright ownership. The ASF licenses this
file to you 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.