Kotlin: a new way to play that you haven't played before
Air safety
In Java, we don't have to force us to deal with null objects, so null pointerexception null pointers often appear. Now Kotlin restricts null objects. We must deal with whether the object is null at compile time, otherwise the compilation will fail When the object cannot be empty, you can use this object directly
fun getText() : ...
Posted by xcoderx on Fri, 21 Jan 2022 16:29:42 +0100
Use of Kotlin synergy
preface
This is a learning record of Kotlin collaboration on the Android official website. Record the characteristics and applications of Kotlin Coroutines on Android
Overview of collaborative process
1, What is a collaborative process?
Coprocessing is a concurrent design pattern that can be used to simplify asynchronously executed code. It can ...
Posted by snteran on Fri, 21 Jan 2022 04:51:46 +0100
Kotin collaboration from zero to one "Five"
The last article introduced the operation and recovery of the process, and this article introduces the parent-child process
What is a subprocess
Let's take an example here The coroutine created by the first launch represents the dead parent coroutine, and the coroutine created by the second launch represents the child coroutine. Note that th ...
Posted by Lyleyboy on Fri, 21 Jan 2022 00:53:26 +0100
Kotlin's coordination process starts and cancels the coordination process
Builder of collaborative process
Both the launch and async builders are used to start new processes launch, which returns a job without any result value async returns a Deferred, which is also a job and can be used await() gets its final result on a Deferred value
//Wait for a job: join and await
private fun runBlocking1(){
// ...
Posted by jcornett on Wed, 19 Jan 2022 12:59:40 +0100
Jetpack - defects of LiveData component and Countermeasures
1, Foreword
In order to solve the problem of chaotic architecture design since the development of android app, Google launched the family bucket solution of jetpack MVVM. As the core of the whole solution, LiveData, with its life cycle security, memory security and other advantages, even has the trend to gradually replace EventBus and RxJava a ...
Posted by jay_bo on Wed, 19 Jan 2022 01:56:08 +0100
The scope function in Kotlin is enough
This article mainly shares the usage and differences of Kotlin's scope functions let, run, with, apply and also.
During the execution of scope function, a temporary scope is formed through lambda expression, which can reduce the number of some logic codes.
Context object: this or it
this
run, with, and apply reference context objects wi ...
Posted by BenS on Wed, 19 Jan 2022 01:50:47 +0100
[Android advanced] Kotlin condition control
IF expressionAn if statement contains a Boolean expression and one or more statements.// Traditional Use
var max = a
if (a < b) max = b
// Use else
var max: Int
if (a > b) {
max = a
} else {
max = b
}
// As an expression
val max = if (a > b) a else bWe can also assign the result of the IF expression to a variable.val max ...
Posted by hagman on Tue, 18 Jan 2022 06:55:19 +0100
Kotlin process I - Coroutine
Python wechat ordering applet course video
https://edu.csdn.net/course/detail/36074
Python practical quantitative transaction financial management system
https://edu.csdn.net/course/detail/35475 Kotlin collaboration series article navigation: Kotlin process I - Coroutine Kotlin collaboration process 2 - Channel Kotlin collaboration process I ...
Posted by yeshuawatso on Sat, 15 Jan 2022 18:59:42 +0100
Kotlin collaboration + Retrofit is the most elegant network request
1. Introduction
Retrofit's support for collaborative processes is very rudimentary. The use of kotlin does not conform to kotlin's elegance
interface TestServer {
@GET("banner/json")
suspend fun banner(): ApiResponse<List<Banner>>
}
//Network request for parallel exception capture
fun oldBanner(){
viewModelScope. ...
Posted by mightymax on Sat, 15 Jan 2022 12:56:02 +0100
Kotlin collaboration + Retrofit is the most elegant network request
1. IntroductionRetrofit's support for collaborative processes is very rudimentary. The use of kotlin does not conform to kotlin's eleganceinterface TestServer {
@GET("banner/json")
suspend fun banner(): ApiResponse<List<Banner>>
}
//Network request for parallel exception capture
fun oldBanner(){
viewModelScope.laun ...
Posted by dancer on Sat, 15 Jan 2022 03:53:21 +0100