Muutke küpsiste eelistusi

Kotlin and Android Develoment featuring Jetpack: Build Better, Safer Android Apps [Pehme köide]

  • Formaat: Paperback / softback, 400 pages
  • Ilmumisaeg: 02-Sep-2021
  • Kirjastus: The Pragmatic Programmers
  • ISBN-10: 1680508156
  • ISBN-13: 9781680508154
  • Formaat: Paperback / softback, 400 pages
  • Ilmumisaeg: 02-Sep-2021
  • Kirjastus: The Pragmatic Programmers
  • ISBN-10: 1680508156
  • ISBN-13: 9781680508154

Start building native Android apps the modern way in Kotlin with Jetpack's expansive set of tools, libraries, and best practices. Learn how to create efficient, resilient views with Fragments and share data between the views with ViewModels. Use Room to persist valuable data quickly, and avoid NullPointerExceptions and Java's verbose expressions with Kotlin. You can even handle asynchronous web service calls elegantly with Kotlin coroutines. Achieve all of this and much more while building two full-featured apps, following detailed, step-by-step instructions.With Kotlin and Jetpack, Android development is now smoother and more enjoyable than ever before. Dive right in by developing two complete Android apps.

With the first app, Penny Drop, you create a full game complete with random die rolls, customizable rules, and AI opponents. Build lightweight Fragment views with data binding, quickly and safely update data with ViewModel classes, and handle all app navigation in a single location. Use Kotlin with Android-specific Kotlin extensions to efficiently write null-safe code without all the normal boilerplate required for pre-Jetpack + Kotlin apps. Persist and retrieve data as full objects with the Room library, then display that data with ViewModels and list records in a RecyclerView.

Next, you create the official app for the Android Baseball League. It's a fake league but a real app, where you use what you learn in Penny Drop and build up from there. Navigate all over the app via a Navigation Drawer, including specific locations via Android App Links. Handle asynchronous and web service calls with Kotlin Coroutines, display that data smoothly with the Paging library, and send notifications to a user's phone from your app.

Come build Android apps the modern way with Kotlin and Jetpack!

What You Need:

You'll need the Android SDK, a text editor, and either a real Android device or emulator for testing. While not strictly required, it's assumed you're using Android Studio, which comes with the Android SDK and simplifies creating an emulator. Also, a few examples require JDK 1.8 or later, though all of these pieces can be completed in other ways when using JDK 1.6.

Acknowledgments ix
Preface xi
Introduction xlii
Part I Penny Drop
1 Initialize The Penny Drop App
3(24)
How to Play Penny Drop
3(1)
Create the App
4(8)
What Else Do We Need?
12(13)
Summary and Next Steps
25(2)
2 Build Views With Fragments
27(30)
Build a Fragment (Pick Players)
28(8)
Add Data Binding to the App
36(8)
Build Another Fragment (Game)
44(12)
Summary and Next Steps
56(1)
3 Bind Data With Viewmodels
57(34)
Create a ViewModel (Pick Players)
57(6)
Bind ViewModel to a Fragment (Pick Players)
63(6)
Add AI Spinner to Player List Items
69(3)
Customize the Player List Items
72(5)
Create Another ViewModel (Game)
77(5)
Bind ViewModel to a Fragment (Game)
82(7)
Summary and Next Steps
89(2)
4 Update Livedata With Conditional Game Logic
91(24)
Create GameHandler
92(9)
Start a Game
101(2)
More GameVlewModel Functions: roll() and pass()
103(1)
Update the UI
104(2)
Create Turn Summary Text
106(3)
Handle AI Turns with Coroutines and First-Class Functions
109(3)
Summary and Next Steps
112(3)
5 Persist Game Data With Room
115(36)
Add Room to the App
115(1)
Add a RoomDatabase Class
116(2)
Create a DAO Class
118(1)
Add Entity Classes
119(5)
Add Data During Database Creation
124(1)
Add Converters to the Database
125(3)
Create a Repository Class
128(5)
Access the Database from a ViewModel
133(16)
Update the UI Data Binding
149(1)
Summary and Next Steps
149(2)
6 Build A List With Recyclerview
151(18)
Add the RecyclerView
152(3)
Build the List Item Layout
155(5)
Create a Custom ListAdapter
160(3)
Connect Adapter to RecyclerView
163(1)
Load Data into RecyclerView from Database
164(4)
Summary and Next Steps
168(1)
7 Customize An App With Settings And Themes
169(30)
Add a New SettingsFragment
170(6)
Use Saved Preferences
176(2)
Add Themes
178(2)
Change Themes
180(3)
Add Night Mode Support
183(5)
Add an About the App Section
188(5)
Summary and Next Steps
193(6)
Part II Android Baseball League
8 Initialize The Android Baseball League App
199(16)
Welcome to the Official ABL App
199(1)
Create the App
200(5)
Configure the Activity
205(1)
Add the First Fragment
206(7)
Summary and Next Steps
213(2)
9 Navigate Via Navigation Drawer
215(20)
Add the Navigation Drawer
215(7)
Add Fragments (Standings and Single Team)
222(3)
Pass Data with Safe Args
225(5)
Navigate Directly via a Deep Link
230(4)
Summary and Next Steps
234(1)
10 Load And Save Data With Coroutines And Room
235(24)
Create a Database
235(6)
Work with Retrofit
241(4)
Load Data from External APIs
245(8)
Add a New Fragment (Scoreboard)
253(5)
Summary and Next Steps
258(1)
11 Display Data With Paging
259(24)
Add Two New Fragments (Leaders and Single Player)
260(4)
Add a New Fragment (Players)
264(2)
Handle Paging Data in the App
266(11)
Display Paging Data in a RecyclerView List
277(3)
Summary and Next Steps
280(3)
12 Personalize The Android Baseball League App
283(22)
Build a Settings Screen via Code
284(4)
Extract Colors with Palette
288(6)
Add and Group Additional Preferences
294(5)
Reliably Complete Background Work with WorkManager
299(5)
Summary and Next Steps
304(1)
13 Send Info To And From The Android Baseball League App
305(24)
Alert Users with Notifications
305(8)
Send Cloud-Based Alerts with Push Notifications
313(8)
Share Links with Android Sharesheet
321(4)
Summary and Next Steps
325(4)
Part III Test Your App
14 Unit Test Your App With Junit
329(22)
Add Unit Tests
330(6)
Test a ViewModel Class
336(6)
Test a Data Access Object (DAO)
342(6)
Summary and Next Steps
348(3)
15 Test Your App's Ui With Espresso
351(16)
Add UI Tests
351(7)
Add More UI Tests
358(5)
Summary and Next Steps
363(4)
Part IV Appendixes
A1 Install Android Studio
367(14)
Download Android Studio
367(1)
Install Android Studio
368(8)
Set Up an Android Virtual Device (AVD)
376(5)
A2 Troubleshooting Your App
381(14)
Debug Your App
382(4)
Display Messages with the Toast Class
386(5)
Log Messages to Logcat
391(3)
Wrapping Up
394(1)
A3 Gradle Dependencies
395(8)
Classpath Dependencies
395(1)
Implementation Dependencies
396(5)
KAPT Dependencies
401(1)
Test Dependencies
401(2)
Index 403
Michael Fazio is a software developer and tech speaker who fell in love with Android starting with the original Galaxy S phone. He's been the Android lead for multiple billion-dollar companies and has seen the Android development process evolve from far too many Activities and a nigh unusable emulator to the actually enjoyable dev experience of Kotlin + Jetpack.