Status Update
Comments
jb...@google.com <jb...@google.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).
jv...@gmail.com <jv...@gmail.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().
il...@google.com <il...@google.com>
an...@immobiliare.it <an...@immobiliare.it> #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).
sa...@google.com <sa...@google.com>
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
il...@google.com <il...@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.
il...@google.com <il...@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
na...@google.com <na...@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.
Description
- **androix.fragment**: `androidx.fragment:fragment:1.3.6`
- **androix.activity**: `androidx.activity:activity:1.2.4`
Devices/Android versions reproduced on: Samsung Galaxy S10 Lite
**Issue**
When multiple activities are launched sequentially from a fragment using the deprecated API `Fragment.startActivityForResult`, the order of launch is well defined but the calls back to `Fragment.onActivityResult` get messed up when all the started activities `setResult` and finish.
As it can be noticed in the logs below, `ResultActivity1` is started with `requestCode=1111` and `ResultActivity2` with `requestCode=2222`, but when both activities set result and dismiss, `onActivityResult` is called with `ResultActivity2` but `requestCode` of `ResultActivity1` and the same for `ResultActivity1`.
```
17:17:52.050 E startActivityForResult: me.jansv.ari.ResultActivity1{requestCode=1111}
17:17:52.187 E startActivityForResult: me.jansv.ari.ResultActivity2{requestCode=2222}
17:17:57.055 E onActivityResult: requestCode=1111, resultCode=-1, extras={ResultActivity2=ResultActivity2.value}
17:17:57.055 E onActivityResult: requestCode=2222, resultCode=-1, extras={ResultActivity1=ResultActivity1.value}
```
**Steps to reproduce**
Using the sample project, click rapidly and in order buttons `Activity 1` and `Activity 2`, then click `Set Result 2` followed by `Set Result 1`.
This is possible in the context of translucent activities that allow click-through or when some delay at starting the first activity allows the click on the second button to trigger.
**Potential cause**
When `Fragment.startActivityForResult` is called, it [register](
This means that if the state of the queue is something like: `{meta{requestCode=1111}, meta{requestCode=2222}}` for sequential launch of `ResultActivity1`, `ResultActivity2`. If `ResultActivity2` set result first, then, we'll endup with `meta{requestCode=1111}` and `ActivityResult` from `ResultActivity2`.