当前位置: 首页 > 软件库 > 手机/移动开发 > >

Clean-MVVM-ArchComponents

授权协议 Apache-2.0 License
开发语言 Kotlin
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 闻人飞白
操作系统 Android
开源组织
适用人群 未知
 软件概览

   

The-Force

An Android app consuming a Star Wars API to display Movie Charactersit has been built with clean architecture principles, Repository Pattern and MVVMpattern as well as Architecture Components.

Min Api Level : 21 Supports Over 87% Devices

Build System : Gradle

Table of Contents

Prerequisite

To run the release build successfully in travis you will need to replace the default values inkeystore.properties.samplefile with your own in a keystore.properties file.

Next archive your keystore file and the properties file with the following command

tar cvf secrets.tar keystore.properties theforce.jks

Next encrypt the archive and add config to travis with the following command

travis encrypt-file --pro secrets.tar --add

Verify that in your travis.yml in the before_install it looks something like

before_install:
  - openssl aes-256-cbc -K $encrypted_5880cf525281_key -iv $encrypted_5880cf525281_iv -in secrets.tar.enc -out secrets.tar -d
  - tar xvf secrets.tar

Make sure to add only the *.enc file to git,leave out the keystore.properties and *.jks file.Add the following to the root .gitignore just to be sure

*.jks
*.tar
keystore.properties

If you encounter any error check this site out.

To setup the Travis CLI tools see this

Architecture

NB: Work in Progress - Feature Modularisation ��

The Application is split into a three layer architecture:

  • Presentation
  • Domain
  • Data

This provides better abstractions between framework implementationsand the underlying business logic.It requires a number of classes to getthings running but the pros outweigh the cons in terms of building an appthat should scale.

The 3 layered architectural approach is majorly guided by clean architecture which providesa clear separation of concerns with its Abstraction Principle.

Presentation

app contains the UI files and handles binding of DI components from other modules.Binding of data is facilitated by jetpacks data binding by serving data from the viewmodelto the UI.The data being received is part of a viewstate class that has properties contained in therelevant state.

Domain

The domain module contains domain model classes which represent thedata we will be handling across presentation and data layer.

Use cases are also provided in the domain layer and orchestrate the flowof data from the data layer onto the presentation layer and a split intomodular pieces serving one particular purpose.

The UseCases use a BaseUseCase interface that defines the parameters its taking in andoutput this helps in creating fakes using in testing.

Data

  • data-remote

Handles data interacting with the network and is later serverd up to the presentation layer throughdomain object

  • data-local

Handles persistence of object with Room ORM from.This module is responsible for handling all local relatedlogic and serves up data to and from the presentation layer through domain objects.

With this separation we can easily swap in new or replace the database being used without causeingmajor ripples across the codebase.

Testing

Each module has its own tests except for the domain module which is catered for since itspart of the behavior under test.

All server responses in the tests are served by mock web server by appending relative urls tothe localhost and the connected port as the base url.

In the data-remote module the responses are mocked using the mockwebserver and verified that theyare what we expect.

In the data-local module an in memory database is being used to run the tests,this makes it alittle faster compared to an actual db.

In the app module there are unit tests for the viewmodels and util classesand connected tests for the UI Screens.

The test instrumentation app uses modules that have been swaped with fakes forthe network module so as to run requests on localhost with mockwebserver,this removes flakinesscompared to relying on actual data from the real server aspects such as internet connection ornetwork service might bring up issues and an in memory database for local data that also allowsmain thread queries since tests should also be fast and we are just asserting stuff works.

View models testing on live data were guided by this article

Libraries

Libraries used in the whole application are:

  • Jetpack ��
    • Viewmodel - Manage UI related data in a lifecycle conscious wayand act as a channel between use cases and ui
    • Data Binding - support library that allows binding of UI components in layouts to data sources,binds character details and search results to UI
    • Room - Provides abstraction layer over SQLite
  • Retrofit - type safe http clientand supports coroutines out of the box.
  • Moshi - JSON Parser,used to parserequests on the data layer for Entities and understands Kotlin non-nullableand default parameters
  • okhttp-logging-interceptor - logs HTTP request and response data.
  • kotlinx.coroutines - Library Support for coroutines,provides runBlocking coroutine builder used in tests
  • Truth - Assertions Library,provides readability as far as assertions are concerned
  • MockWebServer - web server for testing HTTP clients ,verify requests and responses on the star wars api with the retrofit client.
  • Leak Canary - Leak Detection Library
  • Material Design - build awesome beautiful UIs. �� ��
  • Firebase - Backend As A Service for faster mobile development.
    • Crashylitics - Provide Realtime crash reports from users end.
  • Koin - A pragmatic lightweight dependency injection framework for Kotlin
  • Robolectric - Unit test on android framework.
  • Espresso - Test framework to write UI Tests
  • recyclerview-animators - Recycler View Animations
  • AboutLibraries -provide info on used open source libraries.
  • Stetho - debug bridge
  • Kiel - Kiel RecyclerView Adapter Builders

