Kotlin Programming By Example
Copyright 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Aaron Lazar
Acquisition Editor: Denim Pinto
Content Development Editor: Vikas Tiwari
Technical Editor: Subhalaxmi Nadar
Copy Editor: Safis Editing
Project Coordinator: Ulhas Kambali
Proofreader: Safis Editing
Indexer: Mariammal Chettiyar
Graphics: Tania Dutta
Production Coordinator: Aparna Bhagat
First published: March 2018
Production reference: 1270318
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78847-454-2
www.packtpub.com
To my mother and father for their unwavering belief in me and for the unparalleled love they have shown toward me; words cannot describe how grateful I am to you
mapt.io
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details.
At www.PacktPub.com , you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Contributors
About the author
Iyanu Adelekan is a software engineer who enjoys solving problems in the web and Android application domains. He loves working on open source projects and is the author and lead maintainer of Kanary, a Kotlin web framework for building RESTful application programming interfaces. In addition to building software, he is passionate about knowledge sharing and algorithms. He enjoys reading sci-fi and playing chess in his spare time.
I am thankful to God for giving me the strength required to embark on and successfully complete this book.
Gratitude also go out to my siblings, parents, and friends for their love and support over the course of writing this title. May God bless you all.
About the reviewer
Egor Andreevici has been building Android apps since 2010 and has recently moved to Canada to join Square as an Android Developer. He is passionate about technology, clean code, test-driven development, and software architecture. He discovered Kotlin a couple of years ago and has fallen in love with conciseness and expressiveness of the language ever since. In his free time, he likes to contribute to open source, read, and travel.
Packt is searching for authors like you
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Preface
Since its announcement as an officially supported language for Android, Kotlin has experienced a huge rise in popularity. This proliferation in popularity is in many ways warranted as Kotlin is a modern and extremely well-designed language, which has many domains of applicationweb, mobile, and native to name a few. As a direct consequence of its rise in popularity, Kotlin has experienced steady growth over the years.
Who this book is for
This book will be useful to readers of all ages, experience levels, and demographics. That being said, it was written primarily with beginners and experienced programmers who want to learn Kotlin in mind.
Over the course of writing this book, I paid special attention to the fact that beginners will need to be eased into topics and concepts. As such, the chapters of this book were written in ascending order of difficulty. If you are a beginner, this will enable you to learn as quickly as possible with as few hiccups as possible.
Fairly experienced readers are expected to move more quickly through this book than beginnersall things being equal. If you have prior experience of programming and application development, you may choose to first run through the code examples of this book to get a good feel for the topics covered and what to expect. Java developers in particular may be able to get away with diving right into the more advanced chapters of the book.
Regardless of which category of user you fall into, rest assured that there is something that has been written specially for you!
What this book covers
, The Fundamentals, explains how to use Kotlin to write simple programs, how to set up a new Android project, and the fundamental knowledge required to develop Android applications that communicate with web servers.
, Building an Android Application - Tetris, gets you off to a quick start with Android development by walking you through the creation of the classic game, Tetris.
, Implementing Tetris Logic and Functionality, explains how to create views, implement application logic with models, and present data to views. In addition, you will learn about UI event handling.