use of android.transition.TransitionSet in project platform_frameworks_base by android.
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;
}
use of android.transition.TransitionSet in project platform_frameworks_base by android.
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 platform_frameworks_base by android.
the class ActivityTransitionCoordinator method setTargets.
protected Transition setTargets(Transition transition, boolean add) {
if (transition == null || (add && (mTransitioningViews == null || mTransitioningViews.isEmpty()))) {
return null;
}
// Add the targets to a set containing transition so that transition
// remains unaffected. We don't want to modify the targets of transition itself.
TransitionSet set = new TransitionSet();
if (mTransitioningViews != null) {
for (int i = mTransitioningViews.size() - 1; i >= 0; i--) {
View view = mTransitioningViews.get(i);
if (add) {
set.addTarget(view);
} else {
set.excludeTarget(view, true);
}
}
}
// By adding the transition after addTarget, we prevent addTarget from
// affecting transition.
set.addTransition(transition);
if (!add && mTransitioningViews != null && !mTransitioningViews.isEmpty()) {
// Allow children of excluded transitioning views, but not the views themselves
set = new TransitionSet().addTransition(set);
}
return set;
}
use of android.transition.TransitionSet in project platform_frameworks_base by android.
the class PopupWindow method getTransition.
private Transition getTransition(int resId) {
if (resId != 0 && resId != R.transition.no_transition) {
final TransitionInflater inflater = TransitionInflater.from(mContext);
final Transition transition = inflater.inflateTransition(resId);
if (transition != null) {
final boolean isEmpty = transition instanceof TransitionSet && ((TransitionSet) transition).getTransitionCount() == 0;
if (!isEmpty) {
return transition;
}
}
}
return null;
}
use of android.transition.TransitionSet in project android_frameworks_base by ResurrectionRemix.
the class CrossfadeMultiple method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.crossfade_multiple);
ViewGroup container = (ViewGroup) findViewById(R.id.container);
mSceneRoot = container;
mButton = (Button) findViewById(R.id.button);
mImageView = (ImageView) findViewById(R.id.imageview);
mTextView = (TextView) findViewById(R.id.textview);
mCrossfade = new Crossfade();
mCrossfade.addTarget(R.id.button).addTarget(R.id.textview).addTarget(R.id.imageview);
mCrossfadeGroup = new TransitionSet();
mCrossfadeGroup.setDuration(300);
mCrossfadeGroup.addTransition(mCrossfade).addTransition(new ChangeBounds());
mTransition = mCrossfadeGroup;
mInOutGroup = new TransitionSet();
Crossfade inOut = new Crossfade();
inOut.setDuration(300);
inOut.setFadeBehavior(Crossfade.FADE_BEHAVIOR_OUT_IN);
ChangeBounds changeBounds = new ChangeBounds();
changeBounds.setStartDelay(150);
changeBounds.setDuration(0);
mInOutGroup.addTransition(inOut).addTransition(changeBounds);
mTextChangeGroup1 = new TransitionSet();
ChangeText changeTextInOut = new ChangeText();
changeTextInOut.setChangeBehavior(ChangeText.CHANGE_BEHAVIOR_OUT_IN);
mTextChangeGroup1.addTransition(changeTextInOut).addTransition(new ChangeBounds());
mTextChangeGroup2 = new TransitionSet();
mTextChangeGroup2.setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
ChangeText changeTextOut = new ChangeText();
changeTextOut.setChangeBehavior(ChangeText.CHANGE_BEHAVIOR_OUT);
mTextChangeGroup2.addTransition(changeTextOut).addTransition(new ChangeBounds());
mTextChangeGroup3 = new TransitionSet();
mTextChangeGroup3.setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
ChangeText changeTextIn = new ChangeText();
changeTextIn.setChangeBehavior(ChangeText.CHANGE_BEHAVIOR_IN);
mTextChangeGroup3.addTransition(changeTextIn).addTransition(new ChangeBounds());
}
Aggregations