Android Jetpack组件系列之Architecture Components

2 篇文章 0 订阅
1 篇文章 0 订阅

Android Jetpack组件系列之Architecture Components

Architecture Components是什么?

学习一个新技术的最好的方式就是从官方文档开始,Architecture Components在Google的官方文档中是这样介绍的:

Android architecture components are 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.

  • Learn the basics of putting together a robust app with the Guide to app architecture.

  • Manage your app’s lifecycle with ease. New lifecycle-aware components help you manage your activity and fragment lifecycles. Survive configuration changes, avoid memory leaks and easily load data into your UI.

  • Use LiveData to build data objects that notify views when the underlying database changes.

  • ViewModel stores UI-related data that isn’t destroyed on app rotations.

  • Room is a SQLite object mapping library. Use it to avoid boilerplate code and easily convert SQLite table data to Java objects. Room provides compile time checks of SQLite statements and can return RxJava, Flowable and LiveData observables.

翻译过来的简单意思就是:

Architecture Components是一组可帮助您设计健壮,可测试和可维护的应用程序。 从用于管理UI组件生命周期和处理数据持久性的库。

  • 通过应用程序架构指南了解将强大的应用程序组合在一起的基础知识。

  • 轻松管理应用程序的生命周期。 新的生命周期感知组件(Lifecycles)可帮助您管理活动和碎片生命周期。 生存配置更改,避免内存泄漏并轻松将数据加载到UI中。

  • 使用LiveData构建数据对象,以便在数据改变的时候更改时UI改变。

  • ViewModel存储在应用程序轮换时未销毁的UI相关数据。(ViewModel提供了一种创建和检测绑定到特定生命周期的对象的方法。 ViewModel通常存储视图数据的状态,并与其他组件通信,例如数据存储库或处理业务逻辑的域层)

  • Room是一个SQLite对象映射库。 使用它来避免样板代码并轻松地将SQLite表数据转换为Java对象。 Room提供SQLite语句的编译时检查,可以返回RxJava,Flowable和LiveData observable。

以上就是Google对Architecture Components的介绍(请自动忽略我的渣渣英语,大部分都是Google翻译的),个人感觉Google的这套Android组件是一个简易的MVVM实现模板,Architecture Components的介绍就这样吧,学习一个技术最首先的是先要学会它的使用方式,后面我会以学习的方式把这个组件的使用都写下来,以便自己加深记忆和大家一起学习.

Google官方Demo地址:Google官方Demo地址

添加依赖

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值