0. 前言
本文是深入理解「Android Architecture Components」系列文章第四篇
源码基于 AAC 1.1.1 版本
在上一篇 LiveData
原理分析一文中,我们提到了 ViewModel
,它跟 LiveData 配合能够把价值发挥到最大。
这一篇,我们就来深入浅出一下 ViewModel ,来讲讲 ViewModel 的使用方式、生命周期、以及它的实现原理。
菩提本无树,程序亦非猿。
本文是深入理解「Android Architecture Components」系列文章第三篇
源码基于 android.arch.lifecycle:livedata-core:1.1.1
在之前我们深入研究了 Lifecycle 的实现原理,并在文末提到了LiveData 以及 ViewModel,这次我们来讲讲 LiveData。
LiveData 是 Android Architecture Components 中的一员,先看下官方是如何介绍的:
LiveData is an observable data holder class. Unlike a regular observable, LiveData is lifecycle-aware, meaning it respects the lifecycle of other app components, such as activities, fragments, or services. This awareness ensures LiveData only updates app component observers that are in an active lifecycle state. [见 9.1]
This class is designed to hold individual data fields of ViewModel, but can also be used for sharing data between different modules in your application in a decoupled fashion. [见 9.2]
本文是深入理解「Android Architecture Components」系列文章第二篇
源码基于 1.1.1 版本
在前文,我就提到 Android Architecture Components (后简称为 AAC),是一个帮助开发者设计 健壮
、 可测试
且 可维护
的一系列库的集合。
Lifecycle
就是 AAC 中的一员,它能够帮助我们方便的管理 Activity 以及 Fragment 的生命周期。
本文带大家深入了解 Lifecycle 。
注意:本文基于 Lifecycle 1.1.1 版本,Android API 26 ,依赖如下图。
并假设读者对 Lifecycle 有基本的了解,我绘制了一个基本的类图,如果对于下面类图所涉及到的类都还算了解则可以继续阅读下去,如果完全不知道,建议阅读一些教程先。
你好,我是程序亦非猿,一个正在努力成长的阿里资深无线开发工程师。
抽空看了下 I/O , 大概的记录了些东西。
整体上看,这一年,Android 只专注一件事,就是帮助开发者提高生产效率。(developer productivity)
Android development will become increasingly Kotlin-first.
“Many new Jetpack APIs and features will be offered first in Kotlin. If you’re starting a new project, you should write it in Kotlin; code written in Kotlin often mean much less code for you–less code to type, test, and maintain.”
“We understand that not everybody is on Kotlin right now, but we believe that you should get there,”
Google 走在推广 Kotlin 的路上坚定不移。
最近阿里财年结束,阿里员工们都知道了自己的绩效以及年终奖,预计会有一波人离职。
因为阿里绩效的 361
很残酷,拿了 1
的同学没有涨薪也没有年终奖,有大一部分都会选择离开。
再加上一些本来就等着拿了年终奖后就跳槽的同学,后续的1~2个月估计会有不少人离职。
所谓一个萝卜一个坑
,老萝卜不走新萝卜不进,只有老萝卜挪位子了,坑才会多出来。
所以,未来的1~2个月可能会是一年中进阿里最好的时机
。
那么,如果有同学想尝试一下,应该怎么做呢?
我给大家传授一些经验。
文章可能会过时,最新信息请查阅 Github
Github 地址 : https://github.com/AlanCheen/Pandora
在古希腊的神话中 Pandora 是世界上第一个女人,一个 all-gifted 的女人(具有一切天赋的女人),而潘多拉的魔盒里装着希望。
借着 all-gifted 的寓意,我创建了一个开源库 Pandora,一个非常常用的工具类的集合。
虽然算是 Utils 的集合,但是跟其他的库并不同,这里的类&方法的数量非常少,我只选了极少数我觉得真的非常有用且有大概率复用的类,在保证避免编写大量样板代码的基础之上,减少引入不必要类的可能,防止包体积增大。。
所以也可以算是一个『Utils 心选』。
那么就介绍一下 Pandora 的能力啦。