Kickstart Modern Android Development with Jetpack and Kotlin - Catalin Ghita - E-Book

Kickstart Modern Android Development with Jetpack and Kotlin E-Book

Catalin Ghita

0,0
33,59 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

With Jetpack libraries, you can build and design high-quality, robust Android apps that have an improved architecture and work consistently across different versions and devices. This book will help you understand how Jetpack allows developers to follow best practices and architectural patterns when building Android apps while also eliminating boilerplate code.
Developers working with Android and Kotlin will be able to put their knowledge to work with this condensed practical guide to building apps with the most popular Jetpack libraries, including Jetpack Compose, ViewModel, Hilt, Room, Paging, Lifecycle, and Navigation. You'll get to grips with relevant libraries and architectural patterns, including popular libraries in the Android ecosystem such as Retrofit, Coroutines, and Flow while building modern applications with real-world data.
By the end of this Android app development book, you'll have learned how to leverage Jetpack libraries and your knowledge of architectural concepts for building, designing, and testing robust Android applications for various use cases.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 512

Veröffentlichungsjahr: 2022

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Kickstart Modern Android Development with Jetpack and Kotlin

Enhance your applications by integrating Jetpack and applying modern app architectural concepts

Catalin Ghita

BIRMINGHAM—MUMBAI

Kickstart Modern Android Development with Jetpack and Kotlin

Copyright © 2022 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.

Group Product Manager: Rohit Rajkumar

Publishing Product Manager: Vaideeshwari Muralikrishnan

Senior Editor: Hayden Edwards

Content Development Editor: Abhishek Jadhav

Technical Editor: Simran Udasi

Copy Editor: Safis Editing

Project Coordinator: Rashika Ba

Proofreader: Safis Editing

Indexer: Rakha Nair

Production Designer: Shankar Kalbhor

Marketing Coordinator: Elizabeth Varghese and Teny Thomas

First published: May 2022

Production reference: 1200522

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham

B3 2PB, UK.

ISBN 978-1-80181-107-1

www.packt.com

To my mother, Stefania Ghita, and my father, Nicolae, for their sacrifices made to support, encourage, and allow me to become what I am today – your affection and inspiration will always remain in my heart.

To my beloved wife, Ana, for being there for me mentally, spiritually, and emotionally – I'm surprised you haven't broken up with me after all the time I spent on this book.

To my great friend, Daniel Bälz, for constantly helping me review, arrange, and improve the contents of this book – your help should be engraved in stone.

To my devoted counselor, Thomas Künneth, for consistently providing insights and tips on technical writing and the concepts presented in the book.

Finally, to the awesome team at Packt, for making my dream of writing a book become reality.

– Catalin Ghita

Contributors

About the author

Catalin Ghita is a Udemy instructor and an Android engineer proficient in native Android development, while also being active in cross-platform development with React Native and Flutter. He has successfully built, deployed, and maintained huge scalable apps with millions of downloads and active users for industry giants. He is responsible for architecting applications into scalable, maintainable, and testable forms and shapes.

As the Android lead at Airtouch New Media, the owner of the Coding Troops blog, and a Udemy instructor, Catalin is an avid open source contributor and has written articles and taught courses reaching tens of thousands of students, thereby exposing and clarifying concepts and subtleties on hot topics in Android.

About the reviewer

Daniel Bälz is a keen Android developer who enjoys developing maintainable, high-quality apps with well-structured architecture. He works as a freelance developer and helps his customers in building and evolving their Android apps. His personal Android journey dates back to the Android 2.x days. Since then, he has worked on several large-scale apps with millions of installations. Daniel is active in the community by organizing the mobile development meetup in his hometown, Karlsruhe, as well as occasionally giving talks and writing articles.

Table of Contents

Preface

Part 1: Exploring the Core Jetpack Suite and Other Libraries

Chapter 1: Creating a Modern UI with Jetpack Compose

Technical requirements

Understanding the core concepts of Compose

Describing UIs with composable functions

The paradigm shift in creating UIs on Android

Favoring composition over inheritance

Unidirectional flow of data

Recomposition

Exploring the building blocks of Compose UIs

Setting content and previewing composables

Exploring core composables

Customizing composables with modifiers

Layouts in Compose

Building a Compose-based screen

Creating your first Compose project

Building a restaurant element layout

Displaying a list of restaurants with Compose

Exploring lists with Compose

Adding scrolling to the Column composable

Introducing lazy composables

Using LazyColumn to display restaurants

Summary

Further reading

Chapter 2: Handling UI State with Jetpack ViewModel

Technical requirements

Understanding the Jetpack ViewModel

What is a ViewModel?

Why do you need ViewModels?

