use of android.transition.TransitionSet in project android_frameworks_base by AOSPA.
the class PhoneWindow method getTransition.
private Transition getTransition(Transition currentValue, Transition defaultValue, int id) {
if (currentValue != defaultValue) {
return currentValue;
}
int transitionId = getWindowStyle().getResourceId(id, -1);
Transition transition = defaultValue;
if (transitionId != -1 && transitionId != R.transition.no_transition) {
TransitionInflater inflater = TransitionInflater.from(getContext());
transition = inflater.inflateTransition(transitionId);
if (transition instanceof TransitionSet && ((TransitionSet) transition).getTransitionCount() == 0) {
transition = null;
}
}
return transition;
}
use of android.transition.TransitionSet in project android_frameworks_base by AOSPA.
the class Fragment method loadTransition.
private static Transition loadTransition(Context context, TypedArray typedArray, Transition currentValue, Transition defaultValue, int id) {
if (currentValue != defaultValue) {
return currentValue;
}
int transitionId = typedArray.getResourceId(id, 0);
Transition transition = defaultValue;
if (transitionId != 0 && transitionId != com.android.internal.R.transition.no_transition) {
TransitionInflater inflater = TransitionInflater.from(context);
transition = inflater.inflateTransition(transitionId);
if (transition instanceof TransitionSet && ((TransitionSet) transition).getTransitionCount() == 0) {
transition = null;
}
}
return transition;
}
use of android.transition.TransitionSet in project android_frameworks_base by DirtyUnicorns.
the class BackStackRecord method addTargets.
/**
* This method adds views as targets to the transition, but only if the transition
* doesn't already have a target. It is best for views to contain one View object
* that does not exist in the view hierarchy (state.nonExistentView) so that
* when they are removed later, a list match will suffice to remove the targets.
* Otherwise, if you happened to have targeted the exact views for the transition,
* the removeTargets call will remove them unexpectedly.
*/
public static void addTargets(Transition transition, ArrayList<View> views) {
if (transition instanceof TransitionSet) {
TransitionSet set = (TransitionSet) transition;
int numTransitions = set.getTransitionCount();
for (int i = 0; i < numTransitions; i++) {
Transition child = set.getTransitionAt(i);
addTargets(child, views);
}
} else if (!hasSimpleTarget(transition)) {
List<View> targets = transition.getTargets();
if (isNullOrEmpty(targets)) {
// We can just add the target views
int numViews = views.size();
for (int i = 0; i < numViews; i++) {
transition.addTarget(views.get(i));
}
}
}
}
use of android.transition.TransitionSet in project android_frameworks_base by DirtyUnicorns.
the class BackStackRecord method mergeTransitions.
private static Transition mergeTransitions(Transition enterTransition, Transition exitTransition, Transition sharedElementTransition, Fragment inFragment, boolean isBack) {
boolean overlap = true;
if (enterTransition != null && exitTransition != null && inFragment != null) {
overlap = isBack ? inFragment.getAllowReturnTransitionOverlap() : inFragment.getAllowEnterTransitionOverlap();
}
// Wrap the transitions. Explicit targets like in enter and exit will cause the
// views to be targeted regardless of excluded views. If that happens, then the
// excluded fragments views (hidden fragments) will still be in the transition.
Transition transition;
if (overlap) {
// Regular transition -- do it all together
TransitionSet transitionSet = new TransitionSet();
if (enterTransition != null) {
transitionSet.addTransition(enterTransition);
}
if (exitTransition != null) {
transitionSet.addTransition(exitTransition);
}
if (sharedElementTransition != null) {
transitionSet.addTransition(sharedElementTransition);
}
transition = transitionSet;
} else {
// First do exit, then enter, but allow shared element transition to happen
// during both.
Transition staggered = null;
if (exitTransition != null && enterTransition != null) {
staggered = new TransitionSet().addTransition(exitTransition).addTransition(enterTransition).setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
} else if (exitTransition != null) {
staggered = exitTransition;
} else if (enterTransition != null) {
staggered = enterTransition;
}
if (sharedElementTransition != null) {
TransitionSet together = new TransitionSet();
if (staggered != null) {
together.addTransition(staggered);
}
together.addTransition(sharedElementTransition);
transition = together;
} else {
transition = staggered;
}
}
return transition;
}
use of android.transition.TransitionSet in project android_frameworks_base by DirtyUnicorns.
the class BackStackRecord method getSharedElementTransition.
private static TransitionSet getSharedElementTransition(Fragment inFragment, Fragment outFragment, boolean isBack) {
if (inFragment == null || outFragment == null) {
return null;
}
Transition transition = cloneTransition(isBack ? outFragment.getSharedElementReturnTransition() : inFragment.getSharedElementEnterTransition());
if (transition == null) {
return null;
}
TransitionSet transitionSet = new TransitionSet();
transitionSet.addTransition(transition);
return transitionSet;
}
Aggregations