Slide 1

Slide 1 text

Android Jetpack: Navigationを使っ てみる Google I/O 2018 わいわい報告会 @teshi04

Slide 2

Slide 2 text

About me てし @teshi04 Yui Matuura Mercari/Marpay

Slide 3

Slide 3 text

Android Jetpack

Slide 4

Slide 4 text

Jetpack: Architecture ● Databinding ● Lifecycles ● LiveData ● Navigation new! ● Paging new! ● Room ● ViewModel ● WorkManager new!

Slide 5

Slide 5 text

デモ

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Navigationの課題 ● Fragment Transition ● Passing Arguments ● Deep Links ● Up and Back ● Testing ● Error-prone Boilerplate

Slide 8

Slide 8 text

Architecture: Navigation ビジュアルツールとXML ● Navigation Actions ● Arguments ● Animation ● Up behavior ● Deep Link no more Fragment Transaction!

Slide 9

Slide 9 text

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'

Slide 10

Slide 10 text

NavHostFragmentを追加 activity_main.xml

Slide 11

Slide 11 text

Navigation Graph

Slide 12

Slide 12 text

Actionを設定する

Slide 13

Slide 13 text

Actionを設定する

Slide 14

Slide 14 text

Navigation Graph(XML) mobile_navigation.xml ...

Slide 15

Slide 15 text

NavControllerで遷移する MainFragment.kt transactionsButton.setOnClickListener { view -> Navigation.findNavController(view).navigate(R.id.next_action) }

Slide 16

Slide 16 text

まとめ ● Android Jetpack: Navigationのメリット ○ 画面遷移が可視化できる ○ FragmentTransition, Animationが簡単とか ● Jetpack。手段の一つでしかない。使うか使わないかは アプリの次第だと思う

Slide 17

Slide 17 text

参考リンク ● 「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/

Slide 18

Slide 18 text

Thanks!