Created
February 26, 2020 22:43
-
-
Save Nimrodda/2bec9b48cadb385f13936029efebb768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GenericSavedStateViewModelFactory<out V : ViewModel>( | |
private val viewModelFactory: ViewModelAssistedFactory<V>, | |
owner: SavedStateRegistryOwner, | |
defaultArgs: Bundle? = null | |
) : AbstractSavedStateViewModelFactory(owner, defaultArgs) { | |
@Suppress("UNCHECKED_CAST") | |
override fun <T : ViewModel> create( | |
key: String, | |
modelClass: Class<T>, | |
handle: SavedStateHandle | |
): T { | |
return viewModelFactory.create(handle) as T | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment