Kotlin for Android App Development
The book is divided into two parts: first, you dive deep into the Kotlin language itself, and then build two sample apps using purely Kotlin.
- Chapter 1 gives a brief overview of Kotlin, its underlying principles and goals, and why it is such an important and popular language.
- Chapter 2 then teaches you the basic language constructs of Kotlin, all the way from variables and control flow to exception handling.
- In Chapter 3, you dive into functional programming in Kotlin, covering things like higher-order functions, lambda expressions and lazy evaluation. [This is a sample chapter that you can download from KotlinAndroidBook.com]
- Chapter 4 covers object-orientation in Kotlin, from classes with properties and methods to interesting features like sealed or data classes, declaration-site variance and smart-casts.
- Chapter 5 then discusses interoperability with Java, highlighting possible issues, how to work around them, and best practices for mixed-language projects. [This is another sample chapter that you can download from KotlinAndroidBook.com].
- Chapter 6 covers concurrency in Kotlin, from traditional concurrency challenges to Kotlin's approach to concurrency with coroutines, suspending functions, actors and channels.
- In Chapter 7, you put all of Part 1 into practice by building your first Kotlin Android app, a simple to-do list app that already covers things like
RecyclerView, the Kotlin Android Extensions, and Android Architecture Components.
- Chapter 8 goes a step further with a second, more fleshed-out Android that shows the user nutrition data from the US Department of Agriculture. Here, you'll learn how to use Retrofit, Moshi, JSON mapping, Android fragments and more with Kotlin, plus you'll recap the tools and technologies used in Chapter 7.
- Chapter 9 then covers how to easily write simple domain-specific languages (DSLs) with Kotlin that can, for instance, facilitate object creation or configuration. It also covers the two most popular Kotlin DSLs: Anko for Android layouts and the Gradle Kotlin DSL for build config.
- Chapter 10 wraps up the book by discussing adoption of Kotlin in a company, covering pitfalls along with tips and practices used by companies to successfully adopt Kotlin.
Code for Android Apps
To find the code for the two Android apps developed in the book, please check out their respective repositories:
- Kudoo app: https://github.com/petersommerhoff/kudoo-app
- Nutrilicious app: https://github.com/petersommerhoff/nutrilicious-app