Elements of Android Jetpack 0.3 - 2019
Book information
Description
Table of Contents......Page 4 About the Updates......Page 10 Warescription......Page 11 Book Bug Bounty......Page 12 Creative Commons and the Four-to-Free (42F) Guarantee......Page 13 Acknowledgments......Page 14 A Development Machine......Page 16 Java......Page 17 Groovy and Gradle......Page 18 Emulators......Page 19 “Hello, World!”, Front to Back......Page 20 Deeper Dives......Page 21 But First, Some Notes About Android’s Emulator......Page 22 Step #1: Install Android Studio......Page 23 Step #2: Running Android Studio for the First Time......Page 25 Step #1: Importing the Project......Page 34 Step #2: Get Ready for the x86 Emulator......Page 35 Step #3: Set Up the AVD......Page 36 Step #4: Set Up the Device......Page 41 macOS and Linux......Page 46 Step #5: Running the Project......Page 47 Taking a Tour of Android Studio......Page 50 The Project Tree......Page 51 The Editing Pane......Page 54 The Docked Views......Page 55 Popular Menu and Toolbar Options......Page 56 Instant Run......Page 57 Open Project/Open Recent......Page 58 SDK Manager......Page 59 Settings......Page 61 Android Studio and Release Channels......Page 64 The Top Level......Page 68 The Project Contents......Page 69 The App Module Contents......Page 70 The Generated Source Sets......Page 71 main/......Page 73 test/......Page 74 The Role of the Activity......Page 75 Java......Page 76 AppCompatActivity......Page 77 setContentView()......Page 78 External Libraries......Page 79 Scratches and Consoles......Page 80 Exploring Your Resources......Page 82 OS Versions and API Levels......Page 83 Layouts......Page 86 Drawables and Mipmaps......Page 87 Strings......Page 88 Colors......Page 89 Styles......Page 90 About That R Thingy......Page 92 The Root Element......Page 94 The Application Element......Page 95 The Activity Element (And Its Children)......Page 96 What is Gradle?......Page 98 Obtaining Gradle......Page 99 The gradlew Wrapper......Page 100 The Project-Level File......Page 101 buildscript......Page 103 The Module-Level Gradle File......Page 104 Android Plugin for Gradle Configuration......Page 106 compileSdkVersion, minSdkVersion, and targetSdkVersion......Page 107 Version Code and Version Name......Page 108 Libraries and Dependencies......Page 109 APKs......Page 112 What We Run......Page 113 Where They Go......Page 115 Building the APK......Page 116 Analyzing the APK......Page 117 Where They Run......Page 120 What the Starter Project Has......Page 121 The androidTest Source Set......Page 122 The Test Class......Page 123 The Annotations......Page 124 The Test Code......Page 125 How You Run Them......Page 126 What the Test Results Look Like......Page 127 About That testInstrumentationRunner......Page 128 The androidTestImplementation Dependencies......Page 129 Where They Run......Page 130 What the Starter Project Has......Page 131 The test Source Set......Page 132 The Annotations and the Test Code......Page 133 How You Run Them......Page 134 The testInstrumentation Dependencies......Page 135 Um, OK, So, What’s the Point?......Page 136 Fragment......Page 137 Data Binding......Page 138 Lifecycles, ViewModel, and LiveData......Page 139 Room......Page 140 Android KTX......Page 141 What Came Before: the Android Support Library......Page 142 The Projects......Page 144 Direct From Android Studio......Page 145 Import......Page 148 Running the Samples......Page 149 Widgets......Page 150 Attributes......Page 152 Size, Margins, and Padding......Page 153 Hey, What Are Those @dimen Things?......Page 154 Introducing the Graphical Layout Editor......Page 156 Palette......Page 157 Preview......Page 158 Upper Left Toolbar......Page 159 Component Tree......Page 160 Attributes......Page 161 Text Tab......Page 163 TextView: Assigning Labels......Page 164 A Sample TextView......Page 165 Editing the Text......Page 166 Notable TextView Attributes......Page 169 Hey, What Is That tools: Thing?......Page 171 Android Studio Graphical Layout Editor......Page 172 The Classic Way......Page 173 The Kotlin Improvements......Page 176 The Curious Case of the Missing R......Page 178 When R Is Not Created......Page 179 Package Names......Page 180 Debugging Your App......Page 182 Get Thee To a Stack Trace......Page 183 Running Your App in the Debugger......Page 186 Setting Breakpoints......Page 188 Launching the Debugger......Page 189 Examining Objects......Page 190 Stepping Through the Code......Page 191 So, Where Did We Go Wrong?......Page 192 Introducing ConstraintLayout......Page 194 The Role of Containers......Page 195 Layouts and Adapter-Based Containers......Page 196 Performance......Page 197 Using Widgets and Containers from Libraries......Page 198 app: Attributes......Page 199 A Quick RTL Refresher......Page 200 The XML......Page 201 The Android Studio Graphical Layout Editor......Page 203 The Result......Page 204 Starting from Scratch......Page 205 ConstraintLayout and the Attributes Pane......Page 207 Graphical Layout Editor......Page 208 More Complex Forms......Page 209 What We Want......Page 210 How We Get There......Page 211 Barrier: You Shall Not Pass......Page 213 Your Position Shows Some Bias......Page 214 Declaring the Rows......Page 215 Turning Back to RTL......Page 216 More Fun with ConstraintLayout......Page 217 RelativeLayout......Page 218 TableLayout......Page 219 FrameLayout......Page 220 ImageView and ImageButton......Page 222 Android Studio Graphical Layout Editor......Page 225 Switch......Page 227 Android Studio Graphical Layout Editor......Page 230 Hey, You Have a Typo in android:id!......Page 231 CheckBox......Page 232 Android Studio Graphical Layout Editor......Page 234 RadioButton and RadioGroup......Page 235 Reacting to Events......Page 238 SeekBar......Page 240 Reacting to Events......Page 242 ScrollView: Making It All Fit......Page 243 android:gravity......Page 246 log()......Page 248 It’s Not an OMG Object, But It’s Close......Page 254 Application......Page 255 Instrumented Tests......Page 256 Key Context Features......Page 257 Access to System Services......Page 258 Know Your Context......Page 259 Context Anti-Patterns......Page 260 App Icons… And Everything Else......Page 262 Foreground Layer......Page 263 Legacy......Page 266 Using In Your Manifest......Page 268 Creating Other Icons with the Asset Studio......Page 269 Depending on a Local JAR......Page 270 Artifacts and Repositories......Page 271 Configure the Repositories......Page 272 Identify the Version That You Want......Page 273 Add the Dependencies......Page 274 Recap: Layouts vs. Adapter-Based Containers......Page 276 The Challenge: Memory......Page 277 Enter RecyclerView......Page 278 The Dependency......Page 279 The Activity Layout......Page 280 The Row Layout......Page 281 The LayoutManager......Page 283 The Divider......Page 285 The ViewHolder......Page 286 The Toast......Page 288 The Adapter......Page 289 The Base Class......Page 291 onCreateViewHolder()......Page 292 Applying the ColorAdapter......Page 294 Hey, What About ListView?......Page 295 What’s a Configuration? And How Do They Change?......Page 298 Configurations and Resource Sets......Page 299 Language......Page 300 Screen Size and Orientation......Page 301 Hey, What About res/layout-land?......Page 302 Resource Set Rules......Page 303 Scenario #3: Multiple Qualifiers......Page 305 Scenario #5: Screen Density......Page 306 Activity Lifecycles......Page 307 onCreate() and onDestroy()......Page 309 Stick to the Pairs......Page 310 When Activities Die......Page 311 Context Anti-Pattern: Outliving It......Page 312 Configuration Changes......Page 314 What We Want… and What We Do Not Want......Page 315 The Dependencies......Page 316 The ViewModel......Page 317 Using the ViewModel......Page 318 The Results......Page 319 ViewModel and the Lifecycle......Page 320 Changing Data in the ViewModel......Page 324 The Event Model......Page 325 The New RecyclerView Bits......Page 326 The EventViewModel......Page 331 Updating the EventViewModel......Page 333 The Results......Page 336 When Processes Are Created......Page 338 BACK, HOME, and Your Process......Page 339 Termination......Page 340 Foreground Means “I Love You”......Page 341 Tasks and Your App......Page 342 What is a Task?......Page 343 Why Are We Passed a Bundle in onCreate()?......Page 344 When Do We Fill In the Instance State Bundle?......Page 345 Pondering Parcelable......Page 346 Parcelable by Annotation......Page 347 Parcelable by Code Generation......Page 348 The Parcelable Interface......Page 350 The CREATOR......Page 351 The ViewModelProvider.Factory......Page 352 Applying the Factory......Page 356 The Results......Page 357 Enabling Data Binding......Page 360 Augmenting the Layout......Page 361 Updating the Model......Page 365 Creating the Binding......Page 367 Pouring the Model into the Binding......Page 368 Getting the Root View......Page 369 Retrieving Widgets from the Binding......Page 370 Why Bother?......Page 372 Styles: DIY DRY......Page 374 The Locations Where We Use Styles......Page 375 The Available Attributes......Page 377 The Possible Values......Page 378 Themes: Would a Style By Any Other Name…......Page 379 The Theme Declaration......Page 380 The Parent, and an AppCompat Recap......Page 381 The Result......Page 382 Context Anti-Pattern: Using Application Everywhere......Page 384 Configuring the App Bar......Page 386 Toolbar......Page 387 Bars and This Book......Page 388 Vector Drawables......Page 389 Starting the Vector Asset Wizard......Page 390 Using Built-In Vector Artwork......Page 391 Importing SVGs......Page 392 Menu Resources......Page 394 Defining Menu Resources......Page 395 Creating the res/menu/ Directory......Page 396 Creating the Menu Resource......Page 397 Adding Menu Items......Page 398 Using Toolbar Directly......Page 399 Adding the Widget......Page 400 Tailoring the Theme......Page 401 Defining the Menu Resource......Page 403 Refresh......Page 404 About......Page 406 Populating the Toolbar......Page 407 Responding to Events......Page 409 Registering the Toolbar......Page 412 Responding to Events......Page 413 Having Fun at Bars......Page 415 Multiple Activities, and Your App......Page 416 Defining the Class and Resources......Page 417 Populating the Class and Resources......Page 418 Starting Your Own Activity......Page 419 The Second Activity......Page 420 Starting the Activity......Page 423 Using Implicit Intents......Page 425 The Scenario......Page 427 The Layout......Page 428 Picking a Contact......Page 431 Getting and Retaining the Contact......Page 433 Viewing the Contact......Page 436 The Inverse: ......Page 437 What?......Page 440 Who?!?......Page 441 Break the Intent Barrier......Page 442 Screen Sizes......Page 443 Where You Get Your Fragments From......Page 444 Static vs. Dynamic Fragments......Page 445 What We’re Building......Page 446 The Model......Page 448 Kotlin......Page 449 The Repository......Page 450 The Layout......Page 453 The ViewModel......Page 456 The Class Declaration......Page 457 The Arguments Bundle......Page 458 The onCreateView() Function......Page 459 The onViewCreated() Function......Page 460 The Row Layout......Page 462 The Viewmodel......Page 463 The Adapter and Row Holder......Page 464 The Fragment......Page 468 The FragmentTransaction......Page 470 Java......Page 471 The Activity......Page 472 The Fragment Lifecycle Methods......Page 474 onAttach() Versus onAttach()......Page 477 Context Anti-Pattern: Assuming Certain Types......Page 478 What We Get from the Navigation Component......Page 480 Uniform API/Isolation of Details......Page 481 “Safe Args”......Page 482 App Bar Up Integration......Page 483 Navigation Resources......Page 484 Navigation Resource Editor......Page 485 Destinations......Page 486 Actions......Page 488 NavHostFragment......Page 489 The Basics......Page 490 The KTX Bits......Page 491 The Safe Args Code Generator......Page 492 The Navigation Resource......Page 493 listFragment......Page 494 The Activity Layout......Page 495 Java......Page 497 Kotlin......Page 498 ListFragment......Page 499 DisplayFragment......Page 500 So… Was It Worth It?......Page 501 The Main Application Thread......Page 502 The UI Thread is for UI......Page 504 Introducing LiveData......Page 505 Active and Inactive States......Page 506 ColorLiveData......Page 507 ColorViewModel Changes......Page 510 Observing the Colors......Page 512 The Results......Page 514 Threads from Reactive Frameworks......Page 515 Threads from Background Processing......Page 516 Storing Data in a Room......Page 518 Requesting Permissions......Page 520 Working with Content......Page 522 Operating in the Background......Page 524 Injecting Your Dependencies......Page 526 Testing Your Changes......Page 528 Creating a New Project......Page 530 Shrinking Your App......Page 532 Using the SDK Manager......Page 534 Using the AVD Manager and the Emulator......Page 536 Configuring Your Project......Page 538 Configuring Android Studio......Page 540
Similar books
Elements of Android Room Version 0.6
2021 · EPUB
Elements of Kotlin
2021 · PDF
Android's Architecture Components (Final Version)
2019 · PDF
The Busy Coder’s Guide To Android Development (Final Version)
2019 · PDF
The Busy Coder’s Guide To Android Development (Final Version)
2019 · EPUB
Android’s Architecture Components Version 0.10
2018 · PDF
The Busy Coder’s Guide to Android Development
2017 · PDF
The Busy Coder’s Guide to Android Development Version 8.8
2017 · EPUB