Kotlin for Android Developers
Kotlin for Android Developers
Learn Kotlin the easy way while developing an Android App
About the Book
Google has officially announced Kotlin as a supported language to write Android Apps.
These are amazing news for Android developers, which now have the ability to use a modern and powerful language to make their job easier and funnier.
But this comes with other responsibilities. If you want to be a good candidate for new Android opportunities, Kotlin is becoming a new need most companies will ask for. So it's your time to start learning about it!
And "Kotlin for Android Developers" is the best tool. Recommended by both Google and Jetbrains, this book will guide through the process of learning all the new features that Java was missing, in an easy and fun way.
You'll be creating an Android app from ground using Kotlin as the main language. The idea is to learn the language by example, instead of following a typical structure. I'll be stopping to explain the most interesting concepts and ideas about Kotlin, comparing it with Java 7. This way, you can see what the differences are and which parts of the language will help you speed up your work.
This book is not meant to be a language reference, but a tool for Android developers to learn Kotlin and be able to continue with their own projects by themselves. I'll be solving many of the typical problems we have to face in our daily lives by making use of the language expressiveness and some other really interesting tools and libraries.
The book is very practical, so it is recommended to follow the examples and the code in front of a computer and try everything it's suggested. You could, however, take a first read to get a broad idea and then dive into practice.
As you could read in previous pages (and probably the site were you downloaded), this is a lean publication. This means that the book is written and progresses with you. I'll continually write new content and review the existing based on your comments and your suggestions. In the end, it will also be your book. I want this book to be the perfect tool for Android developers, and as such, all the help and ideas will be welcomed.
Thanks for becoming part of this exciting project.
Learn more Kotlin at: antonioleiva.com/kotlin
Reader Testimonials
Medet
This book is read in one breath. If you know the basic concept of android development and looking for the right source to enter the world of Kotlin for Android then this book is right for you. By going throughout the book, I was able to peek up basic concept of Kotlin and good coding practices. In the end, of my journey, I had been convinced that Kotlin is best for Android development.
Table of Contents
-
I. About this book
- What is “Kotlin for Android Developers” about
- II. Is this book for you?
- III. About the author
-
1 Introduction
- 1.1 What is Kotlin?
- 1.2 What do we get with Kotlin?
-
2 Getting ready
- 2.1 Android Studio
- 2.2 Install Kotlin plugin
-
3 Creating a new project
- 3.1 Create a new project in Android Studio
- 3.2 Convert MainActivity to Kotlin code
- 3.3 Configure Kotlin in project
- 3.4 Include some other useful configuration
- 3.5 Test that everything works
-
4 Classes and functions
- 4.1 How to declare a class
- 4.2 Class inheritance
- 4.3 Functions
- 4.4 Constructor and functions parameters
-
5 Writing your first class
- 5.1 Creating the layout
- 5.2 The Recycler Adapter
-
6 Variables and properties
- 6.1 Basic types
- 6.2 Variables
- 6.3 Properties
-
7 Anko and Extension Functions
- 7.1 What is Anko?
- 7.2 Start using Anko
- 7.3 Extension functions
-
8 Retrieving data from API
- 8.1 Performing a request
- 8.2 Performing the request out of the main thread
-
9 Data Classes
- 9.1 Extra functions
- 9.2 Copying a data class
- 9.3 Mapping an object into variables
-
10 Parsing data
- 10.1 Converting JSON to data classes
- 10.2 Shaping the domain layer
- 10.3 Drawing the data in the UI
-
11 Operator overloading
- 11.1 Operators tables
- 11.2 An example
- 11.3 Operators in extension functions
- 12 Making the forecast list clickable
-
13 Lambdas
- 13.1 Simplifying setOnClickListener()
- 13.2 Click listener for ForecastListAdapter
- 13.3 Extending the language
-
14 Visibility Modifiers
- 14.1 Modifiers
- 14.2 Constructors
- 14.3 Reviewing our code
-
15 Kotlin Android Extensions
- 15.1 How to use Kotlin Android Extensions
- 15.2 Kotlin Android Extensions in 1.1.4
- 15.3 Refactoring our code
-
16 Application Singleton and Delegated Properties
- 16.1 Application Singleton
- 16.2 Delegated Properties
- 16.3 Standard Delegates
- 16.4 How to create a custom delegate
- 16.5 Reimplementing the App Singleton
-
17 Creating an SQLiteOpenHelper
- 17.1 ManagedSqliteOpenHelper
- 17.2 Tables definition
- 17.3 Implementing SqliteOpenHelper
- 17.4 Dependency injection
-
18 Collections and functional operations
- 18.1 Aggregate operations
- 18.2 Filtering operations
- 18.3 Mapping operations
- 18.4 Elements operations
- 18.5 Generation operations
- 18.6 Ordering operations
-
19 Saving and requesting data from the database
- 19.1 Creating database model classes
- 19.2 Writing and requesting data
-
20 Null safety in Kotlin
- 20.1 How Null types work
- 20.2 Nullity and Java libraries
- 21 Creating the business logic to data access
-
22. Flow control and ranges
- 22.1 If Expression
- 22.2 When expression
- 22.3 For loops
- 22.4 While and do/while loops
- 22.5 Ranges
-
23 Creating a Detail Activity
- 23.1 Preparing the request
- 23.2 Providing a new activity
- 23.3 Start an activity: reified functions
-
24 Interfaces and Delegation
- 24.1 Interfaces
- 24.2 Delegation
- 24.3 Implementing an example in our App
-
25 Generics
- 25.1 Basics
- 25.2 Variance
- 25.3 Generics examples
-
26 Settings Screen
- 26.1 Creating the settings activity
- 26.2 Accessing Shared Preferences
- 26.3 Generic preference delegate
-
27 Coroutines since Kotlin 1.3
- 27.1 Coroutines goal: The problem
- 27.2 What are coroutines?
- 27.3 Using coroutines in our example
-
28 Testing your App
- 28.1 Unit testing
- 28.2 Mocking closed classes
- 28.3 Instrumentation tests
-
29 Extra concepts
- 29.1 Nested classes
- 29.2 Enum classes
- 29.3 Sealed classes
- 29.4 Exceptions
-
30 Java interoperability
- 30.1 Package-level functions
- 30.2 Extension functions
- 30.3 Function overloads
- 30.4 Instance and static fields
- 30.5 Data classes
- 30.6 Sealed classes
- 30.7 Inline functions and reified types
- 31 Conclusion
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them