Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 1d99479f78c11b2a5189dd1b96811f469682dea8
Author: Andrey Kulikov <andreykulikov@google.com>
Date: Tue Oct 23 15:31:38 2018
Improve AndroidX TransitionSet behavior
1) Allow override values for a children of TransitionSet. For example for usages like this:
TransitionSet set = new TransitionSet().setDuration(300);
Fade fade = new Fade();
set.addTransition(fade);
fade.setDuration(100);
The result duration applied for fade transition is still 300. And it breaks all the flexibility of configuring sets.
The reason of it is clone() method which will be executed in beginDelayedTransition. And as part of clone() implementation of TransitionSet the children will be re-added to the new cloned set and set's duration will be re-applied again. To fix it I changed how we add transitions into set in clone().
2) Recently we had a bug about TransitionSet will crash during inflation if we provide duration for it via xml. I fixed similar issue for applying a part motion.
Test: added new tests for both issues
Bug: 64644617
Change-Id: Ie55dc7bd8c1dffc452988950e3a836afa9b6fa38
M transition/src/androidTest/java/androidx/transition/TransitionInflaterTest.java
M transition/src/androidTest/java/androidx/transition/TransitionSetTest.java
M transition/src/androidTest/res/transition/transition_set.xml
M transition/src/main/java/androidx/transition/TransitionSet.java
https://android-review.googlesource.com/803493
https://goto.google.com/android-sha1/1d99479f78c11b2a5189dd1b96811f469682dea8
Branch: androidx-master-dev
commit 1d99479f78c11b2a5189dd1b96811f469682dea8
Author: Andrey Kulikov <andreykulikov@google.com>
Date: Tue Oct 23 15:31:38 2018
Improve AndroidX TransitionSet behavior
1) Allow override values for a children of TransitionSet. For example for usages like this:
TransitionSet set = new TransitionSet().setDuration(300);
Fade fade = new Fade();
set.addTransition(fade);
fade.setDuration(100);
The result duration applied for fade transition is still 300. And it breaks all the flexibility of configuring sets.
The reason of it is clone() method which will be executed in beginDelayedTransition. And as part of clone() implementation of TransitionSet the children will be re-added to the new cloned set and set's duration will be re-applied again. To fix it I changed how we add transitions into set in clone().
2) Recently we had a bug about TransitionSet will crash during inflation if we provide duration for it via xml. I fixed similar issue for applying a part motion.
Test: added new tests for both issues
Bug: 64644617
Change-Id: Ie55dc7bd8c1dffc452988950e3a836afa9b6fa38
M transition/src/androidTest/java/androidx/transition/TransitionInflaterTest.java
M transition/src/androidTest/java/androidx/transition/TransitionSetTest.java
M transition/src/androidTest/res/transition/transition_set.xml
M transition/src/main/java/androidx/transition/TransitionSet.java
an...@google.com <an...@google.com>
an...@google.com <an...@google.com> #3
Fixed and will be released in androidx.transition:transition:1.1.0-alpha1
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