├── sample ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── styles.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 │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── layout │ │ │ ├── main_activity.xml │ │ │ └── sample_activity.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ └── drawable │ │ │ └── ic_launcher_background.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── wada811 │ │ └── viewmodelsavedstatektx │ │ └── sample │ │ ├── MainActivity.kt │ │ ├── SampleViewModel.kt │ │ └── SampleActivity.kt ├── proguard-rules.pro └── build.gradle ├── ViewModel-SavedState-ktx ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── com │ │ └── wada811 │ │ └── viewmodelsavedstatektx │ │ ├── SavedStateAdapter.kt │ │ ├── property │ │ ├── SavedStateLiveDataProperty.kt │ │ ├── SavedStateProperty.kt │ │ ├── SavedStateSerializableProperty.kt │ │ └── SavedStateLiveDataSerializableProperty.kt │ │ ├── SavedStateHandles.kt │ │ └── extension │ │ ├── Intent.kt │ │ └── Bundle.kt ├── build.gradle └── proguard-rules.pro ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .envrc.template ├── settings.gradle ├── renovate.json ├── publish-root.gradle ├── .github └── workflows │ └── maven-publish.yml ├── gradle.properties ├── publish-module.gradle ├── gradlew.bat ├── README.md ├── .gitignore ├── gradlew └── LICENSE /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /ViewModel-SavedState-ktx/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | SavedStateViewModel 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wada811/ViewModel-SavedState-ktx/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wada811/ViewModel-SavedState-ktx/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wada811/ViewModel-SavedState-ktx/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wada811/ViewModel-SavedState-ktx/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wada811/ViewModel-SavedState-ktx/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wada811/ViewModel-SavedState-ktx/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wada811/ViewModel-SavedState-ktx/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wada811/ViewModel-SavedState-ktx/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wada811/ViewModel-SavedState-ktx/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wada811/ViewModel-SavedState-ktx/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wada811/ViewModel-SavedState-ktx/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.envrc.template: -------------------------------------------------------------------------------- 1 | export OSSRH_USERNAME= 2 | export OSSRH_PASSWORD= 3 | export SONATYPE_STAGING_PROFILE_ID= 4 | export SIGNING_KEY_ID= 5 | export SIGNING_PASSWORD= 6 | export SIGNING_KEY= 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /ViewModel-SavedState-ktx/src/main/java/com/wada811/viewmodelsavedstatektx/SavedStateAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.wada811.viewmodelsavedstatektx 2 | 3 | interface SavedStateAdapter { 4 | fun toSavedState(value: TValue): TState 5 | fun fromSavedState(state: TState): TValue 6 | } 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | } 15 | rootProject.name = 'Android-ViewModel-SavedState-ktx' 16 | include ':ViewModel-SavedState-ktx', ':sample' 17 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ], 5 | "dependencyDashboard": true, 6 | "packageRules": [ 7 | { 8 | "groupName": "Android Gradle Plugin", 9 | "matchPackagePatterns": [ 10 | "com\\.android\\.application", 11 | "com\\.android\\.library" 12 | ] 13 | }, 14 | { 15 | "groupName": "Kotlin", 16 | "matchPackagePatterns": [ 17 | "^org\\.jetbrains\\.kotlin" 18 | ] 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/main_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | -------------------------------------------------------------------------------- /ViewModel-SavedState-ktx/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'com.diffplug.spotless' 4 | id 'org.jetbrains.kotlin.android' 5 | } 6 | 7 | apply from: "${rootDir}/publish-module.gradle" 8 | 9 | android { 10 | namespace "com.wada811.viewmodelsavedstatektx" 11 | compileSdkVersion 33 12 | defaultConfig { 13 | minSdkVersion 21 14 | } 15 | } 16 | 17 | dependencies { 18 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.10" 19 | implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1' 20 | implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.1' 21 | } 22 | -------------------------------------------------------------------------------- /ViewModel-SavedState-ktx/src/main/java/com/wada811/viewmodelsavedstatektx/property/SavedStateLiveDataProperty.kt: -------------------------------------------------------------------------------- 1 | package com.wada811.viewmodelsavedstatektx.property 2 | 3 | import androidx.lifecycle.MutableLiveData 4 | import androidx.lifecycle.SavedStateHandle 5 | import androidx.lifecycle.ViewModel 6 | import kotlin.properties.ReadOnlyProperty 7 | import kotlin.reflect.KProperty 8 | 9 | internal class SavedStateLiveDataProperty( 10 | private val savedStateHandle: SavedStateHandle 11 | ) : ReadOnlyProperty> { 12 | override fun getValue(thisRef: ViewModel, property: KProperty<*>): MutableLiveData { 13 | return savedStateHandle.getLiveData(property.name) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /publish-root.gradle: -------------------------------------------------------------------------------- 1 | ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') 2 | ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') 3 | ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') 4 | ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') 5 | ext["signing.password"] = System.getenv('SIGNING_PASSWORD') 6 | ext["signing.key"] = System.getenv('SIGNING_KEY') 7 | 8 | nexusPublishing { 9 | repositories { 10 | sonatype { 11 | stagingProfileId = sonatypeStagingProfileId 12 | username = ossrhUsername 13 | password = ossrhPassword 14 | nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) 15 | snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |