Skip to content

Eli-Fox/LEGO-Catalog

Repository files navigation

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.

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.

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 LegoSetsFragment Grid LegoSetFragment

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

  • Foundation - Components for core system capabilities, Kotlin extensions and support for multidex and automated testing.
    • AppCompat - Degrade gracefully on older versions of Android.
    • Android KTX - Write more concise, idiomatic Kotlin code.
    • Test - An Android testing framework for unit and runtime UI tests.
  • Architecture - 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 - Declaratively bind observable data to UI elements.
    • Lifecycles - Create a UI that automatically responds to lifecycle events.
    • LiveData - Build data objects that notify views when the underlying database changes.
    • Navigation - Handle everything needed for in-app navigation.
    • Room - SQLite database with in-app objects and compile-time checks.
    • ViewModel - Store UI-related data that isn't destroyed on app rotations. Easily schedule asynchronous tasks for optimal execution.
    • WorkManager - Manage your Android background jobs.
    • Paging - Load and display small chunks of data at a time.
  • UI - Details on why and how to use UI Components in your apps - together or separate.
  • Third party
    • Kotlin Coroutines for managing background threads with simplified code and reducing needs for callbacks.
    • Dagger 2 A fast dependency injector.
    • Retrofit 2 A configurable REST client.
    • OkHttp 3 A type-safe HTTP client.
    • GSON A Json - Object converter using reflection.
    • Glide Image loading.
    • Timber A logger.
    • Stetho Sophisticated debug bridge.

Android Studio IDE setup

For development, the latest version of Android Studio is required. The latest version can be downloaded from here.

App uses ktlint to enforce Kotlin coding styles. Here's how to configure it for use with Android Studio (instructions adapted from the ktlint README):

  • Close Android Studio if it's open

  • Download ktlint using these installation instructions

  • 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.

Releases

No releases published

Packages

No packages published

Languages