Android Weekly Issue #422
Tick Tock: Desugaring and Timezones
AGP/Android Studio 4.0 recently introduced library desugaring (code name "L8"), a tool that backports a number of Java 8+ APIs for use on older Android versions.
这个库: https://github.com/ZacSweers/ticktock
解决一个时区时间的问题.
WebP — a preferred image format for Android apps
WebP是一种图像格式, Google开发.
WebP is an image format that is developed by Google, focuses mainly on optimization and quality. One of the cool features of WebP is that it is lossless and lossy which means it supports both types of compression, unlike PNGs and JPGs. WebP is fully supported on web browsers such as Chrome, Firefox, and Opera (see the image below). On the Android side, WebP was added since API 14, so it is more than safe to use WebP on Android these days.
Apple上暂时不支持, 但是有一个库: https://github.com/SDWebImage/SDWebImageWebPCoder
WebP支持无损压缩和有损压缩.
Android Studio有工具可以把png和jpg转化成webp.
Singleton is More Than Just Design Pattern
- The Good Singleton: 全局变量
- The Bad Singleton: 单例设计模式.
缺点:- 很容易被滥用, 打破层级, 破坏架构.
- 静态方法, 无法看依赖.
- 循环依赖. In some sense, this kind of circular coupling aggregates the involved objects into a single “distributed God Object” (like a chain tying multiple objects together).
- The Ugly Singleton: 注解:
@Singleton
. 只是一个scope注解, 本身并不能保证单例. 不如使用@AppScope
这种名字的注解意义更明确.
Code
- 进程被杀死然后恢复的时候通知你: https://github.com/hannesstruss/unearthed
网友评论