diff --git a/app/build.gradle b/app/build.gradle index 846e3e0..7ec280f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,8 +1,8 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -apply plugin: 'kotlin-kapt' -apply plugin: 'androidx.navigation.safeargs.kotlin' -apply plugin: 'kotlin-parcelize' +apply plugin: "kotlin-kapt" +apply plugin: "androidx.navigation.safeargs.kotlin" +apply plugin: "kotlin-parcelize" android { compileSdkVersion 30 @@ -42,9 +42,8 @@ android { dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.0" - implementation 'androidx.core:core-ktx:1.3.2' - implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.5.0' + implementation 'androidx.appcompat:appcompat:1.3.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.legacy:legacy-support-v4:1.0.0' testImplementation 'junit:junit:4.13.2' @@ -67,7 +66,7 @@ dependencies { implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1" // Kotlin components - api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3" - api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3" + api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0-native-mt" + api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0-native-mt" } \ No newline at end of file diff --git a/app/src/main/java/com/example/todoapp/MainActivity.kt b/app/src/main/java/com/example/todoapp/MainActivity.kt index 4bfb6be..40965e0 100644 --- a/app/src/main/java/com/example/todoapp/MainActivity.kt +++ b/app/src/main/java/com/example/todoapp/MainActivity.kt @@ -2,20 +2,28 @@ package com.example.todoapp import androidx.appcompat.app.AppCompatActivity import android.os.Bundle +import androidx.navigation.NavController import androidx.navigation.findNavController +import androidx.navigation.fragment.NavHostFragment import androidx.navigation.ui.setupActionBarWithNavController class MainActivity : AppCompatActivity() { + + private lateinit var navController: NavController + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) - setupActionBarWithNavController(findNavController(R.id.navHostFragment)) + val navHostFragment = supportFragmentManager + .findFragmentById(R.id.navHostFragment) as NavHostFragment + navController = navHostFragment.navController + + setupActionBarWithNavController(navController) } override fun onSupportNavigateUp(): Boolean { - val navController = findNavController(R.id.navHostFragment) return navController.navigateUp() || super.onSupportNavigateUp() } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index a9a3584..201e086 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -6,7 +6,7 @@ android:layout_height="match_parent" tools:context=".MainActivity"> -