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

Android Jetpack: Navigationを使ってみる

Android Jetpack: Navigationを使ってみる

Yui Matsuura

May 17, 2018
Tweet

More Decks by Yui Matsuura

Other Decks in Technology

Transcript

  1. Jetpack: Architecture • Databinding • Lifecycles • LiveData • Navigation

    new! • Paging new! • Room • ViewModel • WorkManager new!
  2. Navigationの課題 • Fragment Transition • Passing Arguments • Deep Links

    • Up and Back • Testing • Error-prone Boilerplate
  3. Gradle Dependency allprojects { repositories { google() jcenter() } }

    implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha01' implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha01'
  4. Navigation Graph(XML) mobile_navigation.xml <navigation xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" app:startDestination="@+id/launcher_home"> <fragment android:id="@+id/launcher_home"

    android:name="com.example.android.codelabs.navigation.MainFragment" android:label="@string/home" tools:layout="@layout/main_fragment"> <action android:id="@+id/next_action" app:destination="@id/flow_step_one" ... app:popExitAnim="@anim/slide_out_right" /> </fragment> <fragment android:id="@+id/flow_step_one" android:name="com.example.android.codelabs.navigation.FlowStepFragment" tools:layout="@layout/flow_step_one_fragment"/> ...
  5. まとめ • Android Jetpack: Navigationのメリット ◦ 画面遷移が可視化できる ◦ FragmentTransition, Animationが簡単とか

    • Jetpack。手段の一つでしかない。使うか使わないかは アプリの次第だと思う
  6. 参考リンク • 「Android Jetpack: manage UI navigation with Navigation Controller

    (Google I/O '18) https://www.youtube.com/watch?v=8GCXtCjtg40 • Sample https://github.com/googlesamples/android-architecture-c omponents/tree/master/NavigationBasicSample • Navigation Codelab https://codelabs.developers.google.com/codelabs/androi d-navigation/index.html • ドキュメント https://developer.android.com/topic/libraries/architecture/ navigation/