kotlin

Android alarmManager.setAlarmClock Crash Android 7

北城以北 提交于 2021-01-18 06:13:24
问题 I am getting a crash (on android 7 only) when calling alarmmanager.setAlarmClock in a function where i am setting alarm. I have no idea what is wrong here. And how to fix this crash. This is the function which is getting crash when calling alarmManager.setAlarmClock fun setBeforeAlert( context: Context, offset: Long, beforeMin: Int, pendingIntent: PendingIntent ) { if (offset - beforeMin * 60 * 1000 > 0) { val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager if

kotlin RecyclerView Pagination

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-18 05:34:48
问题 I need to make my RecyclerView load only 10 items and load more 10 after scrolling and work like this. I was add the items in array using Volley . Here is my RecyclerView adapter. class newsAdapter constructor(private val activety:MainActivity, private val ListOfCash:ArrayList<newsModling>, val listener:BTNListener): RecyclerView.Adapter<newsAdapter.ViewHolder>(),BTNListener { override fun getItemCount(): Int = ListOfCash.size override fun onCreateViewHolder(parent: ViewGroup, viewType: Int):

How to Enable Kotlin Android Extensions by Default in Android Studio 4.1

徘徊边缘 提交于 2021-01-18 05:28:29
问题 Why kotlin-android-extensions not enabled by default in this latest version of Android Studio? In fact, as long as i know, i have to manually add the plugin in gradle files. Any workaround so that i can add the plugin and enable it automatically everytime i create new project? Thanks before. ICYMI, this is the code that needs to be added to enable kotlin-android plugins { id 'com.android.application' id 'kotlin-android' // add kotlin-android-extensions id 'kotlin-android-extensions' } 回答1: In

How to Enable Kotlin Android Extensions by Default in Android Studio 4.1

家住魔仙堡 提交于 2021-01-18 05:28:27
问题 Why kotlin-android-extensions not enabled by default in this latest version of Android Studio? In fact, as long as i know, i have to manually add the plugin in gradle files. Any workaround so that i can add the plugin and enable it automatically everytime i create new project? Thanks before. ICYMI, this is the code that needs to be added to enable kotlin-android plugins { id 'com.android.application' id 'kotlin-android' // add kotlin-android-extensions id 'kotlin-android-extensions' } 回答1: In

How to Enable Kotlin Android Extensions by Default in Android Studio 4.1

那年仲夏 提交于 2021-01-18 05:25:43
问题 Why kotlin-android-extensions not enabled by default in this latest version of Android Studio? In fact, as long as i know, i have to manually add the plugin in gradle files. Any workaround so that i can add the plugin and enable it automatically everytime i create new project? Thanks before. ICYMI, this is the code that needs to be added to enable kotlin-android plugins { id 'com.android.application' id 'kotlin-android' // add kotlin-android-extensions id 'kotlin-android-extensions' } 回答1: In

SpringBoot结合MyBatis Plus 自动生成代码

偶尔善良 提交于 2021-01-17 08:39:04
SpringBoot结合MyBatis Plus 自动生成代码 本来这一章要介绍Redis+AOP优化权限,可是发现还是需要先介绍一些MyBatis Plus自动生成代码 MyBatis Plus简介 MyBatis-Plus (opens new window)(简称 MP)是一个 MyBatis (opens new window)的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。 MyBatis Plus特性 无侵入:只做增强不做改变,引入它不会对现有工程产生影响,如丝般顺滑 损耗小:启动即会自动注入基本 CURD,性能基本无损耗,直接面向对象操作 强大的 CRUD 操作:内置通用 Mapper、通用 Service,仅仅通过少量配置即可实现单表大部分 CRUD 操作,更有强大的条件构造器,满足各类使用需求 支持 Lambda 形式调用:通过 Lambda 表达式,方便的编写各类查询条件,无需再担心字段写错 支持主键自动生成:支持多达 4 种主键策略(内含分布式唯一 ID 生成器 - Sequence),可自由配置,完美解决主键问题 支持 ActiveRecord 模式:支持 ActiveRecord 形式调用,实体类只需继承 Model 类即可进行强大的 CRUD 操作 支持自定义全局通用操作:支持全局通用方法注入( Write once,

Java 中的不可变数据结构

拟墨画扇 提交于 2021-01-15 13:36:57
最近,在我主导的几场代码面试中,经常出现不可变数据结构(Immutable Data Structure)相关内容。关于这个主题我个人并不过分教条,不变性通常体现在数据结构中," 除非必要 "否则不会要求代码一定具备不变性。然而,我发现大家对不变性(Immutability)这个概念似乎有一些误解。开发者通常认为加上 `final`,或者在 Kotlin、Scala 中加上 `val` 就足以实现不可变对象。这篇文章会深入讨论不可变引用和不可变数据结构。 1. 不可变数据结构的优点 不可变数据结构有下列显著优点: 没有无效状态(Invalid State) 线程安全 代码易于理解 易于测试 可用作值类型 译注:在计算机编程中包含两种类型,值类型 value type 与引用类型 reference type。值类型表示实际值,引用类型表示对其他值或对象的引用。 2. 没有无效状态 不可变对象只能通过构造函数初始化,并且通过参数限制了输入的有效性,从而确保对象不会包含无效值。例如下面这段代码示例: ```java Address address = new Address(); address.setCity( "Sydney" ); // 由于没有设置 country,address 现在处于无效状态. Address address = new Address( "Sydney"

Kotlin开发团队惹上麻烦了!

烈酒焚心 提交于 2021-01-15 13:11:55
Python实战社群 Java实战社群 长按识别下方二维码, 按需求添加 扫码关注添加客服 进Python社群▲ 扫码关注添加客服 进Java社群 ▲ 作者 | 褚杏娟 来源丨InfoQ(infoqchina) 根据彭博亿万富翁指数,总部位于捷克的软件开发公司 JetBrains 的市值已经达到 70 亿美元,三位俄罗斯创始人中的 Sergey Dmitriev 和 Valentin Kipiatkov 也进入了亿万富翁行列,而该公司不仅没有上市,也从未接受过任何风险投资。 对风投不感兴趣 SlashData 数据显示,Kotlin 是增长最快的语言。在过去两年中,它的规模几乎翻了一番。2019 年,谷歌宣布 Kotlin 编程语言成为 Android 应用程序开发人员的首选语言。谷歌表示,超过 60% 的专业 Android 开发者使用 Kotlin,谷歌自身也利用 Kotlin 语言来设计地图、家庭和游戏应用程序。Kotlin 此后更是势不可挡。 而 Kotlin 背后的开发团队就是 JetBrains。JetBrains 成立于 2000 年,是一家私人持股公司。除了 Kotlin,该公司为人所熟知的产品还包括用于 Java 的 IntelliJ 集成开发环境(IDE)和用于编程语言 Python 的、使用最广泛的 IDE PyCharm 等。 据悉,该公司拥有近 1500

Kotlin设计模式实现之装饰者模式(Decorator)

。_饼干妹妹 提交于 2021-01-13 17:24:31
前言 今天是2020年的第一天,在这里祝大家元旦快乐!之前用kotlin实现了策略模式,文中写到要多写几篇文章来加深 一 下对设计模式的理解。那么今天要写的看题目应该就知道了:装饰者模式(也叫装饰模式)。下面是装饰者模式的定义: 装饰者模式(Decorator):在不改变对象自身的基础上,动态地给一个对象添加一些额外的职责。与继承相比,装饰者是一种更轻便灵活的做法。若要扩展功能,装饰者提供了比继承更有弹性的替代方法。 故事场景 小星刚毕业,到一家公司实习。今天来到公司后,一如既往地开始编写它的增删改查。 刚刚坐下打开电脑,技术锦鲤走了过来,小星内心开始发牢骚(锦鲤来干啥,每回它来都没好事)。锦鲤告诉小星,公司想要编写一个卖咖啡的系统,有不同种类的咖啡,需要能计算出咖啡的钱和区分咖啡的类别。 小星:没问题,很简单。 十分钟后,小星写出了它的第一版代码: 咖啡的基类: abstract class Beverage ( var description: String = "Unknown Beverage" ) { //描述 open fun getDescriptions () :String{ return description } //价钱 abstract fun cost () : Double } 其他咖啡(子类): /** * 深度烘焙咖啡(星巴克) * *

Python 开发人员常犯的这7个错误,可能是“致命”的!

痴心易碎 提交于 2021-01-12 15:08:41
<section id="nice" data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px; color: black; padding: 0 10px; line-height: 1.6; word-spacing: 0px; letter-spacing: 0px; word-break: break-word; word-wrap: break-word; text-align: left; font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;"><p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black;"><img src="https://imgkr2.cn-bj.ufileos.com/e81da1b9-d99e-49fa