kotlin

以 Kotlin 为例浅谈如何学习程序语言

。_饼干妹妹 提交于 2020-11-30 00:43:41
我的第一门课程 “Kotlin 系统入门与进阶”上线一年来,我不断地与大家探讨学习中的一些问题,最近颇有心得,遂分享给大家。 持续学习 庄子曰:吾生也有涯,而知也无涯。 工作了这么久还要回头来谈学习,也许有些奇怪,但细想下,学校生涯的结束才是诸位学习的又一个新的开始。记得刚工作的时候组里有位大神吐槽:有些人,工作了十年还不如个两年的新人——是这位新人学得太快,还是这位老人学得太慢?都不是,而是这位老同志大概在适应了工作的环境之后就停留在了“舒适区”,止步不前了。想必大家都熟悉“舒适区”这个概念,如果你想要持续得到进步,那么你就不能过得太舒服,不然就如同这温水煮青蛙一般,一旦环境有变动,你将无所适从。 那么说到 Kotlin,它与 Java 是一脉相承的,这与 React Native、Flutter 有着本质的差异,即便我们有理由不去学习后面二者,那在现在的大环境和大背景之下,不去主动出击学习 Kotlin,就会直接导致大家失去一些选择的机会,也会让大家失去在技术思维和技术视野上反哺 Java 的机会。作为 Android 开发者,我们实际上已经没有理由继续待在 Java 的“舒适区”。 持续学习,要求我们能够勇于探索自己不熟悉的领域,主动扩张自己知识的边界,时刻敏感地关注行业变化,让自己始终保持活力。 原创学习 每当有一门语言放在我们面前,糟糕的是我们还必须得学它

Could not get unknown property 'PrivateData' for object of type org.gradle.api.internal.initialization.DefaultScriptHandler

自闭症网瘾萝莉.ら 提交于 2020-11-29 21:05:44
问题 There is an open source project here. After trying multiple times to build it, there is an error that make build Failed : Task failed with an exception. Where: Build file '/src/apps/build.gradle' line: 19 What went wrong: A problem occurred evaluating root project 'apps'. Could not get unknown property 'PrivateData' for object of type org.gradle.api.internal.initialization.DefaultScriptHandler. Here is line 19 : buildscript { PrivateData.merge(project, "all-apps") ... } And the defined

Parsing webp file header in Kotlin to get its height and width, but getting unexpected results

有些话、适合烂在心里 提交于 2020-11-29 19:27:49
问题 I am trying to read the WebP image header, according to the WebP Container Specification of Extended File Format. fun get24bit(data: ByteArray, index: Int): Int { return ((data[0 + index].toInt()) or (data[1 + index].toInt() shl 8) or (data[2 + index].toInt() shl 16)) } fun get32bit(data: ByteArray, index: Int): Int { return get24bit(data, index) or (data[3 + index].toInt() shl 24) } // data -> File(fileName).readBytes() for testing purpose fun webpExtract(data: ByteArray) { println(String

Unable to add apple device in Android studio

a 夏天 提交于 2020-11-29 09:51:04
问题 I want to try out the Kotlin Multiplatform Mobile (KMM) in Android studio. I have installed the Plugin and when I try to add configuration for IOS, nothing shows up. I just have an IOS option but nothing shows up when I click on it. The android device is already set up, so I was able to run it in Android. 回答1: I guess you are not running Android Studio on macOS . You must have macOS to compile through XCode and use Apple Simulators . If you are running AS on macOS and you created the project

In Kotlin, what's the difference between start and first?

穿精又带淫゛_ 提交于 2020-11-29 08:29:31
问题 I'm learning Kotlin, but I can't seem to find straight answers to simple questions. I presume that it's so new, no one has had a chance to ask the obvious questions yet. So here it goes. When I want to get the smallest item in a range, I type: range.start But I get the warning, "Could be replaced with unboxed first ". Not sure what unboxed means--can't even guess. But when I use this command: range.first the warning goes away. What's happening here? Should I even be concerned? Why does Kotlin

In Kotlin, what's the difference between start and first?

霸气de小男生 提交于 2020-11-29 08:27:31
问题 I'm learning Kotlin, but I can't seem to find straight answers to simple questions. I presume that it's so new, no one has had a chance to ask the obvious questions yet. So here it goes. When I want to get the smallest item in a range, I type: range.start But I get the warning, "Could be replaced with unboxed first ". Not sure what unboxed means--can't even guess. But when I use this command: range.first the warning goes away. What's happening here? Should I even be concerned? Why does Kotlin

What is the difference between textView.setText(string) and textView.text = $string

感情迁移 提交于 2020-11-29 08:21:58
问题 Hi I am making a app with Kotlin and I found that I can both use textView.setText(str) and textView.text = $str I wanna know what I should use and the differences between them. Thank you. 回答1: They're the same in most cases , basically Kotlin generates a synthetic property for the class attributes based on their getter, which you can use to assign values to and get values from. //So, for most cases textView.setText("some value"); //Is the same as textView.text = "some value" //The second is

What is the difference between textView.setText(string) and textView.text = $string

◇◆丶佛笑我妖孽 提交于 2020-11-29 08:20:44
问题 Hi I am making a app with Kotlin and I found that I can both use textView.setText(str) and textView.text = $str I wanna know what I should use and the differences between them. Thank you. 回答1: They're the same in most cases , basically Kotlin generates a synthetic property for the class attributes based on their getter, which you can use to assign values to and get values from. //So, for most cases textView.setText("some value"); //Is the same as textView.text = "some value" //The second is

What is the difference between textView.setText(string) and textView.text = $string

你说的曾经没有我的故事 提交于 2020-11-29 08:19:34
问题 Hi I am making a app with Kotlin and I found that I can both use textView.setText(str) and textView.text = $str I wanna know what I should use and the differences between them. Thank you. 回答1: They're the same in most cases , basically Kotlin generates a synthetic property for the class attributes based on their getter, which you can use to assign values to and get values from. //So, for most cases textView.setText("some value"); //Is the same as textView.text = "some value" //The second is

Pick from Google Photos provider with ACTION_GET_CONTENT or OPEN_DOCUMENT

跟風遠走 提交于 2020-11-29 04:21:55
问题 I have no clue at why this happens, but I am not able to pick images from the Google Photos provider. Testing on API 27. With ACTION_GET_CONTENT If I use: val intent = Intent(Intent.ACTION_GET_CONTENT) intent.addCategory(Intent.CATEGORY_OPENABLE) intent.type = "image/*" I can see Google Photos among the provider I can browse to some picture and select it Then I am directed back to the providers list (not to my app), as if the provider had crashed in a try-catch When I open the Photos provider