随笔分类 - kotlin
1
摘要:Android官方推荐 无需向应用授予的照片选择器工具
阅读全文
摘要:chunked:将ByteArray分割为指定大小的子数组(List<ByteArray>) val list = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) val chunkedList = list.chunked(3) println(chunkedList)
阅读全文
摘要:只需要自定义控件监听 dispatchSetPressed 方法就可以轻松实现 比如: class ImageViewButton(context: Context, attrs: AttributeSet?, defStyleAttr: Int): androidx.appcompat.widge
阅读全文
摘要:
这是一个根据算法取色的自定义圆形取色盘,支持向外拖动,体验非常丝滑。
阅读全文

摘要:val decorView: View = window.decorView //侵入系统栏 WindowCompat.setDecorFitsSystemWindows(window,!hide) /**API 28 以上 状态栏位置上被黑条占领 问题解决 **/ if (Build.VERSIO
阅读全文
摘要:val bottom = remember { mutableStateOf(0f) } ViewCompat.setOnApplyWindowInsetsListener(LocalView.current){ _, insets -> bottom.value = insets?.getInse
阅读全文
摘要:* rememberCoroutineScope 具体使用请看将 Kotlin 协程与生命周期感知型组件一起使用 例 private val mainScope:CoroutineScope = MainScope() override fun onCreate(savedInstanceState
阅读全文
摘要:建造者模式理解 建造者模式(Builder Pattern)使用多个简单的对象一步一步构建成一个复杂的对象。这种类型的设计 模式属于创建型模式,它提供了一种创建对象的最佳方式。 何时使用:一些基本部件不会变,而其组合经常变化的时候。如何解决:将变与不变分离开。优点: 1、建造者独立,易扩展。 2、便
阅读全文
摘要:updateConfiguration废弃,createConfigurationContext无效
阅读全文
摘要:Android 将图片保存到系统相册 兼容Android Q以上
阅读全文
摘要:import android.content.Context; import com.commerce.img.entity.DataUrl; import com.google.gson.Gson; import java.io.BufferedReader; import java.io.IOE
阅读全文
摘要:在 Compose 层次结构中的导航函数,相当于xml >> Navigation组件。 implementation 'androidx.navigation:navigation-compose:2.4.1' 别导错了导成 androidx.navigation:navigation-runti
阅读全文
摘要:@Suppress("DEPRECATION") private fun checkIfOnline(): Boolean { val cm = getSystemService(context, ConnectivityManager::class.java) return if (Build.V
阅读全文
摘要:class AppLifeObserver: LifecycleObserver { @OnLifecycleEvent(Lifecycle.Event.ON_START) fun onForeground() { LogUtils.logd("Application enters the fore
阅读全文
摘要:/** * * 2021/11/30 * @author xiaotie */ @SuppressLint("MissingPermission") class VibrateHelp(context: Context) { private var vibrator: Vibrator? = nul
阅读全文
摘要:概念 密封类用来限制类的继承关系,子类数量是固定的。 可以在类名之前使用sealed关键字将类声明为密封类。 当对象具有来自有限集的类型之一,但不能具有任何其他类型时,使用密封类。 密封类的构造函数在默认情况下是私有的,它也不能允许声明为非私有。 简单来理解就是他是一个拓展版的枚举(enum),不同
阅读全文
1