Coder Social home page Coder Social logo

jetpackmvvm's Introduction

2020年最新最实用的android-MVVM框架



java版mvp参见:https://github.com/VcStrong/RxRetrofitMVPDemo.git
kotlin版mvp参见:https://github.com/VcStrong/KotlinMVPDemo.git

1.mvvm-v1 2020.04.20

这是一个整合架构,所有功能开发都只能在一个module中

1.1 业务功能包含以下:

  • 登录注册(跳转主页后关闭,已登录用户可直接进入主页);
  • 仿微信朋友圈,Recyclerview嵌套RecyclerView实现多图布局列表切换(一张横向全屏,二张横向全屏,三张横向全屏,四张分两行且横向全屏);
  • 发表朋友圈回传值刷新(viewmodel中livedata妙用);
  • 多图带参数上传;
  • 首页和设置页分别退出登录(intent的flag使用);

1.2 本架构技术功能包含以下:

  • ViewModel在xml页面变量同一命名;
  • Adapter中item的xml如果经常复用但model数据不一致的情况,切勿盲目binding设置,切勿单向页面绑定,请在adapter中手动控件赋值,不要xml-binding;
  • Adapter中复杂控件处理需要大对象,建议灵活使用binding寄存,参见CircleAdapter类
  • ObjectBox快速实现对象存取
  • LiveData对网络请求数据灵活设置,view层基于观察者模式填充
  • viewbinding中onClick,onCheckedChanged等事件使用,其他事件根据Listenter实现方法的名字举一反三

1.3 框架包含以下

  • androidx:这个系列的jar包和appcompat.support对立的,参见谷歌官方文档
  • lifecycle-viewmodel+lifecycle-livedata:生命周期管理,完全解耦,方便系统内存管理释放,基于观察者模式实现数据更新等等
  • DataBinding
  • retrofit2+rxjava2
  • ObjectBox:android上运行速度最快的数据库,基于c/c++开发,native接口
  • MZBanner:banner如果不需要刻意去掉。
  • Fresco:图片加载
  • XRecyclerView
  • RxPmissions:权限申请比较好用
  • Arouter:页面路由

2.mvvm-v2 质量的提高来自不断地追求

v2版本计划在v1基础上进行组件化升级,由于对组件和模块的概念有了更深的了解,参考了网上的组件化教程,实践总结利弊之后,决定自己写一套优秀高效率的组件运行gradle:

  • 公司场景:多模块业务联调,统一运行;
  • 此demo种组件化打包好处:根据gradle配置动态改变模块的引入,分分钟能解决一个模块或者多个模块打包联调;
  • 具体方式如下:
    1. 项目根目录新建了config.gradle存放系统变量;
    2. 项目根目录新建了module.gradle存放业务module中build.gradle公用参数,common和app不建议引入(部分重要配置必须写在这两个module中);
    3. 项目根目录build.gradle使用groovy动态改变app(module)对模块的引入;
    4. 所有选中的模块可根据自己要求,决定是否需要改变AndroidManifest.xml的引入,仿照open_main模块中的sourceSets;

注:请认真查看config.gradle中的变量备注

jetpackmvvm's People

Contributors

vcstrong avatar

Watchers

James Cloos avatar

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.