Android Weekly Issue #290
December 31st, 2017html
Android Weekly Issue #290
本期内容包括介绍Kotlin逆变协变的一篇(虽然没说清楚,但我补充了),IoT相关制做MIDI Controler的Part two,以及比较炫酷的Shared Element Reveal动画,以及LiveData与DataBinding相关,Kotlin扩展Fragment/Activity方法作测试,Rx逐条打Log等等.java
<!--more-->android
ARTICLES & TUTORIALS
Lessons learned implementing Redux on Android
文章介绍了模仿Web的Redux,实现其kotlin版本,实现Reducer
,经过State
与Action
来驱动状态的转换.git
State -> UI -> Action -> Reducer -> Store.
In and out type variant of Kotlin
文章介绍了Kotlin中泛型添加in
与out
的意义.github
实际上in
做为参数表示的是consume方,能够将super type能够赋值给sub type.相似于Java里面的<? super X>
,其做为泛型的Collection只能add数据,没法get访问内部成员.数据库
而out
做为返回值表示producer,与in相反,它能够将sub type赋值给super type.相似于Java中的<? extends X>,其做为检讨的Collection<out T>只能get访问,不能add数据.redux
Building a distributed MIDI Controller with Android Things and Nearby API #2
IoT的MIDI播放器第二篇,感兴趣的能够仔细看.api
Meaningful Motion: Circular Reveal & Shared Elements
在Shared Element Transaction Animation的基础上加上了ViewAnimationUtils#createCircularReveal
实现Reveal效果. 即Activity/Fragment跳转过程当中Shared Element先移动再充满Container.app
RxAndroid: Handle Interrupt With “switchMap”
经过switchMap将Happy与Unhappy的pass都加进来(Observer.merge)进行处理,switchMap与flatMap的区别是它内部只有一个active的observer,简单的来讲,它不会对转换后的Observable进行merge,而是在新的来到的时候cancel以前的.less
The curious case of haunting fragments
做者研究Fragment addToBackStack以及pop之间的事情,可是做者貌似没用对...
因此以后他竟然推荐用Activity了,说Fragment太难用...
Unit testing protected lifecycle methods with Kotlin
做者写了个工具库,给Activity的生命周期方法都写了扩展,这样就能够直接经过对象调用了...能够用来写Activity的单元测试.
Kotlin Coding Conventions
Kotlin最新的code style,基本跟Java相似,但这里比较详细,包括何时换行,何时single line等等.
Lessons from my first multi-platform Kotlin project
做者对Kotlin Multiple Platform进行总结,首先platform层应该根据js/jvm/native进行划分,而不是操做系统,操做系统的划分应该属于之下的regular层,而最上层为common层.
MVP的应用很是重要,其次是下层能够访问上层的一切,上层须要访问下层应该经过expected与actual来实现.
Android Architecture Components LiveData with Data Binding
Google最新的Databinding已经支持LiveData了,经过与LiveData进行绑定,能够保证UI在后台的时候不会由于数据变化而刷新,避免了没有必要的操做.
Briefly about RxJava Logging
做者介绍了经过doOnEach
(Flowable)以及doOnEvent
(others)来了解Observable的状态,帮助你添加新的feature中debug遇到的问题,不至于整个Rx Chains出现问题而不知道问题处在哪里.
LIBRARIES & CODE
TableView
很项强大TableView,基于RecyclerView,用来显示复杂数据.有点相似数据库表格.
retrofit2-kotlin-coroutines-adapter
Jake Warthon写的支持Kotlin Coroutine的Retrofit2, 返回Deferred
类型.
RxTest
像这个来测Rx的Observable,是否是很牛.
Observable.just("Hello RxTest!") .test { it shouldEmit "Hello RxTest!" it should complete() it shouldHave noErrors() }
MockK
支持Koltin DSL的mock库, 叫mockk....
KotlinAndroidViewBindings
其实感受跟ViewBinding没多大关系, 主要是实现了Delegate,能够取代findViewById
,Butterknife
以及Kotlin Android Extension
.
直接经过by bindWithXX()
来找到View.
litho-kotlin
Facebook litho的kotlin dsl support.
kotlin-math
支持不少vector计算的lib,帮助简化graphic math.