Programming Android with Kotlin : achieving structured concurrency with coroutines 🔍
Pierre-Olivier Laurence, Amanda Hinchman-Dominguez, G. Blake Meike, Mike Dunn O'Reilly Media, Incorporated, 1, FR, 2022
英语 [en] · PDF · 4.4MB · 2022 · 📘 非小说类图书 · 🚀/lgli/lgrs/nexusstc/zlib · Save
描述
Developing applications for the Android mobile operating system can seem daunting, particularly if it requires learning a new programming language: Kotlin, now Androidâ??s officialdevelopment 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
备用文件名
lgli/P. Laurence, A. Hinchman-Dominguez, G. Meike, M. Dunn - Programming Android with Kotlin. Achieving Structured Concurrency with Coroutines (2022)[EN].pdf
备用文件名
lgrsnf/P. Laurence, A. Hinchman-Dominguez, G. Meike, M. Dunn - Programming Android with Kotlin. Achieving Structured Concurrency with Coroutines (2022)[EN].pdf
备用文件名
zlib/Computers/Programming/Pierre-Olivier Laurence, Amanda Hinchman-Dominguez, G. Blake Meike, Mike Dunn/Programming Android with Kotlin: Achieving Structured Concurrency with Coroutines_21026928.pdf
备选作者
Laurence, Pierre-Olivier, Hinchman-Dominguez, Amanda, Meike, G. Blake, Dunn, Mike
备选作者
Pierre-Olivier Laurence; Amanda Hinchman-Dominguez; Mike Dunn; G. Meike
备用版本
First edition, Beijing ; Boston ; Farnham ; Sebastopol ; Tokyo, 2021
备用版本
United States, United States of America
备用版本
First edition, Sebastopol, CA, 2021
备用版本
1, 2021
元数据中的注释
{"edition":"1","isbns":["1492063002","9781492063001"],"last_page":355,"publisher":"O'Reilly Media"}
备用描述
Copyright
Table of Contents
Preface
Who Should Read This Book
Why We Wrote This Book
Navigating This Book
Conventions Used in This Book
Using Code Examples
O’Reilly Online Learning
How to Contact Us
Acknowledgments
Chapter 1. Kotlin Essentials
The Kotlin Type System
Primitive Types
Null Safety
The Unit Type
Function Types
Generics
Variables and Functions
Variables
Lambdas
Extension Functions
Classes
Class Initialization
Properties
lateinit Properties
Lazy Properties
Delegates
Companion Objects
Data Classes
Enum Classes
Sealed Classes
Visibility Modifiers
Summary
Chapter 2. The Kotlin Collections Framework
Collection Basics
Java Interoperability
Mutability
Overloaded Operators
Creating Containers
Functional Programming
Functional Versus Procedural: A Simple Example
Functional Android
Kotlin Transformation Functions
The Boolean Functions
Filter Functions
Map
flatMap
Grouping
Iterators Versus Sequences
An Example
The Problem
The Implementation
Summary
Chapter 3. Android Fundamentals
The Android Stack
Hardware
Kernel
System Services
Android Runtime Environment
Applications
The Android Application Environment
Intents and Intent Filters
Context
Android Application Components: The Building Blocks
The Activity and Its Friends
Services
Content Providers
Broadcast Receivers
Android Application Architectures
MVC: The Foundation
Widgets
The Local Model
Android Patterns
Model–View–Intent
Model–View–Presenter
Model–View–ViewModel
Summary
Chapter 4. Concurrency in Android
Thread Safety
Atomicity
Visibility
The Android Threading Model
Dropped Frames
Memory Leaks
Tools for Managing Threads
Looper/Handler
Executors and ExecutorServices
Tools for Managing Jobs
JobScheduler
WorkManager
Summary
Chapter 5. Thread Safety
An Example of a Thread Issue
Invariants
Mutexes
Thread-Safe Collections
Thread Confinement
Thread Contention
Blocking Call Versus Nonblocking Call
Work Queues
Back Pressure
Summary
Chapter 6. Handling Concurrency Using Callbacks
Example-of-Purchase Feature
Creating the App
View-Model
View
Implement the Logic
Discussion
Limitations of the Threading Model
Summary
Chapter 7. Coroutines Concepts
What Exactly Is a Coroutine?
Your First Coroutine
The async Coroutine Builder
A Quick Detour About Structured Concurrency
The Parent-Child Relationship in Structured Concurrency
CoroutineScope and CoroutineContext
Suspending Functions
Suspending Functions Under the Hood
Using Coroutines and Suspending Functions: A Practical Example
Don’t Be Mistaken About the suspend Modifier
Summary
Chapter 8. Structured Concurrency with Coroutines
Suspending Functions
Set the Scene
Traditional Approach Using java.util.concurrent.ExecutorService
A Reminder About HandlerThread
Using Suspending Functions and Coroutines
Summary of Suspending Functions Versus Traditional Threading
Cancellation
Coroutine Lifecycle
Cancelling a Coroutine
Cancelling a Task Delegated to a Third-Party Library
Coroutines That Are Cooperative with Cancellation
delay Is Cancellable
Handling Cancellation
Causes of Cancellation
Supervision
supervisorScope Builder
Parallel Decomposition
Automatic Cancellation
Exception Handling
Unhandled Versus Exposed Exceptions
Exposed Exceptions
Unhandled Exceptions
Summary
Closing Thoughts
Chapter 9. Channels
Channels Overview
Rendezvous Channel
Unlimited Channel
Conflated Channel
Buffered Channel
Channel Producers
Communicating Sequential Processes
Model and Architecture
A First Implementation
The select Expression
Putting It All Together
Fan-Out and Fan-In
Performance Test
Back Pressure
Similarities with the Actor Model
Execution Is Sequential Inside a Process
Final Thoughts
Deadlock in CSP
TL;DR
Limitations of Channels
Channels Are Hot
Summary
Chapter 10. Flows
An Introduction to Flows
A More Realistic Example
Operators
Terminal Operators
Examples of Cold Flow Usage
Use Case #1: Interface with a Callback-Based API
Use Case #2: Concurrently Transform a Stream of Values
What Happens in Case of Error?
Final Thoughts
Use Case #3: Create a Custom Operator
Usage
Error Handling
The try/catch Block
Separation of Concern Is Important
Exception Transparency Violation
The catch Operator
Materialize Your Exceptions
Hot Flows with SharedFlow
Create a SharedFlow
Register a Subscriber
Send Values to the SharedFlow
Using SharedFlow to Stream Data
Using SharedFlow as an Event Bus
StateFlow: A Specialized SharedFlow
An Example of StateFlow Usage
Summary
Chapter 11. Performance Considerations with Android Profiling Tools
Android Profiler
Network Profiler
CPU Profiler
Energy Profiler
Memory Profiler
Detecting Memory Leaks with LeakCanary
Summary
Chapter 12. Trimming Down Resource Consumption with Performance Optimizations
Achieving Flatter View Hierarchy with ConstraintLayout
Reducing Programmatic Draws with Drawables
Minimizing Asset Payload in Network Calls
Bitmap Pooling and Caching
Reducing Unnecessary Work
Using Static Functions
Minification and Obfuscation with R8 and ProGuard
Summary
Index
About the Authors
Colophon
备用描述
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
备用描述
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 Kitlin 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
开源日期
2022-03-17
更多信息……
We strongly recommend that you support the author by buying or donating on their personal website, or borrowing in your local library.

