Helion


Szczegóły ebooka

Kickstart Modern Android Development with Jetpack and Kotlin

Kickstart Modern Android Development with Jetpack and Kotlin


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.

  • Kickstart Modern Android Development with Jetpack and Kotlin
  • Contributors
  • About the author
  • About the reviewer
  • Preface
    • Who this book is for
    • What this book covers
    • To get the most out of this book
    • Download the example code files
    • Get in touch
    • Share Your Thoughts
  • 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
    • Why subscribe?
  • Other Books You May Enjoy
    • Packt is searching for authors like you
    • Share Your Thoughts