Kotlin: Use of extension functions and higher-order functions

Foreword In the previous article, we introduced in detail three commonly used keywords in Kotlin: inline, noinline, and crossinline. In this article, the author intends to combine the introductions in the previous articles to explain our application in actual development. Usually extension functions and higher-order functions are used in combination, which can simplify the code […]

Flow in-depth series: Using Kotlin Flows in ViewModels

? Flow in-depth series: Using Kotlin Flows in ViewModels ? Flow in-depth series: more intelligent sharing Kotlin Flows ? Flow in-depth series: the strategy of using Kotlin Flow to automatically refresh Android data After Flow appears, LiveData can still be used and can be converted to each other. Loading UI data in Android applications can […]

Jetpack: 009-lambdas, anonymous functions and closures in kotlin

Article directory 1. Concept introduction 2. How to use 2.1 Variables of function type 2.2 Higher-order functions 3. Content summary 4.Experience sharing We introduced the content related to Icon and Imamg in Jetpack in the previous chapter. This chapter mainly introduces the content in Kotlin. lambda, anonymous functions and closures. Enough chatting, let’s talk Android […]

Kotlin + Coroutine + Room used together

Article directory Preface Integrated Room Combined with the use of coroutines Summarize 1. Foreword, Now that kotlin is the trend, coroutines must be used, and with the development of jetpack, many useful libraries have been brought. For example, Room was mentioned today, which is a database similar to greenDao. It not only supports kotlin coroutines/RxJava, […]

Flow in-depth series: Strategies for automatically refreshing Android data using Kotlin Flow

Flow in-depth series: Using Kotlin Flows in ViewModels Flow in-depth series: more intelligent sharing Kotlin Flows Flow in-depth series: Strategies for automatically refreshing Android data using Kotlin Flow Flow in-depth series: the strategy of using Kotlin Flow to automatically refresh Android data Discuss the use of Kotlin Flow to efficiently load data in Android applications. […]

Flow in-depth series: Using Kotlin Flows in ViewModels

Flow in-depth series: Using Kotlin Flows in ViewModels Flow in-depth series: more intelligent sharing Kotlin Flows Flow in-depth series: Strategies for automatically refreshing Android data using Kotlin Flow Flow in-depth series: Using Kotlin Flows in ViewModels After Flow appears, LiveData can still be used and can be converted to each other. Loading UI data in […]

Monitoring network status changes — combining registerNetworkCallback and broadcast (kotlin)

illustrate Android Android monitors network status changes. In applications, we generally need to monitor changes in device network status and make corresponding business processing. We need a convenient and global monitoring implementation. . Use different API methods for different device system versions; Pay attention to the adaptation problem of using broadcast to monitor network status […]

The use of kotlin coroutines in Android

kotlin coroutine in Android Coroutines are a concurrency design pattern that can be used on the Android platform to simplify code that executes asynchronously On Android, coroutines help manage long-running tasks that, if not managed properly, can block the main thread and make your app unresponsive. Features: Lightweight Thread: Sub-threads are independent from the main […]

Coroutine in Kotlin – directly test the coroutine

In this exercise, you will write a test that calls the suspend function directly. Since refreshTitle is provided as a public API, the system will test it directly, showing how to call the coroutine from the test. Here is the refreshTitle function you implemented in the previous exercise: TitleRepository.kt suspend fun refreshTitle() {<!– –> try […]