![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
kotlin
qq910689331
分享心得 记录生活 开源地址:https://github.com/liberations
展开
-
kotlin中Int Byte的相互转换,常用
串口通信中传输单位为byte,一个byte占用八位/8bit常用的方法1.一个Int转成一个byte 直接调用Int.toByte()方法看如下直接转换 var num = 23 var num2Byte = num.toByte() println("mytest num $num num2Byte$num2Byte")结果一切正常让这里的num=128结果如何?转成byte结果变成了-1 具体是什么原因各位可以去补充下有趣的原码 反码 补码的相关知识。所以一个int要想不丢失精原创 2020-08-01 16:48:08 · 8527 阅读 · 2 评论 -
kotlin内联函数let、with、run、apply、also
最近面试被问到kotlin内联函数,这里作个简单的总结let在函数体内访问该对象中的属性或方法iv_back_activity_clock.let { it.adjustViewBounds = true it.scaleType = ImageView.ScaleType.FIT_XY }判断调用者是否为null (常用) var text: String? = null text?.let { setText(it) }原创 2020-05-25 11:03:53 · 664 阅读 · 0 评论 -
kotlin 一个加号引发的血案
看下面一段代码。你觉得呢计算结果是啥var hour = Calendar.getInstance().get(Calendar.HOUR) + Calendar.getInstance().get(Calendar.AM_PM) * 12当前计算小时加上0或者12呗,你自信的回答然而,,,计算结果只是Calendar.getInstance().get(C...原创 2018-09-12 14:02:46 · 430 阅读 · 0 评论 -
android Too many open files 解决
遍历某一文件夹,当文件数过多时,或出现Too many open files异常,有问题的代码 /** * 获取指定文件大小 * * @param file * @return * @throws Exception */ private long getFileSize(File file) throws Exceptio...原创 2018-09-14 09:22:42 · 2805 阅读 · 0 评论 -
Rxjava 优雅的实现短信验证码发送
废话不多说直接上代码private fun countDown() { btn_send_code_activity_login.isEnabled = false disPose = Flowable.intervalRange(0, 120, 0, 1, ...原创 2018-09-14 17:47:51 · 531 阅读 · 0 评论