Android Weekly Notes #404

作者: 圣骑士wind | 来源:发表于2020-03-09 15:25 被阅读0次

Android Weekly Issue #404

//TODO Live Templates

// TODO-Zarah (06 Mar 2020): Some comments go here

留下名字和日期.

但是每次要输入有点麻烦, 利用: parameterised live templates快捷输入.

Android Studio里:
Preferences > Editor > Live Templates.

Coroutine Cancellation 101

  • coroutine builders: 开启协程: launch.
  • 返回值Job, 可以cancel.
  • 如果是blocking的code呢? -> 无法cancel.

如果有一个操作要同时写到服务器和磁盘:

  • 方法1: withContext.
  • 方法2: yield().

Declarative lists on Android With RecyclerView + ViewBinding

如何抽象简化RecyclerView的代码:

Sealed with a class

像枚举一样限制类型, 像抽象类一样提供自由表达的形式. -> sealed class.

使用when的时候, IDE会检查是否所有的分支都被覆盖了.

编译代码中: 基类的构造是私有的.

Lessons Learnt with Kotlin: Using inline classes

使用inline类.

举例: 两个类都有uuid参数, 如何避免错传?

解决办法: 把ID做成incline类, 包裹UUID. 编译期检查.

  • 好处: inline不会带来性能问题. 利用编译期检查.
  • 注意: still experimental.

Design

Conversation Design Library

让机器像人一样交流.

LIBRARIES & CODE

AnimatedBottomBar

带动画的底部导航.

deep-clean

脚本工具, 清除Gradle/Android项目的缓存.

flow-preferences

Kotlin Flow版本的shared preferences.

RIBs

Uber的跨平台移动框架.

AndroidColorX

颜色工具.

相关文章

网友评论

    本文标题:Android Weekly Notes #404

    本文链接:https://www.haomeiwen.com/subject/tlepdhtx.html