Android - Kotiln basics tutorial
preface
In the previous article, we mainly explained Kotlin's knowledge points related to sets. In this article, we will explain Kotlin's objects in detail!
1. Object
1.1 example 1 (no constructor)
class Player {
//Analysis point 1
var name = "abc"
get() = field.capitalize()
set(value) {
field = value.trim() ...
Added by ScottCFR on Fri, 12 Nov 2021 09:23:33 +0200
Encapsulation attempt of network request framework of Retrofit + Kotlin + MVVM
1. ForewordWhen learning Guo Lin's first line of code, I wrote a Caiyun weather App step by step. I was very impressed by the encapsulation of the network request framework inside. I like the combination of Retrofit + Kotlin + collaboration. Later, I also referred to this part of the code in my own project. However, with the in-depth writing of ...
Added by Judas on Sun, 07 Nov 2021 06:14:26 +0200
Stay up late to fight Android Kotlin interoperability
👉 "About the author"
As we all know, life is a long process, constantly overcoming difficulties and constantly reflecting on the process of progress. In this process, there will be a lot of questions and thoughts about life, so I decided to share all my thoughts, experiences and stories in order to find resonance!!! Focus on Andr ...
Added by mick_otoole on Sat, 06 Nov 2021 05:33:32 +0200
kotlin synergy async await's abnormal stepping pit and correct posture for exception handling
I believe you are very familiar with using Kotlin to do some asynchronous operations. In particular, combined with some components of Jetpack, it is very convenient for us to write asynchronous tasks in Android development.
However, when using a collaborative process, I feel that exception handling is a relatively time-consuming area to unders ...
Added by henrygao on Sat, 30 Oct 2021 10:13:37 +0300
Deep understanding of Kotlin higher-order functions, anonymous functions and lambda expressions
Before we talk about higher-order functions, we have to know what function types are, ah, what? Don't know the function type? Well, let's talk about what is a function type.
1, Function type
Defining variable types in Kotlin is very simple, as follows:
var a :Int = 1 // Int type variable
var person :Person = Person() // Define a Person vari ...
Added by Tomcat13 on Wed, 13 Oct 2021 20:04:37 +0300
[comparative Java Kotlin] data class
In Java, we will create some classes dedicated to holding data, such as various classes ending with Bean and Model as suffixes.
The member variables of these classes are usually various types of data, and the member functions are setters and getters. Or lazy students directly set the visibility of member variables to public, saving setters and ...
Added by deadparrot on Sun, 03 Oct 2021 00:39:42 +0300
Improve the priority of sending messages by Handler in Android practice
When reading the Android drawing source code, many articles analyzed that the execution of drawing message must take precedence over all messages. This is based on the principle of Handler's synchronous barrier mechanism and asynchronous message, but these mechanisms are not open to developers, and the relevant methods are also marked @ hide. ...
Added by bsbotto on Tue, 21 Sep 2021 05:22:33 +0300
Kotlin learns to write notes. You don't even understand the principle
class Person(val age: Int, val name: String){
override fun equals(other: Any?): Boolean {
val other = (other as? Person)?: return false
return other.age == age && other.name == name
}
override fun hashCode(): Int {
return 1 + 7 * age + 13 * name.hashCode()
}
}
And java Similarly, if it is added to a data struc ...
Added by buildakicker on Tue, 07 Sep 2021 03:57:53 +0300
_ Kotlin_ Series_ 2, Kotlin generic, byte Android Senior Engineer Interview
2. What is the use of generics?
3. How to define and use generics?
1. What is generics?
The popular understanding of generics is that many types allow us to program without specifying specific types by using the concept of parameterized types
2. What is the use of generics?
Generics is a security mechanism introduced by JDK 1.5 and a techn ...
Added by magic2goodil on Fri, 03 Sep 2021 09:17:54 +0300
Kotlin: high order function, small code farmers also have big dreams
1.1. Higher order function when function is used as function parameter
Here we introduce sumBy{} higher-order functions in strings. Take a look at the source code first
// Source code of sumBy function
public inline fun CharSequence.sumBy(selector: (Char) -> Int): Int {
var sum: Int = 0
for (element in this) {
...
Added by shneoh on Fri, 03 Sep 2021 01:44:50 +0300