Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Found the issue, ugh
Noticed that when I do the following:
transaction.addToBackStack(null)
When adding a Fragment with ViewPager2, the above issue occurs, although, idk if it's becaugh of gcFragments() anymore.
As soon as I un-comment that line, the issue disappears.
Noticed that when I do the following:
transaction.addToBackStack(null)
When adding a Fragment with ViewPager2, the above issue occurs, although, idk if it's becaugh of gcFragments() anymore.
As soon as I un-comment that line, the issue disappears.
an...@google.com <an...@google.com>
an...@google.com <an...@google.com> #3
Is the Sample application, to reproduce, move back really fast between page 2 -> 1 and vice versa (they are bottom buttons) a couple times.
Wait a couple seconds and page 1 (the black page) should turn white meaning the Fragment has been removed.
As soon as you comment line 40 on MainActivity, and attempt again, the error does not persist
Description
I think we have two issues with misleading behaviour in android.transition.TransitionSet class.
1) setInterpolator of TransitionSet would not propagate an interpolator into the children transitions
Current implementation:
public TransitionSet setInterpolator(TimeInterpolator interpolator) {
return (TransitionSet) super.setInterpolator(interpolator);
}
How it should be (in the same style as setDuration method):
public TransitionSet setInterpolator(TimeInterpolator interpolator) {
super.setInterpolator(interpolator);
if (mTransitions != null) {
int numTransitions = mTransitions.size();
for (int i = 0; i < numTransitions; ++i) {
mTransitions.get(i).setInterpolator(mInterpolator);
}
}
return this;
}
And then in addTransition we should propagate current interpolator, not only duration
public TransitionSet addTransition(Transition transition) {
if (transition != null) {
mTransitions.add(transition);
transition.mParent = this;
if (mDuration >= 0) {
transition.setDuration(mDuration);
}
if (mInterpolator != null) {
transition.setInterpolator(mInterpolator);
}
}
return this;
}
2) Imagine situation when you have a set:
TransitionSet set = new TransitionSet().setDuration(300);
Then you add a lot of transitions into it (that why you want to specify duration not one by one but only once for the set via .setDuration(300)).
And then you also want to add one more transition but with a smaller duration:
Fade fadeIn = new Fade(Fade.IN);
set.addTransition(fadeIn);
fadeIn.setDuration(100);
But it not works, fadeIn is animating with duration 300.
Its a real usecase, sometimes we need a set with for example a lot of ChangeBounds with the same duration and one visibility in animation with a smaller duration(and one visibility out animation with smaller duration)
The reason of it is a clone method:
public TransitionSet clone() {
TransitionSet clone = (TransitionSet) super.clone();
clone.mTransitions = new ArrayList<Transition>();
int numTransitions = mTransitions.size();
for (int i = 0; i < numTransitions; ++i) {
clone.addTransition((Transition) mTransitions.get(i).clone());
}
return clone;
}
Here we call addTransition where we would override the duration of the transition again.
To fix it I suggest to change the line
clone.addTransition((Transition) mTransitions.get(i).clone());
to:
Transition transition = (Transition) mTransitions.get(i).clone();
clone.mTransitions.add(transition);
transition.mParent = clone;
Thanks,
Both issues were found during the development of transitions backport library Transitions-Everywhere