Kotlin introduction section 2

Characteristics of Unit function It is similar to void in java, but java is a key frame, not a type, which is very contradictoryUnit is not written. It also exists by default. Unit represents the ignored type returned without parameters package com.fyx.s1 fun main() { } fun convert() { } //Equivalent to the above fun convert1() : Unit{ ...

Posted by thesmartone on Fri, 03 Dec 2021 06:26:47 -0800

Kotlin functional programming

catalogue Features of functional programming Declarative function Lambda expression Higher order function case Features of functional programming Functional programming is essentially a collection of functions. For example, you want to filter odd numbers in a collection: fun testFunX(): Unit { val list = listOf(1,2,3,4,5,6,7) v ...

Posted by Buchead on Thu, 25 Nov 2021 17:14:39 -0800

Compose + MVI + Navigation to quickly implement Android client

Recommended by Haowen: Author: Ricardo mjiang preface At the end of July this year, Google officially released the 1.0 stable version of Jetpack Compose, which shows that Google believes that Compose can be used in the production environment. I believe that the wide application of Compose is in the near future. Now should be a better time t ...

Posted by abo28 on Wed, 24 Nov 2021 00:31:08 -0800

Android - the end of Gradle tutorial

preface So far, the Gradle foundation and Kotlin foundation have been explained. Therefore, in this article, we will explain in detail the construction optimization of Gradle and how to migrate from Groovy to KTS! Don't say much, just start! 1. Gradle build optimization Optimization is all about configuration. Just go through it quickly! Fo ...

Posted by sebmaurer on Mon, 22 Nov 2021 14:30:20 -0800

Jetpack Lifecycle source code analysis

1, Lifecycle Lifecycle is a lifecycle aware component in Jetpack. It is used to store information about the lifecycle state of an Activity or Fragment, and allow other objects to observe this state. Lifecycle uses state and event enumerations to track the lifecycle state of its associated components. 2, Basic use   Using Lifecycle to o ...

Posted by ibelimb on Wed, 17 Nov 2021 05:25:09 -0800

Kotlin actual combat [v] anomalies in kotlin

1, How kotlin throws exceptionsException handling in Kotlin is similar to that in Java or other languages. A function can end normally or throw an exception when an error occurs. The function caller catches the exception and handles it; If not, the exception is thrown up the call stack again.The basic form of exception handling statements in Ko ...

Posted by BizLab on Thu, 11 Nov 2021 23:28:49 -0800

Kotlin Vocabulary | use the extensions in kotlin to improve code readability

Have you ever wanted to add new functions or properties to the API of a class? You can usually solve this problem by inheriting the class or creating a new function that takes an instance of the class as a parameter. Java programming language usually uses Utils class to solve such problems, but this method does not support automatic code com ...

Posted by dhorn on Wed, 10 Nov 2021 19:34:50 -0800

Start with the Room Kotlin API

Room It is the encapsulation of SQLite, which makes the operation of Android database very simple. It is also my favorite Jetpack library so far. In this article, I will tell you how to use and test the Room Kotlin API, and I will share its working principle during the introduction. We will be based on Room with a view codelab Explain it to ...

Posted by shruti on Wed, 10 Nov 2021 19:24:16 -0800

Kotlin actual combat [v] anomalies in kotlin

1, How kotlin throws exceptions Exception handling in Kotlin is similar to that in Java or other languages. A function can end normally or throw an exception when an error occurs. The function caller catches the exception and handles it; If not, the exception is thrown up the call stack again. The basic form of exception handling statements i ...

Posted by Jtech on Tue, 09 Nov 2021 14:04:02 -0800

On the fifth day of Kotlin development, broadcast BroadcastReceiver

Full code Gitee address: Kotlin Demo: 15 day kotlin learning plan Day 5 learning content code: Chapter5 catalogue preface definition Application scenario Knowledge point 1: static registration broadcast Knowledge point 2: dynamic registration broadcast Knowledge point 3: Customize global broadcasting preface BroadcastReceiver is o ...

Posted by Drabin on Mon, 08 Nov 2021 00:54:23 -0800