• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

bachhoan88/CleanArchitecture: Android Kotlin Clean Architecture

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

bachhoan88/CleanArchitecture

开源软件地址(OpenSource Url):

https://github.com/bachhoan88/CleanArchitecture

开源编程语言(OpenSource Language):

Kotlin 97.8%

开源软件介绍(OpenSource Introduction):

Android Kotlin Clean Architecture & Components Example

CircleCI codecov.io

This is a sample app & basic code that uses Clean Architecture & Components, that is part of a blog post I have written about how to architect android application using the Uncle Bob's clean architecture approach.

NOTE It is a relatively more complex and complete example so if you are not familiar with [Architecture Components][arch], you are highly recommended to check other examples in this repository first.

Introduction

Data-Flow

Structure

Work-Flow

Structure

Handler-Error-Flow

Structure

Domain Layer

  • Contains business model
  • Contains business RULEs
  • Repository interface adapt

Data Layer

  • Implementation Repository
  • Executor API data
  • Storage data to local: Share preferences, database, external storage
  • Mapper data model to domain model
  • Contains data service, third party data service

Presentation Layer

  • View (Activity/Fragment/Layout) Adapt data to view
  • Validate/Submit data input from view via UseCase

Base Code

Base code designed one Activity and multiple Fragment, using Navigation Component to UI navigate Use Dagger2 (version 2.23.2) for Dependencies Injection, You can easily switch to using Koin (I suggestion Dagger for big, super projects) Base code

  • Has created a flow that handles all of the corner cases, you can easily customize them via CleanException, it extends Throwable
  • Added Authorization, Interceptor easily handler and implementations for your project if needed
  • Use ktlint, kotlin-offical for check code conventions, you can run ./gradlew ktlint
  • Use jacoco for full Unit and Instrument test
  • Added basically circle-ci, gitlab-ci with some work-flows
  • Report bugs into Crashlytics via Timber.e

Building

Work from Android Studio 3.2 and above

Unit Test

You can easily write Unit Test up to 70% code coverage lines of code (LOC), if you write focus on

  • Data: API service, Local (database, share preferences), RepositoryImpl, Model Mapper
  • Domain: UseCases, Repository, Exception handlers
  • Presentation: ViewModel, Model Mapper

Libraries used


  • 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 - Access your app's 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.
  • UI - Details on why and how to use UI Components in your apps - together or separate
  • Third party
    • Glide for image loading
    • Kotlin Coroutines for managing background threads with simplified code and reducing needs for callbacks
    • ReactiveX library for composing asynchronous and event-based programs by using observable sequences.
    • Dagger2 for dependencies injection
    • Retrofit Type-safe HTTP client for Android
    • EasyPermission is a wrapper library to simplify basic system permissions logic when targeting Android M or higher.

Upcoming features

  • Build layer for library aar

  • Make design support for all application: styles, fonts, theme

  • Interested in seeing a particular feature of the Architecture or Base Code implemented in this app? Please open a new issue.

License

Copyright 2017 The Android Open Source Project, Inc.

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.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap