Status Update
Comments
th...@gmail.com <th...@gmail.com> #2
Jeremy, is this still an issue? I think the problem was that you had two transitions targeting the same View for the same action (e.g. two Slide() transitions).
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #3
I have a similar issue with plain AnimatorSet:
set.start()
set.pause()
set.setCurrentPlayTime(100)
set.setCurrentPlayTime(0)
set.setCurrentPlayTime(100)
set.resume()
doesn't play animation in resume().
ap...@google.com <ap...@google.com> #4
Should clarify that if I filter out setCurrentPlayTime(0)
(or replace it with setCurrentPlayTime(1)
) it works well.
Also even with setCurrentPlayTime(0)
, onAnimationEnd
is notified with correct delay (as if the animation has played).
ap...@google.com <ap...@google.com> #5
@
I think that is intended for Animator. If you set the currentPlayTime
to 0 or the total duration the animator completes. We do some
mg...@google.com <mg...@google.com>
ap...@google.com <ap...@google.com> #6
Did some investigation on the Fragment side and it seems like the merged transition is targeting correctly.
Exiting Transition: Slide@aa9288e: tgts(android.widget.LinearLayout{f9add3d})
>>>>> ExitingViews <<<<<
View: android.widget.LinearLayout{f9add3d}
Entering Transition: Slide@35b8af: tgts(android.widget.LinearLayout{b7f24bc})
>>>>> EnteringViews <<<<<
View: android.widget.LinearLayout{b7f24bc}
Final merged transition: TransitionSet@7bc1c45:
TransitionSet@e133f9a:
Slide@aa9288e: tgts(android.widget.LinearLayout{f9add3d})
Slide@35b8af: tgts(android.widget.LinearLayout{b7f24bc})
merged transition passed to controlDelayedTransition: TransitionSet@7bc1c45:
TransitionSet@e133f9a:
Slide@aa9288e: tgts(android.widget.LinearLayout{f9add3d})
Slide@35b8af: tgts(android.widget.LinearLayout{b7f24bc})
Still digging.
ap...@google.com <ap...@google.com> #7
Branch: androidx-main
commit 567b7459329d1ec8d27a8c6fe1c4a86442065d7d
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue Sep 26 20:06:54 2023
Add additional logging for transitions
Adding more debug logging in transitions to track the entering and
exiting transitions as well as the final merged transition and its
targets.
Test: added logging
Bug: 300157785
Change-Id: I0d9ad72b865422493c6c895ddb6115abf85eed16
M fragment/fragment/src/main/java/androidx/fragment/app/DefaultSpecialEffectsController.kt
ap...@google.com <ap...@google.com> #8
So I have isolated this outside of fragment into something much simpler and I think it breaks down when it comes to the adding and removing of Views with animateToStart.
The attached sample is a simple add that goes between two screens BLUE
and GREEN
. It has code for both the 1.5.0-alpha03
and 1.5.0-alpha04
versions, but I think alpha04 is currently broken in another way so I will upload the alpha03 version here.
This is integrated with predictive back similar to how fragment is, so upon cancelling we call animateToStart
, then we do a beginDelayedTransition
on a 0
duration Fade()
and we reverse the view visibility back to what it was prior to starting the transition.
If you only do visibility, cancel always works the view never goes away, it is wonderful, but when you do adding and removing views like we need to in fragment it fails.
First the code for beginDelayedTransition goes from this:
TransitionManager.beginDelayedTransition(container, Fade().apply {
duration = 0
})
reverseViews()
to this:
TransitionManager.beginDelayedTransition(container, Fade().apply {
duration = 0
addListener(onEnd = {
reverseViews()
blueScreen.visibility = View.VISIBLE
greenScreen.visibility = View.VISIBLE
})
})
reverseViews(useVisibility = true)
We need to make this change because after the animateToStart()
view is still parented by the overlay, so we call reverseViews(useVisibility = true)
to only change the visibility and then once the transition finishes we can call reverseViews()
to parent the view properly, then we make both views visible again.
From our perspective after the 0
duration transition our views are back in the proper state, but they do not transition properly after a cancel.
If the app is doing this wrong and we can make the appropriate fixes, doing the same in fragment should resolve this. There is logging available that shows the state of the views when we start the transition.
ap...@google.com <ap...@google.com> #9
The API has changed since that project was created in a way that makes the API more robust. I'm hoping that has fixed this...
ap...@google.com <ap...@google.com> #10
There appears to be a problem with the order of operations. I'm going to look into fixing that.
ap...@google.com <ap...@google.com> #11
Branch: androidx-main
commit e57dd5f9ac6cbb8cf83b221e2d5b3fbd3e88ce6b
Author: George Mount <mount@google.com>
Date: Thu Nov 09 14:33:53 2023
Fix animateToStart with Slide.
Fixes: 300157785
Slide was not repositioning the View to its proper
translation after animating it to the start position.
This fixes that so that it is moved.
Test: new test
Change-Id: I698f4dbcef46304f9aa545847d205f7b70c80d63
M transition/transition/src/androidTest/java/androidx/transition/SlideEdgeTest.java
M transition/transition/src/androidTest/java/androidx/transition/TranslationAnimationCreatorTest.java
M transition/transition/src/main/java/androidx/transition/TranslationAnimationCreator.java
ap...@google.com <ap...@google.com> #12
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.transition:transition:1.5.0-alpha05
ap...@google.com <ap...@google.com> #13
Branch: androidx-main
commit e7aad89323a8f7be4593b6b459e6c08696211e39
Author: Marcello Galhardo <mgalhardo@google.com>
Date: Wed Feb 21 18:03:35 2024
Move `ViewModel` tests to `commonTest`
* Migrate all tests, except `ViewModelProviderTest` to `commonTest`.
* Replace `truth` usage for `kruth`.
* Tests dependencies are shared between `androidUnitTest` and `androidInstrumentedTest` by using a `jvmTest` common ancestor.
Bug: 214568825
Test: ./gradlew :lifecycle:lifecycle-viewmodel:testDebugUnitTest
Test: ./gradlew :lifecycle:lifecycle-viewmodel:macosArm64Test
Change-Id: I1c55193640ceb92839c79363637fbed08b020d9a
M lifecycle/lifecycle-viewmodel/build.gradle
M lifecycle/lifecycle-viewmodel/src/androidInstrumentedTest/kotlin/androidx/lifecycle/AndroidViewModelFactoryTest.kt
M lifecycle/lifecycle-viewmodel/src/androidInstrumentedTest/kotlin/androidx/lifecycle/CreationExtrasTest.kt
M lifecycle/lifecycle-viewmodel/src/androidInstrumentedTest/kotlin/androidx/lifecycle/ViewModelScopeTest.kt
M lifecycle/lifecycle-viewmodel/src/androidInstrumentedTest/kotlin/androidx/lifecycle/ViewTreeViewModelStoreOwnerTest.kt
A lifecycle/lifecycle-viewmodel/src/androidUnitTest/kotlin/androidx/lifecycle/MockViewModelStoreTest.kt
A lifecycle/lifecycle-viewmodel/src/androidUnitTest/kotlin/androidx/lifecycle/MockViewModelTest.kt
D lifecycle/lifecycle-viewmodel/src/androidUnitTest/kotlin/androidx/lifecycle/ViewModelLazyTest.kt
D lifecycle/lifecycle-viewmodel/src/androidUnitTest/kotlin/androidx/lifecycle/ViewModelProviderReifiedTest.kt
M lifecycle/lifecycle-viewmodel/src/androidUnitTest/kotlin/androidx/lifecycle/ViewModelProviderTest.kt
D lifecycle/lifecycle-viewmodel/src/androidUnitTest/kotlin/androidx/lifecycle/ViewModelStoreTest.kt
D lifecycle/lifecycle-viewmodel/src/androidUnitTest/kotlin/androidx/lifecycle/ViewModelTest.kt
A lifecycle/lifecycle-viewmodel/src/commonTest/kotlin/androidx/lifecycle/ViewModelLazyTest.kt
A lifecycle/lifecycle-viewmodel/src/commonTest/kotlin/androidx/lifecycle/ViewModelProviderGetTest.kt
A lifecycle/lifecycle-viewmodel/src/commonTest/kotlin/androidx/lifecycle/ViewModelStoreTest.kt
A lifecycle/lifecycle-viewmodel/src/commonTest/kotlin/androidx/lifecycle/ViewModelTest.kt
M lifecycle/lifecycle-viewmodel/src/commonTest/kotlin/androidx/lifecycle/viewmodel/ViewModelInitializerTest.kt
ap...@google.com <ap...@google.com> #14
Branch: androidx-main
commit a9db8a527af2df6402d9ffd2358e983360eacf5e
Author: Marcello Galhardo <mgalhardo@google.com>
Date: Fri Feb 23 10:33:42 2024
Add tests for `NewInstanceFactory`
* Adds new tests for `NewInstanceFactoryTest`. Previously, it was tested in `ViewModelProviderTest` but that is not possible anymore - as `NewInstanceFactory` is Android-only and `ViewModelProviderTest` is in common.
Bug: 214568825
Test: ./gradlew :lifecycle:lifecycle-viewmodel:testDebugUnitTest
Test: ./gradlew :lifecycle:lifecycle-viewmodel:macosArm64Test
Change-Id: Ie3d33f8c46b46c0f7be595f430618cb7d8ec77e8
A lifecycle/lifecycle-viewmodel/src/androidUnitTest/kotlin/androidx/lifecycle/NewInstanceFactoryTest.kt
ap...@google.com <ap...@google.com> #15
Branch: androidx-main
commit 084be9db68c065e7a1d3cdd6394728b38fdb5b93
Author: Marcello Galhardo <mgalhardo@google.com>
Date: Fri Feb 23 10:32:35 2024
Add tests for `DefaultViewModelProviderFactory`
* Adds tests for `DefaultViewModelProviderFactory` for both Native and JVM targets.
* Native and Jvm targets have different implementations, as we can't instantiate a `ViewModel` using the no-args constructor without including `kotlin-reflect-full` on native.
Bug: 214568825
Test: ./gradlew :lifecycle:lifecycle-viewmodel:testDebugUnitTest
Test: ./gradlew :lifecycle:lifecycle-viewmodel:macosArm64Test
Change-Id: I178188c783bd1df20decda867373bffa574e53f5
A lifecycle/lifecycle-viewmodel/src/jvmTest/kotlin/androidx/lifecycle/viewmodel/internal/DefaultViewModelProviderFactoryTest.kt
A lifecycle/lifecycle-viewmodel/src/nativeTest/kotlin/androidx/lifecycle/viewmodel/internal/DefaultViewModelProviderFactoryTest.kt
ap...@google.com <ap...@google.com> #16
Branch: androidx-main
commit 82839d3c84556c50c102615688aa1416570339a3
Author: Marcello Galhardo <mgalhardo@google.com>
Date: Fri Feb 23 10:31:16 2024
Add tests for `getDefaultFactory` and `getDefaultExtras`
* Adds tests for common functions `ViewModelProviders.getDefaultFactory` and `ViewModelProviders.getDefaultExtras`, as those default parameters are not called in the `ViewModelProviderTest`.
Bug: 214568825
Test: ./gradlew :lifecycle:lifecycle-viewmodel:testDebugUnitTest
Test: ./gradlew :lifecycle:lifecycle-viewmodel:macosArm64Test
Change-Id: I6157cb514fd6c72e5c17d4f506a1e70a9aab0d2a
A lifecycle/lifecycle-viewmodel/src/commonTest/kotlin/androidx/lifecycle/viewmodel/internal/ViewModelProvidersTest.kt
ap...@google.com <ap...@google.com> #17
Branch: androidx-main
commit 0cbcf323605e7cd63a4fd92fb61f579be4f36e3b
Author: Marcello Galhardo <mgalhardo@google.com>
Date: Thu Feb 22 15:30:28 2024
Move `ViewModelProvider` tests to `commonTest`
* Migrates `ViewModelProviderTest` to `commonTest`.
Bug: 214568825
Test: ./gradlew :lifecycle:lifecycle-viewmodel:testDebugUnitTest
Test: ./gradlew :lifecycle:lifecycle-viewmodel:macosArm64Test
Change-Id: Ieb45f565ff79c133fb1f614a7f9a5c3b4d1705e0
D lifecycle/lifecycle-viewmodel/src/androidUnitTest/kotlin/androidx/lifecycle/ViewModelProviderTest.kt
A lifecycle/lifecycle-viewmodel/src/commonTest/kotlin/androidx/lifecycle/ViewModelProviderTest.kt
ap...@google.com <ap...@google.com> #18
Branch: androidx-main
commit 6c9d9f858cf59ddecf53027c80a36e180006c3b8
Author: Marcello Galhardo <mgalhardo@google.com>
Date: Mon Feb 26 10:33:05 2024
Set native `ViewModelProvider.Factory` to throw `UnsupportedOperationException`
* `ViewModelProvider.Factory.create` has a default implementation to maintain compatibility with the Android target; but should be directly implemented by any caller.
* Invoking `ViewModelProvider.Factory.create` now throws an exception from all platforms.
Bug: 214568825
Test: ./gradlew :lifecycle:lifecycle-viewmodel:checkApi
Test: ./gradlew :lifecycle:lifecycle-viewmodel:connectedDebugAndroidTest
Test: ./gradlew :lifecycle:lifecycle-viewmodel:testDebugUnitTest
Change-Id: I6fcd5ee66184d74bd885a6618d3ceacbd7b7da2f
M lifecycle/lifecycle-viewmodel/src/commonMain/kotlin/androidx/lifecycle/ViewModelProvider.kt
M lifecycle/lifecycle-viewmodel/src/commonMain/kotlin/androidx/lifecycle/viewmodel/internal/ViewModelProviderImpl.kt
M lifecycle/lifecycle-viewmodel/src/commonMain/kotlin/androidx/lifecycle/viewmodel/internal/ViewModelProviders.kt
M lifecycle/lifecycle-viewmodel/src/nativeMain/kotlin/androidx/lifecycle/ViewModelProvider.native.kt
M lifecycle/lifecycle-viewmodel/src/nativeTest/kotlin/androidx/lifecycle/viewmodel/internal/DefaultViewModelProviderFactoryTest.kt
ap...@google.com <ap...@google.com> #19
Branch: androidx-main
commit 9e09262d2635d2dcc6b64c2b531230e5c5627561
Author: Marcello Galhardo <mgalhardo@google.com>
Date: Mon Feb 26 11:39:32 2024
Remove `atomicfu` from `viewmodel`
* JVM targets will use the default JVM `synchronized`, while native will fallback to `atomicfu` implementation.
* See [here](
Bug: 214568825
Test: ./gradlew :lifecycle:lifecycle-viewmodel:checkApi
Test: ./gradlew :lifecycle:lifecycle-viewmodel:connectedDebugAndroidTest
Test: ./gradlew :lifecycle:lifecycle-viewmodel:testDebugUnitTest
Change-Id: I091c74361c13f434ffaaa6d124a7f972ced38bed
M lifecycle/lifecycle-viewmodel/build.gradle
A lifecycle/lifecycle-viewmodel/src/commonMain/kotlin/androidx/lifecycle/viewmodel/internal/Lock.kt
M lifecycle/lifecycle-viewmodel/src/commonMain/kotlin/androidx/lifecycle/viewmodel/internal/ViewModelImpl.kt
A lifecycle/lifecycle-viewmodel/src/darwinMain/kotlin/androidx/lifecycle/viewmodel/internal/Lock.native.darwin.kt
A lifecycle/lifecycle-viewmodel/src/jvmMain/kotlin/androidx/lifecycle/viewmodel/internal/Lock.jvm.kt
A lifecycle/lifecycle-viewmodel/src/linuxMain/kotlin/androidx/lifecycle/viewmodel/internal/Lock.native.linux.kt
A lifecycle/lifecycle-viewmodel/src/nativeMain/kotlin/androidx/lifecycle/viewmodel/internal/Lock.native.kt
ap...@google.com <ap...@google.com> #20
Branch: androidx-main
commit 1eebb19e3f060d9f76522923adc019701858d371
Author: Marcello Galhardo <mgalhardo@google.com>
Date: Mon Feb 26 11:04:19 2024
Add a public `VIEW_MODEL_KEY` to `ViewModelProvider`
RelNote: "Expose `VIEW_MODEL_KEY` as a public property. `VIEW_MODEL_KEY` will be used by other platforms to integrate with `lifecycle-viewmodel` artifact."
Bug: 214568825
Test: ./gradlew :lifecycle:lifecycle-viewmodel:checkApi
Test: ./gradlew :lifecycle:lifecycle-viewmodel:connectedDebugAndroidTest
Test: ./gradlew :lifecycle:lifecycle-viewmodel:testDebugUnitTest
Change-Id: I8143b0d63c8d7efb16b4ec2d71e66754908d9545
M lifecycle/lifecycle-viewmodel/api/current.txt
M lifecycle/lifecycle-viewmodel/api/restricted_current.txt
M lifecycle/lifecycle-viewmodel/src/androidMain/kotlin/androidx/lifecycle/ViewModelProvider.android.kt
M lifecycle/lifecycle-viewmodel/src/commonMain/kotlin/androidx/lifecycle/ViewModelProvider.kt
M lifecycle/lifecycle-viewmodel/src/desktopMain/kotlin/androidx/lifecycle/ViewModelProvider.desktop.kt
M lifecycle/lifecycle-viewmodel/src/nativeMain/kotlin/androidx/lifecycle/ViewModelProvider.native.kt
ap...@google.com <ap...@google.com> #21
Branch: androidx-main
commit b7639a1c78da27755a2f7c05e16039a25689da05
Author: Ivan Matkov <ivan.matkov@jetbrains.com>
Date: Fri Feb 23 12:42:55 2024
Align source sets in lifecycle-viewmodel with JetBrains fork
- Move shared code into `nonJvmMain` (a common source set for native and web targets)
- Use expect/actual for `qualifiedName`
- Remove `macEnabled`/`linuxEnabled` conditions as it's enabled by default now
Bug: 214568825
Test: N/A
Change-Id: I3623f265fed7bd2db3c934a48c7dbbc865d94f22
M lifecycle/lifecycle-viewmodel/build.gradle
M lifecycle/lifecycle-viewmodel/src/commonMain/kotlin/androidx/lifecycle/viewmodel/internal/ViewModelProviders.kt
M lifecycle/lifecycle-viewmodel/src/darwinMain/kotlin/androidx/lifecycle/viewmodel/internal/Lock.darwin.kt
A lifecycle/lifecycle-viewmodel/src/jvmMain/kotlin/androidx/lifecycle/viewmodel/internal/ViewModelProviders.jvm.kt
M lifecycle/lifecycle-viewmodel/src/linuxMain/kotlin/androidx/lifecycle/viewmodel/internal/Lock.linux.kt
A lifecycle/lifecycle-viewmodel/src/nativeMain/kotlin/androidx/lifecycle/viewmodel/internal/ViewModelProviders.native.kt
M lifecycle/lifecycle-viewmodel/src/nonJvmMain/kotlin/androidx/lifecycle/ViewModel.nonJvm.kt
M lifecycle/lifecycle-viewmodel/src/nonJvmMain/kotlin/androidx/lifecycle/ViewModelProvider.nonJvm.kt
M lifecycle/lifecycle-viewmodel/src/nonJvmMain/kotlin/androidx/lifecycle/viewmodel/InitializerViewModelFactory.nonJvm.kt
M lifecycle/lifecycle-viewmodel/src/nonJvmMain/kotlin/androidx/lifecycle/viewmodel/internal/DefaultViewModelProviderFactory.nonJvm.kt
eg...@gmail.com <eg...@gmail.com> #22
Hello, is it possible to make clear
method not internal?
A lot of kmp libraries creates own version ViewModel due to this method is not accessible outside.
mg...@google.com <mg...@google.com> #23
mg...@google.com <mg...@google.com> #24
Hey
mg...@google.com <mg...@google.com>
pr...@google.com <pr...@google.com> #25
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.lifecycle:lifecycle-viewmodel:2.8.0-alpha03
androidx.lifecycle:lifecycle-viewmodel-android:2.8.0-alpha03
ap...@google.com <ap...@google.com> #26
Branch: androidx-main
commit 338c9cb8cd7027d77e2686832bebd157604c0718
Author: Marcello Galhardo <mgalhardo@google.com>
Date: Thu Mar 28 16:08:13 2024
Use `canonicalName` for `InitializerViewModelFactoryBuilder`
Test: `lifecycle-viewmodel` tests
Bug: 214568825
Change-Id: I9dc55b018de39b8c766d4f9bd7bb9c45212076c7
M lifecycle/lifecycle-viewmodel/src/commonMain/kotlin/androidx/lifecycle/viewmodel/InitializerViewModelFactory.kt
ap...@google.com <ap...@google.com> #27
Branch: androidx-main
commit bfa95f2a028916a70b45114cc3c32b42da8b9a7e
Author: Marcello Galhardo <mgalhardo@google.com>
Date: Thu Mar 28 15:18:59 2024
Align multiplatform `lock` with `synchronized` semantics in `viewmodel`
* Replaces `Lock` usage in `viewmodel` with `synchronized` semantics to reduce confusion with `ReentrantLock` and provide a more intuitive behaviour.
* Adopts the structure of `SynchronizedObject`, `synchronized`, and `synchronizedImpl` from `kotlin.coroutines.internal` to maintain consistency.
* Implements a workaround for the Kotlin issue KT-29963 (
Test: `lifecycle-viewmodel` tests
Bug: 214568825
Change-Id: I43c7a0dd4d6b5eac0e273f62b6d462188f96a0c2
M lifecycle/lifecycle-viewmodel/build.gradle
M lifecycle/lifecycle-viewmodel/src/commonMain/kotlin/androidx/lifecycle/ViewModel.kt
D lifecycle/lifecycle-viewmodel/src/commonMain/kotlin/androidx/lifecycle/viewmodel/internal/Lock.kt
A lifecycle/lifecycle-viewmodel/src/commonMain/kotlin/androidx/lifecycle/viewmodel/internal/SynchronizedObject.kt
M lifecycle/lifecycle-viewmodel/src/commonMain/kotlin/androidx/lifecycle/viewmodel/internal/ViewModelImpl.kt
M lifecycle/lifecycle-viewmodel/src/jvmMain/kotlin/androidx/lifecycle/viewmodel/internal/SynchronizedObject.jvm.kt
M lifecycle/lifecycle-viewmodel/src/nativeMain/kotlin/androidx/lifecycle/viewmodel/internal/SynchronizedObject.native.kt
na...@google.com <na...@google.com> #28
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.lifecycle:lifecycle-viewmodel:2.8.0-beta01
androidx.lifecycle:lifecycle-viewmodel-android:2.8.0-beta01
androidx.lifecycle:lifecycle-viewmodel-desktop:2.8.0-beta01
androidx.lifecycle:lifecycle-viewmodel-iosarm64:2.8.0-beta01
androidx.lifecycle:lifecycle-viewmodel-iossimulatorarm64:2.8.0-beta01
androidx.lifecycle:lifecycle-viewmodel-iosx64:2.8.0-beta01
androidx.lifecycle:lifecycle-viewmodel-linuxx64:2.8.0-beta01
androidx.lifecycle:lifecycle-viewmodel-macosarm64:2.8.0-beta01
androidx.lifecycle:lifecycle-viewmodel-macosx64:2.8.0-beta01
pa...@gmail.com <pa...@gmail.com> #29
I couldn't find if there is a separate issue for this, but we should probably also port lifecycle-viewmodel-kts
to KMP.
In the current 2.8.0-beta01
, it's still defined only as an android library only:
Let me know if we need a new issue ticket for this piece of work :)
il...@google.com <il...@google.com> #30
Re -ktx
modules are empty. You should just use the base artifacts.
Description
I am using compose-jb to make my app multiplatform, but I can't use ViewModel in my desktop app, I am trying to keep the same code for both platforms, but ViewModel is not available.
Going through the code, most of the classes can be easily made multiplatform.
ViewModelStore and ViewModel can be used very easy in desktop+android because of JVM.
Right now I have to create my own library that uses expect in the common module and copy paste the code from the source file to actual JVM implementation.