diff --git a/README.md b/README.md index b14189c2..e5adda5e 100644 --- a/README.md +++ b/README.md @@ -128,11 +128,39 @@ class MainActivity : AppCompatActivity(), SimpleStateChanger.NavigationHandler { } ``` -Where `FirstScreen` looks like this: +Where `FirstScreen` looks like this (assuming you have `data object` enabled): + +```groovy + kotlinOptions { + jvmTarget = "1.8" + languageVersion = '1.8' // data objects +} +``` + +```kotlin +// no args +@Parcelize +data object FirstScreen : DefaultFragmentKey() { + override fun instantiateFragment(): Fragment = FirstFragment() +} +``` + +If you don't have `data object` support yet, then no-args keys look like this (to ensure stable +hashCode/equals/toString): ``` kotlin -@Parcelize // typically data class -class FirstScreen: DefaultFragmentKey() { +// no args +@Parcelize +data class FirstScreen(private val noArgsPlaceholder: String = ""): DefaultFragmentKey() { + override fun instantiateFragment(): Fragment = FirstFragment() +} + +// has args +@Parcelize +data class FirstScreen( + val username: String, + val password: String, +): DefaultFragmentKey() { override fun instantiateFragment(): Fragment = FirstFragment() } ``` @@ -212,10 +240,10 @@ And then: ``` kotlin @Parcelize // typically data class -class FirstScreen: DefaultFragmentKey(), DefaultServiceProvider.HasServices { +data object FirstScreen: DefaultFragmentKey(), DefaultServiceProvider.HasServices { override fun instantiateFragment(): Fragment = FirstFragment() - override fun getScopeTag() = javaClass.name + override fun getScopeTag() = toString() override fun bindServices(serviceBinder: ServiceBinder) { with(serviceBinder) { @@ -257,7 +285,7 @@ Using `Backstack` to navigate allows you to move navigation responsibilities out class FirstScopedModel(private val backstack: Backstack) { fun doSomething() { // ... - backstack.goTo(SecondScreen()) + backstack.goTo(SecondScreen) } } ``` @@ -265,7 +293,7 @@ class FirstScopedModel(private val backstack: Backstack) { Another additional benefit is that your navigation history can be unit tested. ``` java -assertThat(backstack.getHistory()).containsExactly(SomeScreen(), OtherScreen()) +assertThat(backstack.getHistory()).containsExactly(SomeScreen, OtherScreen) ``` And most importantly, navigation (swapping screens) happens in one place, and you are in direct control of what happens in such a scenario. By writing a `StateChanger`, you can set up "how to display my current navigation state" in any way you want. No more `((MainActivity)getActivity()).setTitleText("blah");` inside Fragment's `onStart()`. @@ -303,7 +331,7 @@ For Fragment + Simple-Stack + Compose integration, you can also check [the corre ## License - Copyright 2017-2021 Gabor Varadi + Copyright 2017-2022 Gabor Varadi Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/build.gradle.kts b/build.gradle.kts index 9089a985..eb45dc36 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,7 +14,7 @@ buildscript { classpath("me.tatarka:gradle-retrolambda:3.7.0") classpath("io.realm:realm-gradle-plugin:10.12.0") classpath("io.realm:realm-transformer:10.12.0") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/samples/advanced-samples/extensions-compose-example/build.gradle b/samples/advanced-samples/extensions-compose-example/build.gradle index d84ae9de..b2eb65eb 100644 --- a/samples/advanced-samples/extensions-compose-example/build.gradle +++ b/samples/advanced-samples/extensions-compose-example/build.gradle @@ -29,6 +29,7 @@ android { kotlinOptions { jvmTarget = "1.8" + languageVersion = '1.8' // data objects } buildFeatures { @@ -36,8 +37,9 @@ android { compose = true } + composeOptions { - kotlinCompilerExtensionVersion compose_version + kotlinCompilerExtensionVersion "1.3.2" } packagingOptions { resources { @@ -45,9 +47,9 @@ android { pickFirsts += ['META-INF/core-ktx_release.kotlin_module'] } } - } + dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) diff --git a/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/app/MainActivity.kt b/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/app/MainActivity.kt index 8553132d..7dc79a89 100644 --- a/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/app/MainActivity.kt +++ b/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/app/MainActivity.kt @@ -38,7 +38,7 @@ class MainActivity : AppCompatActivity(), SimpleStateChanger.NavigationHandler { this, androidContentFrame, History.of( when { authenticationManager.isAuthenticated() -> ProfileKey(authenticationManager.getAuthenticatedUser()) - else -> LoginKey() + else -> LoginKey } ) ) diff --git a/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/login/LoginKey.kt b/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/login/LoginKey.kt index 9ac90615..d662d06e 100644 --- a/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/login/LoginKey.kt +++ b/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/login/LoginKey.kt @@ -9,7 +9,7 @@ import com.zhuinden.simplestackextensionscomposesample.app.FragmentKey import kotlinx.parcelize.Parcelize @Parcelize -data class LoginKey(private val noArgsPlaceholder: String = "") : FragmentKey() { +data object LoginKey : FragmentKey() { @Suppress("RemoveExplicitTypeArguments") override fun bindServices(serviceBinder: ServiceBinder) { with(serviceBinder) { diff --git a/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/login/LoginViewModel.kt b/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/login/LoginViewModel.kt index b072e5f9..1732c2d9 100644 --- a/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/login/LoginViewModel.kt +++ b/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/login/LoginViewModel.kt @@ -2,11 +2,7 @@ package com.zhuinden.simplestackextensionscomposesample.features.login import com.jakewharton.rxrelay2.BehaviorRelay import com.zhuinden.rxvalidatebykt.validateBy -import com.zhuinden.simplestack.Backstack -import com.zhuinden.simplestack.Bundleable -import com.zhuinden.simplestack.History -import com.zhuinden.simplestack.ScopedServices -import com.zhuinden.simplestack.StateChange +import com.zhuinden.simplestack.* import com.zhuinden.simplestackextensionscomposesample.app.AuthenticationManager import com.zhuinden.simplestackextensionscomposesample.features.profile.ProfileKey import com.zhuinden.simplestackextensionscomposesample.features.registration.EnterProfileDataKey @@ -54,7 +50,7 @@ class LoginViewModel( } fun onRegisterClicked() { - backstack.goTo(EnterProfileDataKey()) + backstack.goTo(EnterProfileDataKey) } override fun toBundle(): StateBundle = StateBundle().apply { diff --git a/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/profile/ProfileViewModel.kt b/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/profile/ProfileViewModel.kt index 53fc8e53..9fd01d46 100644 --- a/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/profile/ProfileViewModel.kt +++ b/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/profile/ProfileViewModel.kt @@ -13,7 +13,7 @@ class ProfileViewModel( ) : ScopedServices.Activated { override fun onServiceActive() { if (!authenticationManager.isAuthenticated()) { - backstack.setHistory(History.of(LoginKey()), StateChange.REPLACE) + backstack.setHistory(History.of(LoginKey), StateChange.REPLACE) } } diff --git a/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/registration/CreateLoginCredentialsKey.kt b/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/registration/CreateLoginCredentialsKey.kt index 3f22dbb8..3a097805 100644 --- a/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/registration/CreateLoginCredentialsKey.kt +++ b/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/registration/CreateLoginCredentialsKey.kt @@ -6,9 +6,7 @@ import com.zhuinden.simplestackextensionscomposesample.app.FragmentKey import kotlinx.parcelize.Parcelize @Parcelize -data class CreateLoginCredentialsKey( - private val noArgsPlaceholder: String = "", -) : FragmentKey(), ScopeKey.Child { +data object CreateLoginCredentialsKey : FragmentKey(), ScopeKey.Child { override fun getParentScopes(): List = listOf(RegistrationViewModel::class.java.name) override fun instantiateFragment(): Fragment = CreateLoginCredentialsFragment() diff --git a/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/registration/EnterProfileDataKey.kt b/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/registration/EnterProfileDataKey.kt index c7330d65..8dc7182c 100644 --- a/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/registration/EnterProfileDataKey.kt +++ b/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/registration/EnterProfileDataKey.kt @@ -6,9 +6,7 @@ import com.zhuinden.simplestackextensionscomposesample.app.FragmentKey import kotlinx.parcelize.Parcelize @Parcelize -data class EnterProfileDataKey( - private val noArgsPlaceholder: String = "", -) : FragmentKey(), ScopeKey.Child { +data object EnterProfileDataKey : FragmentKey(), ScopeKey.Child { override fun getParentScopes(): List = listOf(RegistrationViewModel::class.java.name) override fun instantiateFragment(): Fragment = EnterProfileDataFragment() diff --git a/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/registration/RegistrationViewModel.kt b/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/registration/RegistrationViewModel.kt index e6924877..92199a0b 100644 --- a/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/registration/RegistrationViewModel.kt +++ b/samples/advanced-samples/extensions-compose-example/src/main/java/com/zhuinden/simplestackextensionscomposesample/features/registration/RegistrationViewModel.kt @@ -2,11 +2,7 @@ package com.zhuinden.simplestackextensionscomposesample.features.registration import com.jakewharton.rxrelay2.BehaviorRelay import com.zhuinden.rxvalidatebykt.validateBy -import com.zhuinden.simplestack.Backstack -import com.zhuinden.simplestack.Bundleable -import com.zhuinden.simplestack.History -import com.zhuinden.simplestack.ScopedServices -import com.zhuinden.simplestack.StateChange +import com.zhuinden.simplestack.* import com.zhuinden.simplestackextensionscomposesample.app.AuthenticationManager import com.zhuinden.simplestackextensionscomposesample.features.profile.ProfileKey import com.zhuinden.simplestackextensionscomposesample.utils.get @@ -65,7 +61,7 @@ class RegistrationViewModel( fun onEnterProfileNextClicked() { if (isEnterProfileNextEnabledRelay.get()) { - backstack.goTo(CreateLoginCredentialsKey()) + backstack.goTo(CreateLoginCredentialsKey) } } diff --git a/samples/advanced-samples/extensions-example/build.gradle b/samples/advanced-samples/extensions-example/build.gradle index 6d89fefd..16fbcb9f 100644 --- a/samples/advanced-samples/extensions-example/build.gradle +++ b/samples/advanced-samples/extensions-example/build.gradle @@ -27,6 +27,7 @@ android { kotlinOptions { jvmTarget = "1.8" + languageVersion = '1.8' // data objects } buildFeatures { diff --git a/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/app/MainActivity.kt b/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/app/MainActivity.kt index dd8d06eb..d9f2eedf 100644 --- a/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/app/MainActivity.kt +++ b/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/app/MainActivity.kt @@ -40,7 +40,7 @@ class MainActivity : AppCompatActivity(), SimpleStateChanger.NavigationHandler { this, binding.step9Root, History.of( when { authenticationManager.isAuthenticated() -> ProfileKey(authenticationManager.getAuthenticatedUser()) - else -> LoginKey() + else -> LoginKey } )) } diff --git a/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/login/LoginKey.kt b/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/login/LoginKey.kt index 42bfdb86..5dccdf82 100644 --- a/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/login/LoginKey.kt +++ b/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/login/LoginKey.kt @@ -9,7 +9,7 @@ import com.zhuinden.simplestackextensions.servicesktx.lookup import kotlinx.parcelize.Parcelize @Parcelize -data class LoginKey(private val placeholder: String = "") : DefaultFragmentKey(), DefaultServiceProvider.HasServices { +data object LoginKey : DefaultFragmentKey(), DefaultServiceProvider.HasServices { override fun bindServices(serviceBinder: ServiceBinder) { with(serviceBinder) { add(LoginViewModel(lookup(), backstack)) diff --git a/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/login/LoginViewModel.kt b/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/login/LoginViewModel.kt index 2433fd8d..c205dccf 100644 --- a/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/login/LoginViewModel.kt +++ b/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/login/LoginViewModel.kt @@ -2,11 +2,7 @@ package com.zhuinden.simplestackextensionsample.features.login import com.jakewharton.rxrelay2.BehaviorRelay import com.zhuinden.rxvalidatebykt.validateBy -import com.zhuinden.simplestack.Backstack -import com.zhuinden.simplestack.Bundleable -import com.zhuinden.simplestack.History -import com.zhuinden.simplestack.ScopedServices -import com.zhuinden.simplestack.StateChange +import com.zhuinden.simplestack.* import com.zhuinden.simplestackextensionsample.app.AuthenticationManager import com.zhuinden.simplestackextensionsample.features.profile.ProfileKey import com.zhuinden.simplestackextensionsample.features.registration.EnterProfileDataKey @@ -50,7 +46,7 @@ class LoginViewModel( } fun onRegisterClicked() { - backstack.goTo(EnterProfileDataKey()) + backstack.goTo(EnterProfileDataKey) } override fun toBundle(): StateBundle = StateBundle().apply { diff --git a/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/profile/ProfileViewModel.kt b/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/profile/ProfileViewModel.kt index 01320720..682c2ceb 100644 --- a/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/profile/ProfileViewModel.kt +++ b/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/profile/ProfileViewModel.kt @@ -1,6 +1,5 @@ package com.zhuinden.simplestackextensionsample.features.profile -import android.content.Context import com.zhuinden.simplestack.Backstack import com.zhuinden.simplestack.History import com.zhuinden.simplestack.ScopedServices @@ -14,7 +13,7 @@ class ProfileViewModel( ) : ScopedServices.Activated { override fun onServiceActive() { if (!authenticationManager.isAuthenticated()) { - backstack.setHistory(History.of(LoginKey()), StateChange.REPLACE) + backstack.setHistory(History.of(LoginKey), StateChange.REPLACE) } } diff --git a/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/registration/CreateLoginCredentialsKey.kt b/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/registration/CreateLoginCredentialsKey.kt index f06e5e2d..c15a346f 100644 --- a/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/registration/CreateLoginCredentialsKey.kt +++ b/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/registration/CreateLoginCredentialsKey.kt @@ -6,7 +6,7 @@ import com.zhuinden.simplestackextensions.fragments.DefaultFragmentKey import kotlinx.parcelize.Parcelize @Parcelize -data class CreateLoginCredentialsKey(private val placeholder: String = "") : DefaultFragmentKey(), ScopeKey.Child { +data object CreateLoginCredentialsKey : DefaultFragmentKey(), ScopeKey.Child { override fun instantiateFragment(): Fragment = CreateLoginCredentialsFragment() override fun getParentScopes(): List = listOf(RegistrationViewModel::class.java.name) diff --git a/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/registration/EnterProfileDataKey.kt b/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/registration/EnterProfileDataKey.kt index 07b83501..fbb539ba 100644 --- a/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/registration/EnterProfileDataKey.kt +++ b/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/registration/EnterProfileDataKey.kt @@ -6,7 +6,7 @@ import com.zhuinden.simplestackextensions.fragments.DefaultFragmentKey import kotlinx.parcelize.Parcelize @Parcelize -data class EnterProfileDataKey(private val placeholder: String = "") : DefaultFragmentKey(), ScopeKey.Child { +data object EnterProfileDataKey : DefaultFragmentKey(), ScopeKey.Child { override fun instantiateFragment(): Fragment = EnterProfileDataFragment() override fun getParentScopes(): List = listOf(RegistrationViewModel::class.java.name) diff --git a/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/registration/RegistrationViewModel.kt b/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/registration/RegistrationViewModel.kt index 82441d40..6c73aa8f 100644 --- a/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/registration/RegistrationViewModel.kt +++ b/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/features/registration/RegistrationViewModel.kt @@ -2,11 +2,7 @@ package com.zhuinden.simplestackextensionsample.features.registration import com.jakewharton.rxrelay2.BehaviorRelay import com.zhuinden.rxvalidatebykt.validateBy -import com.zhuinden.simplestack.Backstack -import com.zhuinden.simplestack.Bundleable -import com.zhuinden.simplestack.History -import com.zhuinden.simplestack.ScopedServices -import com.zhuinden.simplestack.StateChange +import com.zhuinden.simplestack.* import com.zhuinden.simplestackextensionsample.app.AuthenticationManager import com.zhuinden.simplestackextensionsample.features.profile.ProfileKey import com.zhuinden.simplestackextensionsample.utils.get @@ -63,7 +59,7 @@ class RegistrationViewModel( fun onEnterProfileNextClicked() { if (isEnterProfileNextEnabledRelay.get()) { - backstack.goTo(CreateLoginCredentialsKey()) + backstack.goTo(CreateLoginCredentialsKey) } } diff --git a/samples/advanced-samples/mvvm-sample/build.gradle.kts b/samples/advanced-samples/mvvm-sample/build.gradle.kts index 8a0c812c..8bc12eef 100644 --- a/samples/advanced-samples/mvvm-sample/build.gradle.kts +++ b/samples/advanced-samples/mvvm-sample/build.gradle.kts @@ -42,6 +42,7 @@ android { kotlinOptions { jvmTarget = "1.8" + languageVersion = "1.8" // data objects } buildFeatures { diff --git a/samples/advanced-samples/mvvm-sample/src/main/java/com/zhuinden/simplestackexamplemvvm/application/MainActivity.kt b/samples/advanced-samples/mvvm-sample/src/main/java/com/zhuinden/simplestackexamplemvvm/application/MainActivity.kt index 137b732f..06ce1879 100644 --- a/samples/advanced-samples/mvvm-sample/src/main/java/com/zhuinden/simplestackexamplemvvm/application/MainActivity.kt +++ b/samples/advanced-samples/mvvm-sample/src/main/java/com/zhuinden/simplestackexamplemvvm/application/MainActivity.kt @@ -40,8 +40,8 @@ class MainActivity : AppCompatActivity(), SimpleStateChanger.NavigationHandler { binding.navView.setNavigationItemSelectedListener { item: MenuItem -> when (item.itemId) { - R.id.list_navigation_menu_item -> backstack.goTo(TasksKey()) - R.id.statistics_navigation_menu_item -> backstack.goTo(StatisticsKey()) + R.id.list_navigation_menu_item -> backstack.goTo(TasksKey) + R.id.statistics_navigation_menu_item -> backstack.goTo(StatisticsKey) else -> { } } @@ -62,7 +62,7 @@ class MainActivity : AppCompatActivity(), SimpleStateChanger.NavigationHandler { .setStateChanger(SimpleStateChanger(this)) .setGlobalServices(globalServices) .setScopedServices(DefaultServiceProvider()) - .install(this, binding.contentFrame, History.of(TasksKey())) + .install(this, binding.contentFrame, History.of(TasksKey)) } override fun onBackPressed() { diff --git a/samples/advanced-samples/mvvm-sample/src/main/java/com/zhuinden/simplestackexamplemvvm/features/statistics/StatisticsKey.kt b/samples/advanced-samples/mvvm-sample/src/main/java/com/zhuinden/simplestackexamplemvvm/features/statistics/StatisticsKey.kt index a715429a..612eb51a 100644 --- a/samples/advanced-samples/mvvm-sample/src/main/java/com/zhuinden/simplestackexamplemvvm/features/statistics/StatisticsKey.kt +++ b/samples/advanced-samples/mvvm-sample/src/main/java/com/zhuinden/simplestackexamplemvvm/features/statistics/StatisticsKey.kt @@ -13,7 +13,7 @@ import kotlinx.parcelize.Parcelize * Created by Zhuinden on 2017.07.26.. */ @Parcelize -data class StatisticsKey(private val noArgPlaceHolder: String = "") : BaseKey() { +data object StatisticsKey : BaseKey() { override fun instantiateFragment(): Fragment = StatisticsFragment() @Suppress("RemoveExplicitTypeArguments") diff --git a/samples/advanced-samples/mvvm-sample/src/main/java/com/zhuinden/simplestackexamplemvvm/features/tasks/TasksKey.kt b/samples/advanced-samples/mvvm-sample/src/main/java/com/zhuinden/simplestackexamplemvvm/features/tasks/TasksKey.kt index 13a267a4..b8d758bd 100644 --- a/samples/advanced-samples/mvvm-sample/src/main/java/com/zhuinden/simplestackexamplemvvm/features/tasks/TasksKey.kt +++ b/samples/advanced-samples/mvvm-sample/src/main/java/com/zhuinden/simplestackexamplemvvm/features/tasks/TasksKey.kt @@ -11,17 +11,18 @@ import com.zhuinden.simplestackextensions.servicesktx.lookup import kotlinx.parcelize.Parcelize @Parcelize -data class TasksKey(private val noArgsPlaceHolder: String = "") : BaseKey() { +data object TasksKey : BaseKey() { override fun instantiateFragment(): Fragment = TasksFragment() @Suppress("RemoveExplicitTypeArguments") override fun bindServices(serviceBinder: ServiceBinder) { with(serviceBinder) { - add(TasksViewModel( - lookup(), - lookup(), - backstack, - getKey() + add( + TasksViewModel( + lookup(), + lookup(), + backstack, + getKey() )) } } diff --git a/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/build.gradle.kts b/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/build.gradle.kts index ee53c82f..a3192e99 100644 --- a/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/build.gradle.kts +++ b/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/build.gradle.kts @@ -17,6 +17,12 @@ android { testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } + kotlinOptions { + jvmTarget = "1.8" + languageVersion = "1.8" // data objects + } + + buildTypes { getByName("release") { isMinifyEnabled = false diff --git a/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/application/MainActivity.kt b/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/application/MainActivity.kt index eb325148..a75ad1ec 100644 --- a/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/application/MainActivity.kt +++ b/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/application/MainActivity.kt @@ -29,9 +29,9 @@ class MainActivity : AppCompatActivity(), SimpleStateChanger.NavigationHandler { binding.navigation.setOnNavigationItemSelectedListener { item -> val destination = when (item.itemId) { - R.id.navigation_home -> HomeKey() - R.id.navigation_dashboard -> DashboardKey() - R.id.navigation_notifications -> NotificationKey() + R.id.navigation_home -> HomeKey + R.id.navigation_dashboard -> DashboardKey + R.id.navigation_notifications -> NotificationKey else -> null } @@ -45,7 +45,7 @@ class MainActivity : AppCompatActivity(), SimpleStateChanger.NavigationHandler { Navigator.configure() .setStateChanger(SimpleStateChanger(this)) - .install(this, binding.container, History.single(HomeKey())) + .install(this, binding.container, History.single(HomeKey)) } override fun onBackPressed() { diff --git a/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/DashboardKey.kt b/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/DashboardKey.kt index d8ed69c0..18d5a2fa 100644 --- a/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/DashboardKey.kt +++ b/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/DashboardKey.kt @@ -8,6 +8,6 @@ import kotlinx.parcelize.Parcelize * Created by Owner on 2017.11.13. */ @Parcelize -data class DashboardKey(private val placeholder: String = "") : DefaultFragmentKey() { // generate reliable `toString()` for no-args data class +data object DashboardKey : DefaultFragmentKey() { // generate reliable `toString()` for no-args data class override fun instantiateFragment(): Fragment = DashboardFragment() } diff --git a/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/HomeFragment.kt b/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/HomeFragment.kt index cfcf9a6f..875bcdc2 100644 --- a/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/HomeFragment.kt +++ b/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/HomeFragment.kt @@ -19,7 +19,7 @@ class HomeFragment : KeyedFragment(R.layout.home_view) { val binding = HomeViewBinding.bind(view) binding.homeButton.onClick { - backstack.goTo(OtherKey()) + backstack.goTo(OtherKey) } val homeKey = getKey() // args diff --git a/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/HomeKey.kt b/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/HomeKey.kt index a1df8b11..7464bd04 100644 --- a/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/HomeKey.kt +++ b/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/HomeKey.kt @@ -7,6 +7,6 @@ import kotlinx.parcelize.Parcelize * Created by Owner on 2017.11.13. */ @Parcelize -data class HomeKey(private val placeholder: String = "") : DefaultFragmentKey() { // generate reliable `toString()` for no-args data class +data object HomeKey : DefaultFragmentKey() { // generate reliable `toString()` for no-args data class override fun instantiateFragment() = HomeFragment() } diff --git a/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/NotificationKey.kt b/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/NotificationKey.kt index 73e87f9e..c731cc85 100644 --- a/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/NotificationKey.kt +++ b/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/NotificationKey.kt @@ -7,6 +7,6 @@ import kotlinx.parcelize.Parcelize * Created by Owner on 2017.11.13. */ @Parcelize -data class NotificationKey(private val placeholder: String = "") : DefaultFragmentKey() { // generate reliable `toString()` for no-args data class +data object NotificationKey : DefaultFragmentKey() { // generate reliable `toString()` for no-args data class override fun instantiateFragment() = NotificationFragment() } diff --git a/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/OtherKey.kt b/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/OtherKey.kt index b25800bf..2b03546a 100644 --- a/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/OtherKey.kt +++ b/samples/basic-samples/simple-stack-example-basic-kotlin-fragment/src/main/java/com/zhuinden/simplestackexamplekotlinfragment/screens/OtherKey.kt @@ -7,6 +7,6 @@ import kotlinx.parcelize.Parcelize * Created by Owner on 2017.11.13. */ @Parcelize -data class OtherKey(private val placeholder: String = "") : DefaultFragmentKey() { // generate reliable `toString()` for no-args data class +data object OtherKey : DefaultFragmentKey() { // generate reliable `toString()` for no-args data class override fun instantiateFragment() = OtherFragment() } diff --git a/samples/basic-samples/simple-stack-example-basic-kotlin-view/build.gradle.kts b/samples/basic-samples/simple-stack-example-basic-kotlin-view/build.gradle.kts index fb3fc96b..a647e782 100644 --- a/samples/basic-samples/simple-stack-example-basic-kotlin-view/build.gradle.kts +++ b/samples/basic-samples/simple-stack-example-basic-kotlin-view/build.gradle.kts @@ -24,6 +24,12 @@ android { vectorDrawables.useSupportLibrary = true } + kotlinOptions { + jvmTarget = "1.8" + languageVersion = "1.8" // data objects + } + + buildTypes { getByName("release") { isMinifyEnabled = false diff --git a/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/application/MainActivity.kt b/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/application/MainActivity.kt index 62f17665..b6cd245a 100644 --- a/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/application/MainActivity.kt +++ b/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/application/MainActivity.kt @@ -22,22 +22,22 @@ class MainActivity : AppCompatActivity() { binding.navigation.setOnNavigationItemSelectedListener { item -> when (item.itemId) { R.id.navigation_home -> { - backstack.replaceHistory(HomeKey()) + backstack.replaceHistory(HomeKey) return@setOnNavigationItemSelectedListener true } R.id.navigation_dashboard -> { - backstack.replaceHistory(DashboardKey()) + backstack.replaceHistory(DashboardKey) return@setOnNavigationItemSelectedListener true } R.id.navigation_notifications -> { - backstack.replaceHistory(NotificationKey()) + backstack.replaceHistory(NotificationKey) return@setOnNavigationItemSelectedListener true } } false } - Navigator.install(this, binding.container, History.single(HomeKey())) + Navigator.install(this, binding.container, History.single(HomeKey)) } override fun onBackPressed() { diff --git a/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/DashboardKey.kt b/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/DashboardKey.kt index 283cabec..7778eb95 100644 --- a/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/DashboardKey.kt +++ b/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/DashboardKey.kt @@ -8,6 +8,6 @@ import kotlinx.parcelize.Parcelize * Created by Owner on 2017. 06. 29.. */ @Parcelize -data class DashboardKey(private val placeholder: String = "") : BaseKey() { +data object DashboardKey : BaseKey() { override fun layout(): Int = R.layout.dashboard_view } diff --git a/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/HomeKey.kt b/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/HomeKey.kt index a466893b..bb186c52 100644 --- a/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/HomeKey.kt +++ b/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/HomeKey.kt @@ -8,6 +8,6 @@ import kotlinx.parcelize.Parcelize * Created by Owner on 2017. 06. 29.. */ @Parcelize -data class HomeKey(private val placeholder: String = "") : BaseKey() { +data object HomeKey : BaseKey() { override fun layout(): Int = R.layout.home_view } diff --git a/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/HomeView.kt b/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/HomeView.kt index d7514b83..465007a9 100644 --- a/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/HomeView.kt +++ b/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/HomeView.kt @@ -29,7 +29,7 @@ class HomeView : RelativeLayout { binding = HomeViewBinding.bind(this) binding.buttonHome.onClick { - backstack.goTo(OtherKey()) + backstack.goTo(OtherKey) } val homeKey = Backstack.getKey(context) // get args diff --git a/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/NotificationKey.kt b/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/NotificationKey.kt index 6c078f25..9a2402a0 100644 --- a/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/NotificationKey.kt +++ b/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/NotificationKey.kt @@ -8,6 +8,6 @@ import kotlinx.parcelize.Parcelize * Created by Owner on 2017. 06. 29.. */ @Parcelize -data class NotificationKey(private val placeholder: String = "") : BaseKey() { +data object NotificationKey : BaseKey() { override fun layout(): Int = R.layout.notification_view } diff --git a/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/OtherKey.kt b/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/OtherKey.kt index 1a4ae323..fd6b2318 100644 --- a/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/OtherKey.kt +++ b/samples/basic-samples/simple-stack-example-basic-kotlin-view/src/main/java/com/zhuinden/navigationexamplekotlinview/screens/OtherKey.kt @@ -10,7 +10,7 @@ import kotlinx.parcelize.Parcelize * Created by Owner on 2017. 06. 29.. */ @Parcelize -data class OtherKey(private val placeholder: String = "") : BaseKey() { +data object OtherKey : BaseKey() { override fun layout(): Int = R.layout.other_view override fun viewChangeHandler(): ViewChangeHandler = SegueViewChangeHandler() diff --git a/samples/community-samples/simple-stack-example-kotlin-community-sample/build.gradle.kts b/samples/community-samples/simple-stack-example-kotlin-community-sample/build.gradle.kts index d0b58189..db80f0b0 100644 --- a/samples/community-samples/simple-stack-example-kotlin-community-sample/build.gradle.kts +++ b/samples/community-samples/simple-stack-example-kotlin-community-sample/build.gradle.kts @@ -26,6 +26,12 @@ android { testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } + kotlinOptions { + jvmTarget = "1.8" + languageVersion = "1.8" // data objects + } + + buildTypes { getByName("release") { isMinifyEnabled = false @@ -70,9 +76,9 @@ dependencies { implementation("androidx.recyclerview:recyclerview:1.2.1") implementation("com.squareup.okhttp3:okhttp:4.10.0") implementation("com.squareup.okhttp3:logging-interceptor:4.10.0") - implementation("com.google.dagger:dagger:2.42") + implementation("com.google.dagger:dagger:2.44") - kapt("com.google.dagger:dagger-compiler:2.42") + kapt("com.google.dagger:dagger-compiler:2.44") implementation("com.squareup.retrofit2:retrofit:2.9.0") { // exclude Retrofit’s OkHttp peer-dependency module and define your own module import diff --git a/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/application/MainActivity.kt b/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/application/MainActivity.kt index e1e13269..0d7baf47 100644 --- a/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/application/MainActivity.kt +++ b/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/application/MainActivity.kt @@ -24,7 +24,7 @@ class MainActivity : AppCompatActivity(), SimpleStateChanger.NavigationHandler { Navigator.configure() .setStateChanger(SimpleStateChanger(this)) - .install(this, binding.container, History.single(HomeKey())) + .install(this, binding.container, History.single(HomeKey)) } override fun onBackPressed() { diff --git a/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/screens/home/HomeFragment.kt b/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/screens/home/HomeFragment.kt index 78e19dac..700add1b 100644 --- a/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/screens/home/HomeFragment.kt +++ b/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/screens/home/HomeFragment.kt @@ -17,7 +17,7 @@ class HomeFragment : KeyedFragment(R.layout.fragment_home) { val binding = FragmentHomeBinding.bind(view) binding.buttonLoadUsers.onClick { - backstack.goTo(UsersKey()) + backstack.goTo(UsersKey) } } } \ No newline at end of file diff --git a/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/screens/home/HomeKey.kt b/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/screens/home/HomeKey.kt index b7909fbf..7610c6d6 100644 --- a/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/screens/home/HomeKey.kt +++ b/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/screens/home/HomeKey.kt @@ -4,6 +4,6 @@ import com.zhuinden.simplestackextensions.fragments.DefaultFragmentKey import kotlinx.parcelize.Parcelize @Parcelize -data class HomeKey(private val placeholder: String = "") : DefaultFragmentKey() { +data object HomeKey : DefaultFragmentKey() { override fun instantiateFragment() = HomeFragment() } \ No newline at end of file diff --git a/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/screens/users/UsersKey.kt b/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/screens/users/UsersKey.kt index 54c76d5f..84a62547 100644 --- a/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/screens/users/UsersKey.kt +++ b/samples/community-samples/simple-stack-example-kotlin-community-sample/src/main/java/com/community/simplestackkotlindaggerexample/screens/users/UsersKey.kt @@ -4,6 +4,6 @@ import com.zhuinden.simplestackextensions.fragments.DefaultFragmentKey import kotlinx.parcelize.Parcelize @Parcelize -data class UsersKey(private val placeholder: String = "") : DefaultFragmentKey() { +data object UsersKey : DefaultFragmentKey() { override fun instantiateFragment() = UsersFragment() } \ No newline at end of file diff --git a/samples/legacy-samples/simple-stack-example-multistack-fragment/build.gradle.kts b/samples/legacy-samples/simple-stack-example-multistack-fragment/build.gradle.kts index 824bd941..5702057f 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-fragment/build.gradle.kts +++ b/samples/legacy-samples/simple-stack-example-multistack-fragment/build.gradle.kts @@ -30,6 +30,7 @@ android { kotlinOptions { jvmTarget = "1.8" + languageVersion = "1.8" // data objects } buildFeatures { diff --git a/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/application/MainActivity.kt b/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/application/MainActivity.kt index 6632b3d4..d65552f3 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/application/MainActivity.kt +++ b/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/application/MainActivity.kt @@ -31,10 +31,10 @@ class MainActivity : AppCompatActivity(), SimpleStateChanger.NavigationHandler { override fun onCreate(savedInstanceState: Bundle?) { this.multistack = (lastCustomNonConfigurationInstance as Multistack?) ?: Multistack().apply { - add(CloudSyncKey()) - add(ChromeCastKey()) - add(MailKey()) - add(ListKey()) + add(CloudSyncKey) + add(ChromeCastKey) + add(MailKey) + add(ListKey) if (savedInstanceState != null) { fromBundle(savedInstanceState.getParcelable("multistack")) diff --git a/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/chromecast/ChromeCastKey.kt b/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/chromecast/ChromeCastKey.kt index 503a95b9..03103d75 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/chromecast/ChromeCastKey.kt +++ b/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/chromecast/ChromeCastKey.kt @@ -6,7 +6,7 @@ import com.zhuinden.simplestackdemomultistack.core.navigation.MultistackFragment import kotlinx.parcelize.Parcelize @Parcelize -data class ChromeCastKey(private val placeholder: String = "") : MultistackFragmentKey() { +data object ChromeCastKey : MultistackFragmentKey() { override fun stackIdentifier(): String = MainActivity.StackType.CHROMECAST.name override fun createFragment(): BaseFragment = ChromeCastFragment() diff --git a/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncFragment.kt b/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncFragment.kt index 57e31b43..0eea9bd2 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncFragment.kt +++ b/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncFragment.kt @@ -16,7 +16,7 @@ class CloudSyncFragment : BaseFragment(R.layout.cloudsync_fragment) { val binding = CloudsyncFragmentBinding.bind(view) binding.buttonFirst.onClick { - backstack.goTo(AnotherKey()) + backstack.goTo(AnotherKey) } } } diff --git a/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncKey.kt b/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncKey.kt index 2ddd60bc..73b6dd3b 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncKey.kt +++ b/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncKey.kt @@ -6,7 +6,7 @@ import com.zhuinden.simplestackdemomultistack.core.navigation.MultistackFragment import kotlinx.parcelize.Parcelize @Parcelize -data class CloudSyncKey(private val placeholder: String = "") : MultistackFragmentKey() { +data object CloudSyncKey : MultistackFragmentKey() { override fun stackIdentifier(): String = MainActivity.StackType.CLOUDSYNC.name override fun createFragment(): BaseFragment = CloudSyncFragment() diff --git a/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/another/AnotherKey.kt b/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/another/AnotherKey.kt index b88cc2d8..41ab3a6d 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/another/AnotherKey.kt +++ b/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/another/AnotherKey.kt @@ -6,7 +6,7 @@ import com.zhuinden.simplestackdemomultistack.core.navigation.MultistackFragment import kotlinx.parcelize.Parcelize @Parcelize -data class AnotherKey(private val placeholder: String = "") : MultistackFragmentKey() { +data object AnotherKey : MultistackFragmentKey() { override fun stackIdentifier(): String = MainActivity.StackType.CLOUDSYNC.name override fun createFragment(): BaseFragment = AnotherFragment() diff --git a/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/list/ListKey.kt b/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/list/ListKey.kt index c12a4ec9..ee09efff 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/list/ListKey.kt +++ b/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/list/ListKey.kt @@ -6,7 +6,7 @@ import com.zhuinden.simplestackdemomultistack.core.navigation.MultistackFragment import kotlinx.parcelize.Parcelize @Parcelize -data class ListKey(private val placeholder: String = "") : MultistackFragmentKey() { +data object ListKey : MultistackFragmentKey() { override fun stackIdentifier(): String = MainActivity.StackType.LIST.name override fun createFragment(): BaseFragment = ListFragment() diff --git a/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/mail/MailKey.kt b/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/mail/MailKey.kt index 67805cd0..0e765211 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/mail/MailKey.kt +++ b/samples/legacy-samples/simple-stack-example-multistack-fragment/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/mail/MailKey.kt @@ -6,7 +6,7 @@ import com.zhuinden.simplestackdemomultistack.core.navigation.MultistackFragment import kotlinx.parcelize.Parcelize @Parcelize -data class MailKey(private val placeholder: String = "") : MultistackFragmentKey() { +data object MailKey : MultistackFragmentKey() { override fun stackIdentifier(): String = MainActivity.StackType.MAIL.name override fun createFragment(): BaseFragment = MailFragment() diff --git a/samples/legacy-samples/simple-stack-example-multistack-view/build.gradle.kts b/samples/legacy-samples/simple-stack-example-multistack-view/build.gradle.kts index ed66a088..736db459 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-view/build.gradle.kts +++ b/samples/legacy-samples/simple-stack-example-multistack-view/build.gradle.kts @@ -30,6 +30,7 @@ android { kotlinOptions { jvmTarget = "1.8" + languageVersion = "1.8" // data objects } buildFeatures { diff --git a/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/application/MainActivity.kt b/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/application/MainActivity.kt index 6f2f4e40..7a38089c 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/application/MainActivity.kt +++ b/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/application/MainActivity.kt @@ -34,10 +34,10 @@ class MainActivity : AppCompatActivity(), MultistackViewStateChanger.AnimationSt override fun onCreate(savedInstanceState: Bundle?) { this.multistack = (lastCustomNonConfigurationInstance as Multistack?) ?: Multistack().apply { - add(CloudSyncKey()) - add(ChromeCastKey()) - add(MailKey()) - add(ListKey()) + add(CloudSyncKey) + add(ChromeCastKey) + add(MailKey) + add(ListKey) if (savedInstanceState != null) { fromBundle(savedInstanceState.getParcelable("multistack")) diff --git a/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/chromecast/ChromeCastKey.kt b/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/chromecast/ChromeCastKey.kt index f1f37e6b..d483ec43 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/chromecast/ChromeCastKey.kt +++ b/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/chromecast/ChromeCastKey.kt @@ -6,7 +6,7 @@ import com.zhuinden.simplestackdemomultistack.core.navigation.MultistackViewKey import kotlinx.parcelize.Parcelize @Parcelize -data class ChromeCastKey(private val placeholder: String = "") : MultistackViewKey() { +data object ChromeCastKey : MultistackViewKey() { override fun layout(): Int = R.layout.chromecast_view override fun stackIdentifier(): String = MainActivity.StackType.CHROMECAST.name } diff --git a/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncKey.kt b/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncKey.kt index e6d595c0..cb254012 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncKey.kt +++ b/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncKey.kt @@ -6,7 +6,7 @@ import com.zhuinden.simplestackdemomultistack.core.navigation.MultistackViewKey import kotlinx.parcelize.Parcelize @Parcelize -data class CloudSyncKey(private val placeholder: String = "") : MultistackViewKey() { +data object CloudSyncKey : MultistackViewKey() { override fun layout(): Int = R.layout.cloudsync_view override fun stackIdentifier(): String = MainActivity.StackType.CLOUDSYNC.name } diff --git a/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncView.kt b/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncView.kt index 8be26cce..61b5dfc5 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncView.kt +++ b/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/CloudSyncView.kt @@ -30,7 +30,7 @@ class CloudSyncView : RelativeLayout { super.onFinishInflate() findViewById(R.id.buttonFirst).onClick { - backstack.goTo(AnotherKey()) + backstack.goTo(AnotherKey) } } } diff --git a/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/another/AnotherKey.kt b/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/another/AnotherKey.kt index 383546a2..201af496 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/another/AnotherKey.kt +++ b/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/cloudsync/another/AnotherKey.kt @@ -6,7 +6,7 @@ import com.zhuinden.simplestackdemomultistack.core.navigation.MultistackViewKey import kotlinx.parcelize.Parcelize @Parcelize -data class AnotherKey(private val placeholder: String = "") : MultistackViewKey() { +data object AnotherKey : MultistackViewKey() { override fun layout(): Int = R.layout.another_view override fun stackIdentifier(): String = MainActivity.StackType.CLOUDSYNC.name } diff --git a/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/list/ListKey.kt b/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/list/ListKey.kt index 6444afa8..b35c69d9 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/list/ListKey.kt +++ b/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/list/ListKey.kt @@ -6,7 +6,7 @@ import com.zhuinden.simplestackdemomultistack.core.navigation.MultistackViewKey import kotlinx.parcelize.Parcelize @Parcelize -data class ListKey(private val placeholder: String = "") : MultistackViewKey() { +data object ListKey : MultistackViewKey() { override fun layout(): Int = R.layout.list_view override fun stackIdentifier(): String = MainActivity.StackType.LIST.name } diff --git a/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/mail/MailKey.kt b/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/mail/MailKey.kt index 2c317ad1..36c346dc 100644 --- a/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/mail/MailKey.kt +++ b/samples/legacy-samples/simple-stack-example-multistack-view/src/main/java/com/zhuinden/simplestackdemomultistack/features/main/mail/MailKey.kt @@ -6,7 +6,7 @@ import com.zhuinden.simplestackdemomultistack.core.navigation.MultistackViewKey import kotlinx.parcelize.Parcelize @Parcelize -data class MailKey(private val placeholder: String = "") : MultistackViewKey() { +data object MailKey : MultistackViewKey() { override fun layout(): Int = R.layout.mail_view override fun stackIdentifier(): String = MainActivity.StackType.MAIL.name } diff --git a/samples/scoping-samples/simple-stack-example-scoping-kotlin/build.gradle.kts b/samples/scoping-samples/simple-stack-example-scoping-kotlin/build.gradle.kts index e35bb5e1..4eb42559 100644 --- a/samples/scoping-samples/simple-stack-example-scoping-kotlin/build.gradle.kts +++ b/samples/scoping-samples/simple-stack-example-scoping-kotlin/build.gradle.kts @@ -33,6 +33,7 @@ android { kotlinOptions { jvmTarget = "1.8" + languageVersion = "1.8" // data objects } buildFeatures { diff --git a/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/application/MainActivity.kt b/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/application/MainActivity.kt index c93e22db..a699cc70 100644 --- a/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/application/MainActivity.kt +++ b/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/application/MainActivity.kt @@ -31,7 +31,7 @@ class MainActivity : AppCompatActivity(), SimpleStateChanger.NavigationHandler { Navigator.configure() .setStateChanger(SimpleStateChanger(this)) .setScopedServices(DefaultServiceProvider()) - .install(this, binding.container, History.of(WordListKey())) + .install(this, binding.container, History.of(WordListKey)) } override fun onBackPressed() { diff --git a/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/NewWordKey.kt b/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/NewWordKey.kt index d753b935..f7630854 100644 --- a/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/NewWordKey.kt +++ b/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/NewWordKey.kt @@ -9,7 +9,7 @@ import kotlinx.parcelize.Parcelize * Created by Zhuinden on 2018.09.17. */ @Parcelize -data class NewWordKey(val placeholder: String = "") : BaseKey() { +data object NewWordKey : BaseKey() { override fun instantiateFragment(): Fragment = NewWordFragment() override fun bindServices(serviceBinder: ServiceBinder) {} diff --git a/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/WordController.kt b/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/WordController.kt index 55ba1c77..8a98e911 100644 --- a/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/WordController.kt +++ b/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/WordController.kt @@ -40,7 +40,7 @@ class WordController( } override fun onAddNewWordClicked() { - backstack.goTo(NewWordKey()) + backstack.goTo(NewWordKey) } override fun onAddWordClicked(word: String) { diff --git a/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/WordListFragment.kt b/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/WordListFragment.kt index 396ccd64..0b30c699 100644 --- a/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/WordListFragment.kt +++ b/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/WordListFragment.kt @@ -3,7 +3,6 @@ package com.zhuinden.simplestackexamplescoping.features.words import android.os.Bundle import android.view.View import androidx.lifecycle.LiveData -import androidx.lifecycle.observe import androidx.recyclerview.widget.LinearLayoutManager import com.zhuinden.fragmentviewbindingdelegatekt.viewBinding import com.zhuinden.liveevent.observe diff --git a/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/WordListKey.kt b/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/WordListKey.kt index 9507be9d..99a40b43 100644 --- a/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/WordListKey.kt +++ b/samples/scoping-samples/simple-stack-example-scoping-kotlin/src/main/java/com/zhuinden/simplestackexamplescoping/features/words/WordListKey.kt @@ -11,7 +11,7 @@ import kotlinx.parcelize.Parcelize * Created by Zhuinden on 2018.09.17. */ @Parcelize -data class WordListKey(val placeholder: String = "") : BaseKey() { +data object WordListKey : BaseKey() { override fun bindServices(serviceBinder: ServiceBinder) { with(serviceBinder) { add(WordController(backstack)) diff --git a/samples/shared-element-samples/simple-stack-example-sharedelement-fragment/build.gradle.kts b/samples/shared-element-samples/simple-stack-example-sharedelement-fragment/build.gradle.kts index a56bef9c..bbcbd9e7 100644 --- a/samples/shared-element-samples/simple-stack-example-sharedelement-fragment/build.gradle.kts +++ b/samples/shared-element-samples/simple-stack-example-sharedelement-fragment/build.gradle.kts @@ -56,6 +56,6 @@ dependencies { implementation("androidx.appcompat:appcompat:1.5.1") implementation("androidx.recyclerview:recyclerview:1.2.1") implementation("androidx.vectordrawable:vectordrawable:1.1.0") - implementation("com.google.dagger:dagger:2.42") - annotationProcessor("com.google.dagger:dagger-compiler:2.42") + implementation("com.google.dagger:dagger:2.44") + annotationProcessor("com.google.dagger:dagger-compiler:2.44") } \ No newline at end of file