├── .gitignore ├── .idea ├── codeStyles │ └── Project.xml ├── gradle.xml ├── inspectionProfiles │ └── Project_Default.xml ├── misc.xml ├── navEditor.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── Screen Shot 2018-06-28 at 09.54.47.png ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── jdapplications │ │ └── multi_module_navigation_sample │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── jdapplications │ │ │ └── multi_module_navigation_sample │ │ │ ├── MainActivity.kt │ │ │ └── ui │ │ │ └── main │ │ │ ├── MainFragment.kt │ │ │ └── MainViewModel.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── main_activity.xml │ │ └── main_fragment.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── navigation │ │ └── main_graph.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── jdapplications │ └── multi_module_navigation_sample │ └── ExampleUnitTest.kt ├── build.gradle ├── fourth_feature ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── jdapplications │ │ └── fourth_feature │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── jdapplications │ │ │ └── fourth_feature │ │ │ ├── FourthFeatureFragment.kt │ │ │ └── FourthFeatureViewModel.kt │ └── res │ │ ├── layout │ │ └── fourth_feature_fragment.xml │ │ ├── navigation │ │ └── fourth_feature_graph.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── jdapplications │ └── fourth_feature │ └── ExampleUnitTest.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── second_feature ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── jdapplications │ │ └── second_feature │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── jdapplications │ │ │ └── second_feature │ │ │ ├── SecondFeatureFragment.kt │ │ │ └── SecondFeatureViewModel.kt │ └── res │ │ ├── layout │ │ └── second_feature_fragment.xml │ │ ├── navigation │ │ └── second_feature_graph.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── jdapplications │ └── second_feature │ └── ExampleUnitTest.java ├── settings.gradle └── third_feature ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src ├── androidTest └── java │ └── com │ └── jdapplications │ └── third_feature │ └── ExampleInstrumentedTest.java ├── main ├── AndroidManifest.xml ├── java │ └── com │ │ └── jdapplications │ │ └── third_feature │ │ ├── ThirdFeatureFragment.kt │ │ ├── ThirdFeatureFragmentSecondScreen.kt │ │ ├── ThirdFeatureFragmentSecondScreenViewModel.kt │ │ └── ThirdFeatureViewModel.kt └── res │ ├── layout │ ├── third_feature_fragment.xml │ └── third_feature_fragment_second_screen_fragment.xml │ ├── navigation │ └── third_feature_graph.xml │ └── values │ └── strings.xml └── test └── java └── com └── jdapplications └── third_feature └── ExampleUnitTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches/build_file_checksums.ser 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | .DS_Store 9 | /build 10 | /captures 11 | .externalNativeBuild 12 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 29 | 30 | 31 | 32 | 33 | 34 | 36 | -------------------------------------------------------------------------------- /.idea/navEditor.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 151 | 152 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # android-multi-module-navigation 2 | A showcase app for the new navigation component with a multiple module project 3 | 4 | Check out the article on Medium: 5 | 6 | https://medium.com/@hartwich.daniel/multi-module-navigation-with-the-android-architecture-component-82ed028fa1d9 7 | 8 | 9 | ![](https://raw.githubusercontent.com/dhartwich1991/android-multi-module-navigation/master/Screen%20Shot%202018-06-28%20at%2009.54.47.png) 10 | -------------------------------------------------------------------------------- /Screen Shot 2018-06-28 at 09.54.47.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dhartwich1991/android-multi-module-navigation/fe2301d7cf575d60f23ba0ec8f5388f243293cf1/Screen Shot 2018-06-28 at 09.54.47.png -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 28 9 | defaultConfig { 10 | applicationId "com.jdapplications.multi_module_navigation_sample" 11 | minSdkVersion 21 12 | targetSdkVersion 28 13 | versionCode 1 14 | versionName "1.0" 15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation fileTree(dir: 'libs', include: ['*.jar']) 27 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 28 | implementation 'androidx.appcompat:appcompat:1.0.0-alpha3' 29 | implementation 'androidx.constraintlayout:constraintlayout:1.1.2' 30 | implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-alpha1' 31 | testImplementation 'junit:junit:4.12' 32 | androidTestImplementation 'androidx.test:runner:1.1.0-alpha3' 33 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3' 34 | implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha02' 35 | implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha02' 36 | 37 | implementation project(':second_feature') 38 | } 39 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/jdapplications/multi_module_navigation_sample/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.jdapplications.multi_module_navigation_sample 2 | 3 | import androidx.test.InstrumentationRegistry 4 | import androidx.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getTargetContext() 22 | assertEquals("com.jdapplications.multi_module_navigation_sample", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/jdapplications/multi_module_navigation_sample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.jdapplications.multi_module_navigation_sample 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | import androidx.navigation.Navigation 6 | import androidx.navigation.ui.NavigationUI 7 | 8 | class MainActivity : AppCompatActivity() { 9 | 10 | override fun onCreate(savedInstanceState: Bundle?) { 11 | super.onCreate(savedInstanceState) 12 | setContentView(R.layout.main_activity) 13 | setupNavigation() 14 | } 15 | 16 | override fun onSupportNavigateUp() = 17 | Navigation.findNavController(findViewById(R.id.mainNavigationFragment)).navigateUp() 18 | 19 | private fun setupNavigation() { 20 | val navController = Navigation.findNavController(findViewById(R.id.mainNavigationFragment)) 21 | NavigationUI.setupActionBarWithNavController(this@MainActivity, navController) 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/jdapplications/multi_module_navigation_sample/ui/main/MainFragment.kt: -------------------------------------------------------------------------------- 1 | package com.jdapplications.multi_module_navigation_sample.ui.main 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import androidx.fragment.app.Fragment 8 | import androidx.lifecycle.ViewModelProviders 9 | import androidx.navigation.Navigation 10 | import com.jdapplications.multi_module_navigation_sample.R 11 | import kotlinx.android.synthetic.main.main_fragment.view.* 12 | 13 | class MainFragment : Fragment() { 14 | 15 | companion object { 16 | fun newInstance() = MainFragment() 17 | } 18 | 19 | private lateinit var viewModel: MainViewModel 20 | 21 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, 22 | savedInstanceState: Bundle?): View { 23 | val view = inflater.inflate(R.layout.main_fragment, container, false) 24 | view.navigateToFeatureTwo.setOnClickListener { 25 | Navigation.findNavController(it).navigate(R.id.navigateToSecondFeature) 26 | } 27 | return view 28 | 29 | } 30 | 31 | override fun onActivityCreated(savedInstanceState: Bundle?) { 32 | super.onActivityCreated(savedInstanceState) 33 | viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java) 34 | // TODO: Use the ViewModel 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/jdapplications/multi_module_navigation_sample/ui/main/MainViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.jdapplications.multi_module_navigation_sample.ui.main 2 | 3 | import androidx.lifecycle.ViewModel 4 | 5 | class MainViewModel : ViewModel() { 6 | // TODO: Implement the ViewModel 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 11 | 16 | 21 | 26 | 31 | 36 | 41 | 46 | 51 | 56 | 61 | 66 | 71 | 76 | 81 | 86 | 91 | 96 | 101 | 106 | 111 | 116 | 121 | 126 | 131 | 136 | 141 | 146 | 151 | 156 | 161 | 166 | 171 | 172 | -------------------------------------------------------------------------------- /app/src/main/res/layout/main_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/main_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 20 |