Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
> The Transition Kotlin extensions target the Framework Transition class which is a bit confusing
All extensions in 'core-ktx' target either 'core' or the framework types. This is working as expected. It sounds like this is a feature request for a transition-ktx with equivalent extensions for the androidx.transition types.
> as most framework classes are being deprecated in favor of their AndroidX counterparts, Fragments for example.
"Most"? This *dramatically* overstates what is actually happening. Fragments (and loaders) were added to the framework in a time where the Android team did not have external libraries for shipping features. Transition was added 5 years later.
All extensions in 'core-ktx' target either 'core' or the framework types. This is working as expected. It sounds like this is a feature request for a transition-ktx with equivalent extensions for the androidx.transition types.
> as most framework classes are being deprecated in favor of their AndroidX counterparts, Fragments for example.
"Most"? This *dramatically* overstates what is actually happening. Fragments (and loaders) were added to the framework in a time where the Android team did not have external libraries for shipping features. Transition was added 5 years later.
an...@google.com <an...@google.com>
an...@google.com <an...@google.com> #3
Pardon my misunderstanding, I was under the belief that where possible, new features that could be developed outside the framework, would be under Androidx. Also it's a common refrain to use the Androidx libraries over the framework libraries where possible, as those ship update independently of platform releases. I wasn't attempting to be dramatic.
If the Transition api is unlikely to change, there is no need for a transition-ktx for androidx.transition types. If developers should use Androidx transitions over framework transitions where possible however, then it would be much appreciated.
I am well aware of the limitations that existed when Fragments and Loaders were created, and when the Transition api was introduced.
If the Transition api is unlikely to change, there is no need for a transition-ktx for androidx.transition types. If developers should use Androidx transitions over framework transitions where possible however, then it would be much appreciated.
I am well aware of the limitations that existed when Fragments and Loaders were created, and when the Transition api was introduced.
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