Contributors

  • Thanks to Zafer Celaloglu for the Dagger to Koin Refactor and additional test cases.

Feel free to contribute in any way to the project from typos in docs to code review are all welcome.

Demo

The codebase in most cases will be ahead of whats on the store.

Get it on Google Play

Google Play and the Google Play logo are trademarks of Google LLC.

Copyright Notice

Star Wars and all associated names are copyright Lucasfilm ltd.

Related Posts

Handling Dynamic Urls

License

  Copyright 2019 David Odari
  
  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.
  • 之前写代码的过程中曾经遇到过问题,用mvn install后,新改的内容不生效,一定要后来使用mvn clean install 才生效,由于之前没有做记录,以及记不清是什么情况下才会出现的问题,于是想看看clean和不clean的区别。 就如大家知道的,maven在执行一个生命周期的命令的是时候将会执行之前的所有生命周期操作,比如执行mvn install,会执行前面一系列的动作包括 compi

  • mvn clean package依次执行了clean、resources、compile、testResources、testCompile、test、jar(打包)等7个阶段。 mvn clean install依次执行了clean、resources、compile、testResources、testCompile、test、jar(打包)、install等8个阶段。 mvn clean

  • Posted on September 25, 2013 by 一品 原文点击这里 之前写代码的过程中曾经遇到过问题,用mvn install后,新改的内容不生效,一定要后来使用mvn clean install 才生效,由于之前没有做记录,以及记不清是什么情况下才会出现的问题,于是想看看clean和不clean的区别。 就如大家知道的,maven在执行一个生命周期的命令的是时候将会执行之前的所有

  • sh 'mvn clean package -Dfile.encoding=UTF-8 -DskipTests=true' Java构建过程中,用到mvn clean package,那么这个命令是什么?执行之后又会发生什么? 其实可以理解它为一组命令的集合,执行哪些命令?顺序如何? 执行顺序: 1、使用清理插件:maven-clean-plugin:2.5执行清理删除已有target目录(版本2

  • 1.前言 想必大家早用惯了SQLife这个嵌入性数据库,或是利用LitePal操作数据库。不过在我们学习MVVM时,一个更加新颖和便捷的组件进入了我们的视线——room,什么是room呢? room定义:流畅地访问 SQLite 数据库。在SQLite上提供了一个抽象层,以在利用SQLite的全部功能的同时允许更健壮的数据库访问。 简言之就是能自动生成CUDR操作,没错,你没听错,就是自动生成,节

  • mvn clean package  -U -pl xxx -P xxx -Dmaven.test.skip=true -e clean 运行mvn命令时常用的参数有,-B -e -U -pl -D -P,这些参数是Maven自身的,在命令行、持续集成环境都适用。 -B 使Maven在批处理模式下运行,避免需要人工参与交互而造成挂起,在持续集成等不希望人工参与的环境很有用。 -e 在运行maven

  • 之前写代码的过程中曾经遇到过问题,用mvn install后,新改的内容不生效,一定要后来使用mvn clean install 才生效,由于之前没有做记录,以及记不清是什么情况下才会出现的问题,于是想看看clean和不clean的区别。 就如大家知道的,maven在执行一个生命周期的命令的是时候将会执行之前的所有生命周期操作,比如执行mvn install,会执行前面一系列的动作包括 compi

  • 以下为一位代码同学的经验总结(原文链接未知) 之前写代码的过程中曾经遇到过问题,用mvn install后,新改的内容不生效,一定要后来使用mvn clean install 才生效,于是想看看clean和不clean的区别。 就如大家知道的,maven在执行一个生命周期的命令的是时候将会执行之前的所有生命周期操作,比如执行mvn install,会执行前面一系列的动作包括 compile , p

  • 在学习springcloud的时候打包模块为jar时遇到该命令,不太清楚之间的区别,在此记录。谢谢 两个都将清除。这意味着他们将删除目标文件夹。真正的问题是软件包和安装有什么区别? package将编译代码,并将其打包。例如,如果项目是一个jar文件,那么当打包并将其放置在目标目录的某个位置(默认情况下)时,它将创建一个jar文件。 install会编译和打包,但是也会把这个包放到你的本地仓库中。

  • clean: 执行该命令会删除项目路径下的target文件,但是不会删除本地的maven仓库已经生成的jar文件 compile: 编译命令,只编译选定的目标,不管之前是否已经编译过,会在你的项目路径下生成一个target目录,在该目录中包含一个classes文件夹,里面全是生成的class文件及字节码文件。 package: 这个命令会在你的项目路径下一个target目录,并且拥有compile

  • Maven 相关:mvn clean package 与 mvn clean install 的区别 mvn clean package mvn clean install 以上两条命令,表面上看做了相同的工作,实际上却略有区别。 mvn clean package:删除目标文件夹、编译代码并打包 mvn clean install:删除目标文件夹、编译代码并打包、将打好的包放置到本地仓库中 参

  • 当maven程序在执行时 mvn clean package mvn package -Dmaven.test.skip=true -Ptest 终端还是打印出单元测试在执行,并且查看target目录,下面依然有test-classes目录,解决的过程中了解到-DskipTests和-Dmaven.test.skip=true的区别是 -DskipTests,不执行测试用例,但编译测试用例类生成

  • mvn clean package依次执行了clean、resources、compile、testResources、testCompile、test、jar(打包)等7个阶段。 mvn clean install依次执行了clean、resources、compile、testResources、testCompile、test、jar(打包)、install等8个阶段。 mvn clean

  • 完整报错内容如下: D:\workspace\JavaWorkspace\hello_world>mvn clean [WARNING] [WARNING] Some problems were encountered while building the effective settings [WARNING] Unrecognised tag: 'id' (position: START_TA

  • 命令mvn clean 和项目lifecycle中的区别 mvn clean命令找的是setting.xml,因为在平时项目中我们会根据不同项目区分setting文件,即使我们配置setting和仓库,也会再执行命令时依赖报错; lifecycle:会找我们配置的setting和仓库,不回去找默认的setting.xml 解决办法:把其他不用的setting文件修改为其他名字,只留一个要使用的文件

  • 在此之前,生产环境一直都是mvn install来打包的。昨天出现1个问题,xxxMapper.xml引用的类都找不到了,其实这个mapper.xml和引用的类都已经删掉了。本地环境和测试环境也都是正常的。百思不得其解。最终打开生产环境打的包,原来之前的mapper.xml文件仍然孩在。原因是没有clean

 相关资料
  • Model-View-ViewModel (MVVM)是用于开发软件应用程序的架构设计模式。 MVVM由Microsoft Architect John Gossman于2005年开发。该模式源自模型 - 视图 - 控制器(MVC)模式。 MVVM的优势在于它将应用程序层的图形用户界面与业务逻辑分开。 MVVM负责处理来自底层模型的数据,以便非常容易地表示和管理它。 MVVM中的ViewModel

  • 我有一些第三方jar依赖。因此,我使用maven-install-plugin将这些第三方jar安装到我的本地存储库(.m2/repository)中。这个插件一定要清理阶段。当我执行“MVN clean Install”时,在运行clean之前,它开始搜索依赖项,最终构建失败,因为它无法找到第三方JAR。但是当我单独运行mvn clean时,它会将文件安装在本地存储库中。随后当我运行mvn cl

  • MVVM(Model View ViewModel)是一种基于MVC和MVP的架构模式,它试图将用户界面(UI)从业务逻辑和行为中更加清晰地分离出来。为了这个目的,很多例子使用声明变量绑定来把View层的工作从其他层分离出来。 这促进了UI和开发工作在同一代码库中的同步进行。UI开发者用他们的文档标记(HTML)绑定到ViewModel,在这个地方Model和ViewModel由负责逻辑的开发人员

  • 什么是MVVM?MVVM是Model-View-ViewModel的缩写。 要编写可维护的前端代码绝非易事。我们已经用MVC模式通过koa实现了后端数据、模板页面和控制器的分离,但是,对于前端来说,还不够。 这里有童鞋会问,不是讲Node后端开发吗?怎么又回到前端开发了? 对于一个全栈开发工程师来说,懂前端才会开发出更好的后端程序(不懂前端的后端工程师会设计出非常难用的API),懂后端才会开发出更

  • MVVM 是一个 Android MVVM 框架,基于谷歌dataBinding技术实现。dataBinding 实现的 V 和 VM的关联;使用IOC架构实现了 M 和 V的关联。 框架具有以下功能: 业务逻辑层的分离 封装了android 6.0权限申请,在申请权限时,能像View一样设置事件监听 创建Fragment、Dialog、popupwindow都将变得极其简单 占位布局实现将变得极

  • clean 命令用于删除生成的书籍,和任何其他构建工件. mdbook clean clean命令可以将目录作为参数,用作本书的根目录,而不是当前工作目录. mdbook clean path/to/book --dest-dir(-d)选项允许您覆盖书籍的输出目录,该目录会删除。 为相对路径,(相对于书籍的根目录)。如果未指定,则默认为book.toml配置的build.build-dir字