Introducing Android Jetpack ViewModel

Implementing your first ViewModel

Defining and handling state with Compose

Understanding state and events

Adding state to our Restaurants app

Hoisting state in Compose

Recovering from system-initiated process death

Summary

Further reading

Exploring ViewModel with runtime-provided arguments

Exploring ViewModel for Kotlin Multiplatform projects

Understanding how to minimize the number of recompositions

Chapter 3: Displaying Data from REST APIs with Retrofit

Technical requirements

Understanding how apps communicate with remote servers

Creating and populating your database with Firebase

Exploring Retrofit as an HTTP networking client for Android

Using Retrofit

Adding Retrofit to the Restaurants application

Mapping JSON to model classes

Executing GET requests to the Firebase REST API

Improving the way our app handles network requests

Summary

Further reading

Chapter 4: Handling Async Operations with Coroutines

Technical requirements

Introducing Kotlin coroutines

What is a coroutine?

The features and advantages of coroutines

How do coroutines work?

Exploring the basic elements of coroutines

Creating suspending functions

Launching coroutines

Using coroutines for async work

Implementing coroutines instead of callbacks

Improving the way our app works with coroutines

Summary

Further reading

Chapter 5: Adding Navigation in Compose With Jetpack Navigation

Technical requirements

Introducing the Jetpack Navigation component

Creating a new Compose-based screen

Defining the HTTP request for the contents of a restaurant

Getting the contents of a specific restaurant

Building the restaurant details screen

Implementing navigation with Jetpack Navigation

Adding support for deep links

Summary

Part 2: A Guide to Clean Application Architecture with Jetpack Libraries

Chapter 6: Adding Offline Capabilities with Jetpack Room

Technical requirements

Introducing Jetpack Room

Exploring the caching mechanism on Android

Introducing Jetpack Room as a solution for local caching

Enabling offline usage by implementing Room

Applying partial updates to the Room database

Making local data the single source of truth for app content

Refactoring the Restaurants app to have a single source of truth for data

Removing the logic of persisting state in the case of process recreation

Summary

Chapter 7: Introducing Presentation Patterns in Android

Technical requirements

Introducing MVC, MVP, and MVVM as presentation patterns

MVC

MVP

MVVM

Refactoring our Restaurants app to fit a presentation pattern

Adding more functionality inside our Restaurants app

Refactoring our Restaurants app to MVVM

Improving state encapsulation in ViewModel

Summary

Chapter 8: Getting Started with Clean Architecture in Android

Technical requirements

Defining the Domain layer with Use Cases

Separating the Domain model from Data models

Creating a package structure

Decoupling the Compose-based UI layer from ViewModel

Summary

Further reading

Chapter 9: Implementing Dependency Injection with Jetpack Hilt

Technical requirements

What is DI?

Why is DI needed?

Write less boilerplate code

Write testable classes

Implementing DI with Hilt

Understanding the basics of Dagger Hilt

Setting up Hilt

Using Hilt for DI

Summary

Further reading

Chapter 10: Test Your App with UI and Unit Tests

Technical requirements

Exploring the fundamentals of testing

Understanding the benefits of testing

Exploring types of tests

Learning the basics of testing your Compose UI

Covering the basics of unit-testing your core logic

Testing the functionality of a ViewModel class

Testing the functionality of a UseCase class

Summary

Further reading

Part 3: Diving into Other Jetpack Libraries

Chapter 11: Creating Infinite Lists with Jetpack Paging and Kotlin Flow

Technical requirements

Why do we need pagination?

Importing and exploring the Repositories App

Using Kotlin Flow to handle streams of data

Exploring pagination with Jetpack Paging

Implementing pagination with Jetpack Paging

Implementing loading and error states plus retry functionality

Summary

Further reading

Chapter 12: Exploring the Jetpack Lifecycle Components

Technical requirements

Introducing the Jetpack Lifecycle components

ViewModel

LiveData

Adding a countdown component in the Repositories app

Creating your own lifecycle-aware component

Making our countdown component aware of the lifecycle of composables

Summary

Further reading

Other Books You May Enjoy

Part 1: Exploring the Core Jetpack Suite and Other Libraries

In this part, we will build a modern and robust Android app with the help of Jetpack libraries such as Compose, ViewModel, and Navigation, as well as other popular libraries, including Coroutines and Retrofit.

This section comprises the following chapters:

Chapter 1, Creating a Modern UI with Jetpack ComposeChapter 2, Handling UI State with Jetpack ViewModelChapter 3, Displaying Data from REST APIs with RetrofitChapter 4, Handling Async Operations with CoroutinesChapter 5, Adding Navigation in Compose with Jetpack Navigation