Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Hi Ed, Thank you so much for these suggestions. I've been reviewing them and merging them in. Hopefully it should be live. I've included a thank you note too in the article.
ap...@google.com <ap...@google.com> #3
Great! Thanks a lot, I'll look for the live updates soon!
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit fca6251684a11f480ced8fffca6783f87f187f47
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Dec 09 14:59:49 2021
Integrate CreationExtras into ComponentActivity
Providing access to default CreationExtras from ComponentActivity so
that they can be used by custom ViewModelProvider factories.
RelNote: "`ComponentActivity` now provides CreationExtras via the
`getDefaultViewModelCreationExtras()` method."
Test: ComponentActivityViewModelTest
Bug: 207012584
Change-Id: Ie7e00cf560026d19de728920f8c233a128ec24f3
M activity/activity/src/androidTest/java/androidx/activity/ComponentActivityViewModelTest.kt
M activity/activity/src/main/java/androidx/activity/ComponentActivity.java
https://android-review.googlesource.com/1917658
Branch: androidx-main
commit fca6251684a11f480ced8fffca6783f87f187f47
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Dec 09 14:59:49 2021
Integrate CreationExtras into ComponentActivity
Providing access to default CreationExtras from ComponentActivity so
that they can be used by custom ViewModelProvider factories.
RelNote: "`ComponentActivity` now provides CreationExtras via the
`getDefaultViewModelCreationExtras()` method."
Test: ComponentActivityViewModelTest
Bug: 207012584
Change-Id: Ie7e00cf560026d19de728920f8c233a128ec24f3
M activity/activity/src/androidTest/java/androidx/activity/ComponentActivityViewModelTest.kt
M activity/activity/src/main/java/androidx/activity/ComponentActivity.java
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-main
commit 223bd2a9d70bbbd235909c733ac8b821e887a4fa
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Dec 09 15:18:57 2021
Provide creation extras to ViewModel lazy
When using by viewModels, since they are normally called as part of
initialization, there is normally no application context attached yet.
This means creation extras passes has a null application associated with
its key, causing a failure. We should make sure the Creation extras are
accessed just in time.
RelNote: "The `by viewModels()` and `by activityViewModels()` Kotlin property extensions
now correctly pass `CreationExtras` to your `ViewModelProvider.Factory` when your `ViewModelStoreOwner` implements `getDefaultViewModelCreationExtras()`."
Test: modified existing tests
Bug: 207012584
Bug: 207012585
Bug: 207012490
Change-Id: I79f2bbd8ae78103d3ef764fd527674cdfb592936
M lifecycle/lifecycle-viewmodel/api/current.txt
M fragment/fragment-ktx/api/public_plus_experimental_current.txt
M activity/activity-ktx/src/main/java/androidx/activity/ActivityViewModelLazy.kt
M lifecycle/lifecycle-viewmodel/api/restricted_current.txt
M fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentViewModelLazyTest.kt
M fragment/fragment-ktx/api/current.txt
M fragment/fragment-ktx/src/main/java/androidx/fragment/app/FragmentViewModelLazy.kt
M fragment/fragment-ktx/api/restricted_current.txt
M lifecycle/lifecycle-viewmodel/api/public_plus_experimental_current.txt
M lifecycle/lifecycle-viewmodel/src/main/java/androidx/lifecycle/ViewModelLazy.kt
https://android-review.googlesource.com/1917657
Branch: androidx-main
commit 223bd2a9d70bbbd235909c733ac8b821e887a4fa
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Dec 09 15:18:57 2021
Provide creation extras to ViewModel lazy
When using by viewModels, since they are normally called as part of
initialization, there is normally no application context attached yet.
This means creation extras passes has a null application associated with
its key, causing a failure. We should make sure the Creation extras are
accessed just in time.
RelNote: "The `by viewModels()` and `by activityViewModels()` Kotlin property extensions
now correctly pass `CreationExtras` to your `ViewModelProvider.Factory` when your `ViewModelStoreOwner` implements `getDefaultViewModelCreationExtras()`."
Test: modified existing tests
Bug: 207012584
Bug: 207012585
Bug: 207012490
Change-Id: I79f2bbd8ae78103d3ef764fd527674cdfb592936
M lifecycle/lifecycle-viewmodel/api/current.txt
M fragment/fragment-ktx/api/public_plus_experimental_current.txt
M activity/activity-ktx/src/main/java/androidx/activity/ActivityViewModelLazy.kt
M lifecycle/lifecycle-viewmodel/api/restricted_current.txt
M fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentViewModelLazyTest.kt
M fragment/fragment-ktx/api/current.txt
M fragment/fragment-ktx/src/main/java/androidx/fragment/app/FragmentViewModelLazy.kt
M fragment/fragment-ktx/api/restricted_current.txt
M lifecycle/lifecycle-viewmodel/api/public_plus_experimental_current.txt
M lifecycle/lifecycle-viewmodel/src/main/java/androidx/lifecycle/ViewModelLazy.kt
jb...@google.com <jb...@google.com> #6
This has been added internally and will be available in the Activity 1.5.0-alpha01
release.
ro...@gmail.com <ro...@gmail.com> #7 Restricted+
Restricted+
Comment has been deleted.
Description
Component used: Activity
ViewModel added new APIs for providing information from
CreationExtras
ViewModelStoreOwner
s to ViewModel factories. This should be integrated intoComponentActivity
so that custom factories can rely on these extras being available.