🚀 快速下载

成为会员以支持书籍、论文等的长期保存。为了感谢您对我们的支持,您将获得高速下载权益。❤️
如果您本月捐款,您将获得额外1个月适用于3个月以上的会员订阅。 每个账户最多获得1个额外月份。

🐢 低速下载

由可信的合作方提供。 更多信息请参见常见问题解答。 (可能需要验证浏览器——无限次下载!)

所有选项下载的文件都相同,应该可以安全使用。即使这样,从互联网下载文件时始终要小心。例如,确保您的设备更新及时。
  • 对于大文件,我们建议使用下载管理器以防止中断。
    推荐的下载管理器:Motrix
  • 您将需要一个电子书或 PDF 阅读器来打开文件,具体取决于文件格式。
    推荐的电子书阅读器:Anna的档案在线查看器ReadEraCalibre
  • 使用在线工具进行格式转换。
    推荐的转换工具:CloudConvertPrintFriendly
  • 您可以将 PDF 和 EPUB 文件发送到您的 Kindle 或 Kobo 电子阅读器。
    推荐的工具:亚马逊的“发送到 Kindle”djazz 的“发送到 Kobo/Kindle”
  • 支持作者和图书馆
    ✍️ 如果您喜欢这个并且能够负担得起,请考虑购买原版,或直接支持作者。
    📚 如果您当地的图书馆有这本书,请考虑在那里免费借阅。