
Introduction to Kotlin and Android Development
Topics:
Table of Contents
Introduction
Introduction
Maximiliano Firtman introduces the course by providing some personal background with mobile development and discussing an overview of what material will be covered in this course. Prerequisites for this course are also provided in this segment.Android Overview
Maximiliano walks through the layers of the Android operating system and which parts will be utilized in this course. An Android application should contain an APK, a ZIP package containing compiled VM code, metadata, assets, and a signature and be installable via the Play Store or USB cable.Android Versioning & APIs
Maximiliano discusses Android version numbers, code names, and API numbers. SDK versions, including minimum SDK version, target SDK version, and compile SDK version, are also covered in this segment.Kotlin & Architecture Overview
Maximiliano discusses an overview of Kotlin being open source, statically typed, containing type inference, multi-platform, easy to learn, concise, and null-safety. Kotlin's ability to compile to JVM 6, JVM 8, Android - Java DEX, Native, and Kotlin Multiplatform Mobile is also discussed in this segment.
Basics
Kotlin Basic Expressions
Maximiliano walks through some basic expressions in Kotlin, including global expressions, variables, booleans, semicolons, printing to the console, correct casing, and conditionals. A student's question regarding using multiple cases is also covered in this segment.Variables & Types
Maximiliano demonstrates that Kotlin is a statically typed yet flexible language by walking through some variables and types, including mutable and immutable variables, constants, defining types, and core data types.Collections
Maximiliano discusses collections including mutable and immutable lists, sets, maps, and dictionaries. When talking to the Android SDK sometimes Java arrays are required.Null Safety
Maximiliano demonstrates the function of Null Safety to distinguish between references that can hold null (nullable references) and those that cannot (non-null references). Kotlin's type system is aimed at eliminating the danger of null referencesFunctions & Lambdas
Maximiliano walks through creating functions with the fun keyword, inputting arguments, extension functions, and lambda functions. Lambda expressions and anonymous functions are function literals that are not declared but passed immediately as an expression.Classes
Maximiliano demonstrates how to declare a class with the class name and the optional header and body and discusses constructors. A class in Kotlin can have a primary constructor and one or more secondary constructors.Other Data Types
Maximiliano discusses other data types including the companion objects attached to classes, sealed classes, enum classes,and data classes.Kotlin Q&A
Maximiliano answers student questions regarding SDKs compiling to Android and what the function of the triple double quotes are.
Project
Create a Project in Android Studio
Maximiliano walks through creating a new project using Android Studio, including setting up the application's app store ID. A walk-through of the application preview window is also covered in this segment.Jetpack Compose
Maximiliano discusses an overview of Jetpack Compose main concepts, including Android activity, theme, composable (UI component), modifier, composition, mutable state, and remember. This segment also briefly discusses the composition local, side effects, dimension units: dp, sp, and graphical assets: PNG and SVG concepts.Composables Layout
Maximiliano demonstrates how to create a composable to build a user interface by defining a set of composable functions that take in data and emit UI elements.Modifiers
Maximiliano demonstrates modifiers allow you to decorate or augment a composable, including changing the composable's size, layout, behavior, and appearance. Since each function makes changes to the Modifier returned by the previous function, the sequence affects the final result.TextField & Input Value
Maximiliano walks through implementing a TextField, using the remember composable to allow a user to input text. A value computed by remember is stored in the Composition during initial composition, and the stored value is returned during recomposition.
UI
Offers Page
Maximiliano walks through creating the Offers page of the application, including a shortcut to create a Composable and preview, and discusses the purpose of the andriodx imports. Editing the page's text styling and adding auto imports are also covered in this segment.UI Theming
Maximiliano demonstrates setting the Offers page styles in the theme using MaterialTheme and further styling using modifiers. Setting up custom reusable theme colors in the ui.theme/Color.kt file is also demonstrated in this segment.Adding Background Image
Maximiliano walks through creating, converting, and importing a vector background image to the Offers page. Modifying the image width and height is also covered in this segment.Preview Composable
Maximiliano demonstrates creating a private composable just for the preview to allow multiple previews to be viewed at the same time. Implementing a scrollable preview is also covered in this segment.App Title Bar
Maximiliano walks through rendering the application's title bar by downloading a vector logo and placing it in the correct content position in the Scaffold. Implementing the composables Box and TopAppBar are also covered in this segment.Bottom Bar Navigation
Maximiliano walks through creating a bottom navigation bar by creating a data class to contain the titles, images, and routes for each navigation option. Styling the alignment, image, and text of the NavBarItem is also covered in this segment.Nav Bar Buttons & State
Maximiliano demonstrates rendering each navbar item, implementing state, and updating the navigation icon colors when selected. Styling the bottom nav bar with proper padding, background color, and font is also covered in this segment.Creating Pages & Data Model
Maximiliano walks through creating and implementing navigation for each page when the corresponding icon is selected. A student's question regarding if iterables could be used is also covered in this segment.
Data
Rendering Data & Images
Maximiliano walks through creating a composable for a ProductItem and then the page with a LazyColumn. Compose provides a set of components that only compose and layout items visible in the component’s viewport. These components include LazyColumn and LazyRow.Adding Dependencies
Maximiliano demonstrates calling the web service using HTTP(s) with the RetroFit, OkHttp, and JsonConverter libraries. The AsyncImage from Coil will also be used to download images from the web.Managing Data
Maximiliano walks through creating a DataManager class that will be responsible for managing the application's data. Adding and removing products from the cart will be managed by the created class.Requesting API Data
Maximiliano demonstrates fetching and parsing the data using the previously imported libraries within composables. The DataManager is also edited to conform to an Android architectural pattern: ViewModel.Rendering Product Data
Maximiliano walks through pulling in the dynamic data to render images, names, and prices for each category of ProductItems. The previously created dataManger will pull in the usable data from the web server.
Production
Web View
Maximiliano demonstrates rendering an AndroidView to connect classic Android UI controls with a composable. Integrating an AndroidView into Jetpack can be achieved by embedding a chromium engine into the application.Bundling the App for Production
Maximiliano walks through the finishing steps, including setting the application icons and building the final app APK or bundle. A student's question regarding Android's png support is also covered in this segment.