Android Weekly Issue #242
January 29th, 2017
Android Weekly Issue #242
本期內(nèi)容包括: Android中常用的設計模式; 基于NoSQL的移動對象數(shù)據(jù)庫--ObjectBox; MVC, MVP和MVVM模式的討論; 一個Google Actions的Java SDK; 一個帶黏性動畫的FAB的實現(xiàn); Kotlin 1.1的新功能; Firebase的實時數(shù)據(jù)庫討論; Model-View-Intent模式應用的實現(xiàn); 關于實現(xiàn)gradient時透明顏色的使用.
ARTICLES & TUTORIALS
Common Design Patterns for Android
Creational Patterns
- Builder
- 依賴注入: 舉例: Dagger
- Singleton
Structural Patterns
- Adapter
- Facade: 舉例: Retrofit
Behavioral Patterns
- Command: 舉例: EventBus
- Observer: 舉例: RxAndroid
- Model View Controller
- Model View ViewModel
ObjectBox - The new Mobile Database
ObjectBox是greenrobot發(fā)布的一個新的mobile對象數(shù)據(jù)庫, 主要關注于性能, 據(jù)說superfast.
在ObjectBox中, 主要是把NoSQL技術遷移到mobile端使用. 之前他們創(chuàng)建的greenDAO, 據(jù)說是最快的Object/Relational Mapper (ORM) for Android and SQLite.
ObjectBox的5大特性:
- Superfast.
- Object API.
- Instant unit testing.
- Simple threading.
- No manual schema migrations.
MVC vs. MVP vs. MVVM on Android
MVC, MVP, MVVM模式的介紹.
Building Google Actions with Java
非官方的Google Actions Java SDK, 本文為開發(fā)者介紹其如何使用.
Android Gooey FAB is EASY
實現(xiàn)一個膠黏的FAB.
首先作者展示了效果, 點擊FAB, 從中逐漸分離中一個新的小按鈕. 作者討論了這種效果可能的實現(xiàn)方法:
- 用bitmap的mesh transformation, 這是能高度自定義的.
- 創(chuàng)建自定義View, 自己繪制Path.
- 最簡單的辦法: 用Animated Vector Drawable, 即本文所介紹的方法.
源碼在這里: Android-Animations
What Comes in Kotlin 1.1 for Android Developers?
Kotlin 1.1的新features.
- Coroutines. 改善Kotlin中的異步編程.
- Type Aliases. 可以為類型起別名.
- Inlining Property Accessors.
- Less Restrictive Inheritance. sealed類的子類不用再放在同一個類中; 非final的類現(xiàn)在也可以繼承data類了.
- Destructuring and Underscores.
- Methods Count. 作者對比了一個sample程序, 用kotlin的不同版本, 發(fā)現(xiàn)用最新版kotlin確實會增加一些方法數(shù), 但它仍然算是一個很輕量的庫.
Understanding the Power of Firebase Security Rules
作者要寫關于Firebase的一系列文章: 第一和第二篇主要介紹實時數(shù)據(jù)庫的規(guī)則, 第三篇介紹Storage的規(guī)則.
關于實時數(shù)據(jù)庫規(guī)則的主要內(nèi)容包括:
- 識別你的用戶.
- 控制數(shù)據(jù)訪問權(quán)限.
- 驗證創(chuàng)建, 更新和刪除操作.
Reactive apps with Model-View-Intent - Part 3
上一篇中介紹了用Model-View-Intent模式來構(gòu)建一個單相數(shù)據(jù)流的簡單屏. 這篇文章接著講如何用MVI和state reducer來構(gòu)建一個復雜屏.
(感覺太復雜了我沒仔細看).
Android Dev Tip #3: A gotcha with color/transparent
如果你要在xml中用gradient寫一個漸變色, 對于透明色@android:color/transparent.的使用一定要注意.
透明色@android:color/transparent.的色值是#00000000, 所以它實際上代表的是一個透明的黑色.
在gradient進行插值的時候, 會對ARGB每一個通道的色值都分別進行插值然后疊加.
所以如果你想要保持顏色不變, 只改變透明度, 也即Alpha通道的值, 你就應該把透明色中RGB顏色設置為和原來的顏色一樣.
LIBRARIES & CODE
PreviewSeekBar
一個帶Preview的SeekBar.
AndroidTestingBox
一個Android項目, 用于實驗各種測試工具.
FunctionalRx2
a collection of constructs to simplify a functional programming approach to Java and Android.
gradle-completion
gradle的tab補全, for bash and zsh.
ObjectBox
超快的移動平臺對象數(shù)據(jù)庫.
superlightstack
一個輕量級的庫, 用于創(chuàng)建View的stack, 并處理轉(zhuǎn)換和狀態(tài)維持.
PicassoFaceDetectionTransformation
一個配合picasso使用的圖像轉(zhuǎn)換庫, 可以根據(jù)人臉檢測自動確定范圍而切圖.
(Readme中附有配合Glide和Fresco使用的版本.)
cwac-netsecurity
This library contains a backport of the Android 7.0 network security configuration subsystem.