You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
val pad = dp(16)
if (ScreenMetrics.isDarkMode(this)) { /* ... */ }
if (ProcessInfo.isMainProcess(this)) CrashHandler.install(this)
val space =StorageSpace.internal(this)
Toasts.short(this, ByteSize.format(space.freeBytes) +" 可用")
6. 存储与配置
类
一句话
亮点
Preferences
SharedPreferences 薄封装
一律 apply();可 wrap
ResourceReader
assets / raw
自动关流;Properties 便捷读取
UriFiles
content Uri
显示名/大小/MIME;拷贝到 cache
7. 文本 / 校验 / 摘要 / 编解码 / 时间
类
一句话
亮点
RegexUtils / RegexConstants
手机号·邮箱·身份证…
匹配 / 提取 / 替换
DigestUtils
SHA-256 / MD5
MD5 仅非安全场景
EncodingUtils
Base64 / Hex
URL_SAFE 可选
ByteSize
1.5 MB
人类可读
TimeFormats
相对时间 · 时长
「3分钟前」/ mm:ss
VersionUtils
版本比较
isAtLeast("2.1.0", "2.0.0")
LunarDate
公历→农历
生肖 / 干支 / 闰月
8. 并发与交互节奏
类
一句话
亮点
MainThread
主线程投递
run / post / postDelayed / Executor
Debouncer
防抖
按钮连点杀手
Throttler
节流
滑动/传感器场景
val debounce =Debouncer(600)
button.setOnClickListener {
if (debounce.tryAcquire()) submit()
}
MainThread.postDelayed(300) { refresh() }