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.