Skip to content

Commit 4018b56

Browse files
committed
Multimodule navigation to Home Fragment
1 parent 7b0dccd commit 4018b56

File tree

11 files changed

+126
-8
lines changed

11 files changed

+126
-8
lines changed

app/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,24 @@ android {
2828
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2929
}
3030
}
31+
3132
compileOptions {
3233
sourceCompatibility JavaVersion.VERSION_1_8
3334
targetCompatibility JavaVersion.VERSION_1_8
3435
}
36+
3537
kotlinOptions {
3638
jvmTarget = '1.8'
3739
}
40+
3841
packagingOptions {
3942
pickFirst 'META-INF/kotlinx-io.kotlin_module'
4043
pickFirst 'META-INF/atomicfu.kotlin_module'
4144
pickFirst 'META-INF/kotlinx-coroutines-io.kotlin_module'
4245
pickFirst 'kotlin/reflect/reflect.kotlin_builtins'
4346
}
47+
48+
dynamicFeatures = [":home"]
4449
}
4550

4651
dependencies {

app/src/main/java/cz/skywall/multimoduleexample/MainActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class MainActivity : AppCompatActivity() {
1111
setContentView(R.layout.activity_main)
1212

1313
(main_navigation_fragment as? NavHostFragment)?.navController?.apply {
14-
val navGraph = navInflater.inflate(R.navigation.nav_graph).apply {
15-
// startDestination = R.id.
14+
val navGraph = navInflater.inflate(R.navigation.main_nav_graph).apply {
15+
startDestination = R.id.home_navigation_graph
1616
}
1717

1818
graph = navGraph

app/src/main/res/navigation/nav_graph.xml renamed to app/src/main/res/navigation/main_nav_graph.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
<fragment
88
android:id="@+id/splashFragment"
99
android:name="cz.skywall.multimoduleexample.SplashFragment"
10-
android:label="fragment_home" />
10+
android:label="Splash fragment" />
1111

12-
<!-- <include-dynamic-->
13-
<!-- android:id="@+id/home_navigation_graph"-->
14-
<!-- app:graphPackage="@string/module_id_home"-->
15-
<!-- app:graphResName="home_navigation_graph"-->
16-
<!-- app:moduleName="home"/>-->
12+
<include-dynamic
13+
android:id="@+id/home_navigation_graph"
14+
app:graphPackage="@string/module_id_home"
15+
app:graphResName="home_nav_graph"
16+
app:moduleName="home"/>
1717
</navigation>

home/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

home/build.gradle

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
plugins {
2+
id 'com.android.dynamic-feature'
3+
id 'kotlin-android'
4+
id 'kotlin-android-extensions'
5+
id 'kotlin-kapt'
6+
}
7+
8+
apply from: '../core_dependencies.gradle'
9+
apply from: '../test_dependencies.gradle'
10+
11+
android {
12+
compileSdkVersion 29
13+
buildToolsVersion "29.0.3"
14+
15+
defaultConfig {
16+
minSdkVersion 23
17+
targetSdkVersion 29
18+
versionCode 1
19+
versionName "1.0"
20+
21+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
22+
consumerProguardFiles "consumer-rules.pro"
23+
}
24+
25+
buildTypes {
26+
release {
27+
minifyEnabled false
28+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
29+
}
30+
}
31+
compileOptions {
32+
sourceCompatibility JavaVersion.VERSION_1_8
33+
targetCompatibility JavaVersion.VERSION_1_8
34+
}
35+
kotlinOptions {
36+
jvmTarget = '1.8'
37+
}
38+
}
39+
40+
dependencies {
41+
implementation project(":app")
42+
43+
kapt 'com.google.dagger:dagger-compiler:2.27'
44+
}

home/consumer-rules.pro

Whitespace-only changes.

home/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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

home/src/main/AndroidManifest.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:dist="http://schemas.android.com/apk/distribution"
3+
package="cz.skywall.multimoduleexample.home">
4+
5+
<dist:module
6+
dist:instant="false"
7+
dist:onDemand="false"
8+
dist:title="Home Fragment">
9+
10+
<dist:fusing dist:include="true"/>
11+
12+
</dist:module>
13+
14+
</manifest>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package cz.skywall.multimoduleexample.home
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import android.widget.TextView
8+
import androidx.fragment.app.Fragment
9+
10+
class HomeFragment : Fragment() {
11+
12+
override fun onCreateView(
13+
inflater: LayoutInflater,
14+
container: ViewGroup?,
15+
savedInstanceState: Bundle?
16+
): View? {
17+
return TextView(requireActivity()).apply {
18+
text = "Home Fragment"
19+
}
20+
}
21+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
app:startDestination="@id/home_fragment">
5+
6+
<fragment
7+
android:id="@+id/home_fragment"
8+
android:name="cz.skywall.multimoduleexample.home.HomeFragment"
9+
android:label="fragment_home" />
10+
11+
</navigation>

0 commit comments

Comments
 (0)