Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android App Architecture & Navigation

Bryan Herbst
September 04, 2018

Android App Architecture & Navigation

A look into the new navigation architecture component and how it fits with Fragments and Activites

Bryan Herbst

September 04, 2018
Tweet

More Decks by Bryan Herbst

Other Decks in Technology

Transcript

  1. Activity Entry point to your application Has a Window Has

    a lifecycle Responds to configuration changes
  2. Activity Entry point to your application Has a Window Has

    a lifecycle Responds to configuration changes ActivityManager handles back stack
  3. Activity Layout inflation View manipulation Click handlers Animations Navigation Menu

    creation Menu item callbacks Database calls Networking calls Disk I/O Sensor input Geolocation
  4. Principles Navigation is a stack Up never exits the app

    Up = Back within your app Deep linking should yield the same stack
  5. Destinations: Deep link Destinations can have deep links <fragment android:id="@+id/home”

    android:name="com.example.HomeFragment" android:label="fragment_home"> <deepLink app:uri="http://example.com/detail"/> </fragment>
  6. Actions: Animations Actions can have transition animations <action android:id="@+id/action_home_to_detail" app:destination="@id/detail"

    app:popEnterAnim="@anim/slide_in_left" app:popExitAnim="@anim/slide_out_right" app:enterAnim="@anim/slide_in_right" app:exitAnim="@anim/slide_out_left"/>
  7. Actions: back stack Each action can define its own behavior

    <action android:id="@+id/home_to_details" app:destination="@id/details” app:popUpTo="@id/splash” app:popUpToInclusive="false" />
  8. What’s missing Some integration with common elements like bottom navigation

    Shared element transitions Nested navigation graphs
  9. What’s missing Some integration with common elements like bottom navigation

    Shared element transitions Nested navigation graphs Result data (e.g. startActivityForResult())
  10. Single Activity Set up navigation graph Each Fragment is a

    destination Every transaction is an action
  11. Single Activity Set up navigation graph Each Fragment is a

    destination Every transaction is an action Define arguments
  12. Single Activity Set up navigation graph Each Fragment is a

    destination Every transaction is an action Define arguments Replace transactions with NavController.navigate()
  13. Multiple activities Start by making a graph for each Activity

    If you want a single Activity, combine Activities one screen at a time