Muutke küpsiste eelistusi

E-raamat: Programming Android with Kotlin: Achieving Structured Concurrency with Coroutines

  • Formaat: EPUB+DRM
  • Ilmumisaeg: 06-Dec-2021
  • Kirjastus: O'Reilly Media
  • Keel: eng
  • ISBN-13: 9781492062950
  • Formaat - EPUB+DRM
  • Hind: 40,37 €*
  • * hind on lõplik, st. muud allahindlused enam ei rakendu
  • Lisa ostukorvi
  • Lisa soovinimekirja
  • See e-raamat on mõeldud ainult isiklikuks kasutamiseks. E-raamatuid ei saa tagastada.
  • Formaat: EPUB+DRM
  • Ilmumisaeg: 06-Dec-2021
  • Kirjastus: O'Reilly Media
  • Keel: eng
  • ISBN-13: 9781492062950

DRM piirangud

  • Kopeerimine (copy/paste):

    ei ole lubatud

  • Printimine:

    ei ole lubatud

  • Kasutamine:

    Digitaalõiguste kaitse (DRM)
    Kirjastus on väljastanud selle e-raamatu krüpteeritud kujul, mis tähendab, et selle lugemiseks peate installeerima spetsiaalse tarkvara. Samuti peate looma endale  Adobe ID Rohkem infot siin. E-raamatut saab lugeda 1 kasutaja ning alla laadida kuni 6'de seadmesse (kõik autoriseeritud sama Adobe ID-ga).

    Vajalik tarkvara
    Mobiilsetes seadmetes (telefon või tahvelarvuti) lugemiseks peate installeerima selle tasuta rakenduse: PocketBook Reader (iOS / Android)

    PC või Mac seadmes lugemiseks peate installima Adobe Digital Editionsi (Seeon tasuta rakendus spetsiaalselt e-raamatute lugemiseks. Seda ei tohi segamini ajada Adober Reader'iga, mis tõenäoliselt on juba teie arvutisse installeeritud )

    Seda e-raamatut ei saa lugeda Amazon Kindle's. 

Developing applications for the Android mobile operating system can seem daunting, particularly if it requires learning a new programming language: Kotlin, now Android's official development language. With this practical book, Android developers will learn how to make the transition from Java to Kotlin, including how Kotlin provides a true advantage for gaining control over asynchronous computations.

Authors Pierre-Olivier Laurence, Amanda Hinchman-Dominguez, G. Blake Meike, and Mike Dunn explore implementations of the most common tasks in native Android development, and show you how Kotlin can help you solve concurrency problems. With a focus on structured concurrency, a new asynchronous programming paradigm, this book will guide you through one of Kotlin's most powerful constructs, coroutines.

Learn about Kotlin essentials and the Kotlin Collections Framework Explore Android fundamentals: the operating system and the application container and its components Learn about thread safety and how to handle concurrency Write sequential, asynchronous work at a low cost Examine structured concurrency with coroutines, and learn how channels make coroutines communicate Learn how to use flows for asynchronous data processing Understand performance considerations using Android profiling tools Use performance optimizations to trim resource consumption
Preface ix
1 Kotlin Essentials
1(28)
The Kotlin Type System
2(6)
Primitive Types
2(1)
Null Safety
3(2)
The Unit Type
5(1)
Function Types
6(2)
Generics
8(1)
Variables and Functions
8(4)
Variables
8(1)
Lambdas
9(1)
Extension Functions
10(2)
Classes
12(12)
Class Initialization
12(2)
Properties
14(1)
Lateinit Properties
15(2)
Lazy Properties
17(1)
Delegates
18(1)
Companion Objects
19(1)
Data Classes
20(1)
Enum Classes
21(2)
Sealed Classes
23(1)
Visibility Modifiers
24(2)
Summary
26(3)
2 The Kotlin Collections Framework
29(24)
Collection Basics
29(5)
Java Interoperability
30(1)
Mutability
30(2)
Overloaded Operators
32(1)
Creating Containers
33(1)
Functional Programming
34(3)
Functional Versus Procedural: A Simple Example
35(1)
Functional Android
36(1)
Kotlin Transformation Functions
37(7)
The Boolean Functions
37(1)
Filter Functions
38(1)
Map
38(2)
flatMap
40(2)
Grouping
42(1)
Iterators Versus Sequences
43(1)
An Example
44(7)
The Problem
44(1)
The Implementation
45(6)
Summary
51(2)
3 Android Fundamentals
53(28)
The Android Stack
53(2)
Hardware
54(1)
Kernel
54(1)
System Services
55(1)
Android Runtime Environment
55(1)
Applications
55(1)
The Android Application Environment
55(7)
Intents and Intent Filters
57(2)
Context
59(3)
Android Application Components: The Building Blocks
62(11)
The Activity and Its Friends
62(5)
Services
67(4)
Content Providers
71(1)
Broadcast Receivers
72(1)
Android Application Architectures
73(3)
MVC: The Foundation
74(1)
Widgets
75(1)
The Local Model
75(1)
Android Patterns
76(2)
Model-View-Intent
76(1)
Model-View-Presenter
76(1)
Model-View-ViewModel
77(1)
Summary
78(3)
4 Concurrency in Android
81(20)
Thread Safety
82(2)
Atomicity
82(1)
Visibility
83(1)
The Android Threading Model
84(1)
Dropped Frames
85(2)
Memory Leaks
87(3)
Tools for Managing Threads
90(5)
Looper/Handler
91(2)
Executors and ExecutorServices
93(2)
Tools for Managing Jobs
95(4)
JobScheduler
96(2)
WorkManager
98(1)
Summary
99(2)
5 Thread Safety
101(14)
An Example of a Thread Issue
101(2)
Invariants
103(4)
Mutexes
104(1)
Thread-Safe Collections
104(3)
Thread Confinement
107(1)
Thread Contention
108(1)
Blocking Call Versus Nonblocking Call
109(1)
Work Queues
110(1)
Back Pressure
111(2)
Summary
113(2)
6 Handling Concurrency Using Callbacks
115(14)
Example-of-Purchase Feature
116(2)
Creating the App
118(8)
View-Model
118(1)
View
119(4)
Implement the Logic
123(1)
Discussion
124(2)
Limitations of the Threading Model
126(1)
Summary
127(2)
7 Coroutines Concepts
129(28)
What Exactly Is a Coroutine?
129(5)
Your First Coroutine
130(3)
The async Coroutine Builder
133(1)
A Quick Detour About Structured Concurrency
134(3)
The Parent-Child Relationship in Structured Concurrency
137(1)
CoroutineScope and CoroutineContext
138(7)
Suspending Functions
145(1)
Suspending Functions Under the Hood
146(4)
Using Coroutines and Suspending Functions: A Practical Example
150(3)
Don't Be Mistaken About the suspend Modifier
153(1)
Summary
154(3)
8 Structured Concurrency with Coroutines
157(44)
Suspending Functions
157(14)
Set the Scene
158(2)
Traditional Approach Using java.util.concurrent.ExecutorService
160(3)
A Reminder About HandlerThread
163(4)
Using Suspending Functions and Coroutines
167(4)
Summary of Suspending Functions Versus Traditional Threading
171(1)
Cancellation
171(16)
Coroutine Lifecycle
172(2)
Cancelling a Coroutine
174(2)
Cancelling a Task Delegated to a Third-Party Library
176(4)
Coroutines That Are Cooperative with Cancellation
180(2)
Delay Is Cancellable
182(1)
Handling Cancellation
183(1)
Causes of Cancellation
184(3)
Supervision
187(2)
supervisorScope Builder
189(1)
Parallel Decomposition
189(2)
Automatic Cancellation
191(1)
Exception Handling
191(8)
Unhandled Versus Exposed Exceptions
191(2)
Exposed Exceptions
193(3)
Unhandled Exceptions
196(3)
Summary
199(1)
Closing Thoughts
200(1)
9 Channels
201(34)
Channels Overview
202(10)
Rendezvous Channel
204(4)
Unlimited Channel
208(1)
Conflated Channel
209(1)
Buffered Channel
210(1)
Channel Producers
211(1)
Communicating Sequential Processes
212(15)
Model and Architecture
213(1)
A First Implementation
214(5)
The select Expression
219(2)
Putting It All Together
221(1)
Fan-Out and Fan-In
222(1)
Performance Test
223(1)
Back Pressure
224(1)
Similarities with the Actor Model
225(1)
Execution Is Sequential Inside a Process
226(1)
Final Thoughts
226(1)
Deadlock in CSP
227(2)
TL;DR
229(1)
Limitations of Channels
230(2)
Channels Are Hot
232(1)
Summary
233(2)
10 Flows
235(40)
An Introduction to Flows
236(4)
A More Realistic Example
237(2)
Operators
239(1)
Terminal Operators
239(1)
Examples of Cold Flow Usage
240(11)
Use Case #1 Interface with a Callback-Based API
240(5)
Use Case #2 Concurrently Transform a Stream of Values
245(2)
What Happens in Case of Error?
247(1)
Final Thoughts
248(1)
Use Case #3 Create a Custom Operator
248(3)
Usage
251(1)
Error Handling
251(11)
The try/catch Block
252(2)
Separation of Concern Is Important
254(1)
Exception Transparency Violation
255(1)
The catch Operator
256(3)
Materialize Your Exceptions
259(3)
Hot Flows with SharedFlow
262(12)
Create a SharedFlow
263(1)
Register a Subscriber
263(1)
Send Values to the SharedFlow
264(1)
Using SharedFlow to Stream Data
264(6)
Using SharedFlow as an Event Bus
270(1)
StateFlow: A Specialized SharedFlow
271(1)
An Example of StateFlow Usage
272(2)
Summary
274(1)
11 Performance Considerations with Android Profiling Tools
275(36)
Android Profiler
277(27)
Network Profiler
280(6)
CPU Profiler
286(11)
Energy Profiler
297(2)
Memory Profiler
299(5)
Detecting Memory Leaks with LeakCanary
304(4)
Summary
308(3)
12 Trimming Down Resource Consumption with Performance Optimizations
311(18)
Achieving Flatter View Hierarchy with ConstraintLayout
312(4)
Reducing Programmatic Draws with Drawables
316(5)
Minimizing Asset Payload in Network Calls
321(1)
Bitmap Pooling and Caching
321(2)
Reducing Unnecessary Work
323(2)
Using Static Functions
325(1)
Minification and Obfuscation with R8 and ProGuard
326(1)
Summary
327(2)
Index 329
Pierre-Olivier Laurence is the Lead Software Engineer at Safran Aircraft Engines near Paris, France. He started learning Java and Linux systems over a decade ago, which quickly lead to full time Android development. A frequent collaborator on the TileView open source library since its inception, Pierre recently created a version of the library that's 100% Kotlin, leveraging the power of Kotlin coroutines for truly impressive performance gains. An early adopter of Kotlin, Pierre has maintained several open source Kotlin projects since the language was introduced in 2015. With an eye toward personal development, Pierre is an avid reader of O'Reilly books and looks forward to mastering even more technologies in the future.

Amanda Hinchman-Dominguez is a Kotlin Google Developer Expert, Android engineer at Groupon, and active in the global Kotlin community, both as a speaker and as a community organizer. Starting out in academia, she obtained a B.S. in Computer Science at Grinnell College. Working across web, mobile, and native-desktop development, her roots in metaprogramming research1 and community-based learning heavily influenced her direction in both her interests and her career. Kotlin community back in 2016 and eventually, her career. Her passion for Kotlin naturally shifted towards Android development some years in the industry.

She's given technical lectures in Kotlin internationally officially since 2017. She's written dozens more on topics ranging from metaprogramming, compilers and application development. She's participated in the TornadoFX community, and contributed to the Arrow-meta open-source project. She's also involved with the world community via conferences like KotlinConf, Chicago Roboto, Chicago Kotlin User Group, and more. Her current focus is capturing the ever-evolving history of Kotlin and Android and establishing a stronger presence of the Kotlin community.

Mike Dunn is the author of Native Mobile Development: an Android to iOS Cross Reference. He is currently the Principal Mobile Engineer at O'Reilly Media, a recognized member of the AOSP community, and a dedicated contributor to the Android open source ecosystem, including the popular tiling image library, TileView. He's contributed to Google's Closure library, and provided extensions for Google's next-gen Android media player, ExoPlayer. Mike has been programming professionally for about 15 years, and is continuing to study computer science in the master's program at the Georgia Institute of Technology.