Kotlin: how to achieve multi-threaded synchronization?

Problem backgroundMultithreaded tasks to be executed: Task 1 and task 2 are executed in parallel; When all execution is completed, execute task 3.// Each task takes time to simulate through sleep val task1: () -> String = { sleep(2000) "Hello".also { println("task1 finished: $it") } } val task2: () -> String = { sleep(2000) ...

Posted on Tue, 07 Dec 2021 03:49:30 -0500 by lulon83

Some Tips in Kotlin development

Scope function selection At present, there are let, run, with and apply   and   also five scope functions. The official document has a table to illustrate the differences between them: To sum up, there are several differences: 1. apply and also return context objects. 2,let,run   And with return lambda results. 3. The ref ...

Posted on Tue, 07 Dec 2021 03:21:03 -0500 by febrarian

Kotlin: how to achieve multi-threaded synchronization?

  Problem background Multithreaded tasks to be executed: Task 1 and task 2 are executed in parallel; When all execution is completed, execute task 3. // Each task takes time to simulate through sleep val task1: () -> String = { sleep(2000) "Hello".also { println("task1 finished: $it") } } val task2: () -> String = { sleep(2 ...

Posted on Mon, 06 Dec 2021 23:57:03 -0500 by nahydy

Learning from beginning to end of Android cultivation manual Kotlin [complete]

Sharing of previous articles Click jump = > stay up late and fight Android again from bronze to King - development efficiency plug-in Click jump = > unity particle special effects series - Tornado preform is ready, and the unitypackage package can be used directly! Click jump = > my sister asked me to unlock the new skills of dolls: ...

Posted on Mon, 06 Dec 2021 15:55:24 -0500 by shastry

Jetpack room framework usage and source code analysis

1, Introduction 1. What is Room The room framework is one of many component libraries of Android Jetpack. The emergence of Jetpack unifies the Android development ecology, various tripartite libraries are gradually replaced by official components, and room gradually replaces competitive products as the most mainstream database ORM framewo ...

Posted on Thu, 25 Nov 2021 22:10:17 -0500 by tazdevil

Kotlin writes custom ViewGroup

Recommended by Haowen: Author: IAn2018 With the blessing of Kotlin, the composition recently implemented by Android makes it easier and faster to write UI. There is no need to worry about layout nesting or declarative UI. So there are so many advantages of composition. Is there a "way out" for native writing? Today, I'd like to sh ...

Posted on Tue, 23 Nov 2021 16:59:10 -0500 by dotMoe

Jetpack LiveData source code analysis

1, LiveData overview LiveData is an observable data holder class. LiveData is located under the android.lifecycle package and has the ability to sense the life cycle, such as the life cycle of Activity, Fragment, Service, etc. This perception means that there is no need to manually handle the life cycle when using, so as to avoid problems such ...

Posted on Sat, 20 Nov 2021 19:29:40 -0500 by kkeim

Jetpack: Room super detailed use pit guide!

1, Introduction ORM(Object Relational Mapping) relational mapping library provides a layer of encapsulation on Sqlite to optimize the convenience of database operation. The architecture diagram of Room is as follows: Entity: an entity corresponds to a table in the database. Entity class is the mapping of Sqlite table structure to Java ...

Posted on Sat, 20 Nov 2021 07:10:04 -0500 by neo0506

Binary, hexadecimal, big end, small end

Use of hexadecimal In the development process, it is common to write files. If the content is text, you can open it with a notepad software to check whether the content is correct. If you write an audio file, you should use the audio software to check. If it is a video file, you should use the video software to check... The corresponding files ...

Posted on Fri, 19 Nov 2021 04:01:22 -0500 by kriek

Kotlin process control statement

Article structure: Branch statement (if, when)Circular statements (for, while)Jump statements (break, continue, return, label, throw) Branch statement (if, when) if expression In kotlin, if is an expression that returns a value The if branch can be a code block, and the last expression is the value of the block (the return value of the la ...

Posted on Tue, 09 Nov 2021 20:39:04 -0500 by MCP