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
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.
I. About this book
- What is “Kotlin for Android Developers” about
- II. Is this book for you?
- III. About the author
- 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.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.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 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
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), EPUB (for phones and tablets) and MOBI (for 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.
C++ Best PracticesJason Turner
Level up your C++, get the tools working for you, eliminate common problems, and move on to more exciting things!
Functional Design and ArchitectureAlexander Granin
Software Design in Functional Programming, Design Patterns and Practices, Methodologies and Application Architectures. How to build real software in Haskell with less efforts and low risks. The first complete source of knowledge.
OpenIntro StatisticsDavid Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntro
A complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
R Programming for Data ScienceRoger D. Peng
This book brings the fundamentals of R programming to you, using the same material developed as part of the industry-leading Johns Hopkins Data Science Specialization. The skills taught in this book will lay the foundation for you to begin your journey learning data science. Printed copies of this book are available through Lulu.
C++20 is the next big C++ standard after C++11. As C++11 did it, C++20 changes the way we program modern C++. This change is, in particular, due to the big four of C++20: ranges, coroutines, concepts, and modules.
I am a Software Engineer and I am in ChargeAlexis Monville and Michael Doyle
I am a Software Engineer and I am in Charge is a real-world, practical book that helps you increase your impact and satisfaction at work no matter who you work with.
In the book, we will follow Sandrine, a fictional character who learns to think in a new way enabling her to take a different course of action.
Invest In Digital Health - The Medical Futurist's GuideDr. Bertalan Mesko
Artificial Intelligence and Digital Health are booming. In this book, we explain why now it's a good time to invest in Digital Health and give recommendations on where to invest by looking at the top 24 technological trends we find the most promising.
Atomic KotlinBruce Eckel and Svetlana Isakova
For both beginning and experienced programmers! From the author of the multi-award-winning Thinking in C++ and Thinking in Java together with a member of the Kotlin language team comes a book that breaks the concepts into small, easy-to-digest "atoms," along with exercises supported by hints and solutions directly inside IntelliJ IDEA!
The Hundred-Page Machine Learning BookAndriy Burkov
Everything you really need to know in Machine Learning in a hundred pages.
Mastering STM32Carmine Noviello
With more than 600 microcontrollers, STM32 is probably the most complete ARM Cortex-M platform on the market. This book aims to be the first guide around that introduces the reader to this exciting MCU portfolio from ST Microelectronics and its official CubeHAL.
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
2 Books"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before...
The Future of Digital Health
6 BooksWe put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy and how technology giants such as Amazon or Google want to conquer...
Cisco CCNA 200-301 Complet
4 BooksCe lot comprend les quatre volumes du guide préparation à l'examen de certification Cisco CCNA 200-301.
CCDE Practical Studies (All labs)
3 BooksCCDE lab
"The C++ Standard Library" and "Concurrency with Modern C++"
2 BooksGet my books "The C++ Standard Library" and "Concurrency with Modern C++" in a bundle. The first book gives you the details you should know about the C++ standard library; the second one dives deeper into concurrency with modern C++. In sum, you get more than 600 pages full of modern C++ and about 250 source files presenting the standard library...
Modern Management Made Easy
3 BooksRead all three Modern Management Made Easy books. Learn to manage yourself, lead and serve others, and lead the organization.
Programming with Ease
3 BooksAlle drei Bände der Serie Programming with Ease in einem Paket. Darin findest du alles, was ich dir zu den wichtigsten Phasen der Softwareentwicklung im Hinblick auf Clean Code Development für langfristig hohe Produktivität sagen kann.Im Band Slicing findest du die Anforderungsanalyse im Rahmen eines iterativ-inkrementellen Vorgehensmodells aus...
2 BooksUnveil the power of Ansible and Vagrant with this bundle at a special price. You'll have everything you need to get started with Vagrant - learn the basics and how to create your virtual development environments, using Ansible as provisioner! About Vagrant Cookbook Vagrant Cookbook is a complete guide to get started with Vagrant and create your...
2 BooksDocker and Kubernetes are taking the world by storm! These books will get you up-to-speed fast! Docker Deep Dive is over 400 pages long, and covers all objectives on the Docker Certified Associate exam.The Kubernetes Book includes everything you need to get up and running with Kubernetes!
Growing Agile: The Complete Coach's Guide
7 BooksGrowing Agile: Coach's Guide Series This bundle provides a collection of training and workshop plans for a variety of agile topics. The series is aimed at agile coaches, trainers and ScrumMasters who often find themselves needing to help teams understand agile concepts. Each book in the series provides the plans, slides, handouts and activity...