use of android.transition.Transition in project UltimateAndroid by cymcsg.
the class DetailActivity3 method setupExitAnimations.
private void setupExitAnimations() {
Transition sharedElementReturnTransition = getWindow().getSharedElementReturnTransition();
sharedElementReturnTransition.setStartDelay(ANIM_DURATION);
Transition returnTransition = getWindow().getReturnTransition();
returnTransition.setDuration(ANIM_DURATION);
returnTransition.addListener(new Transition.TransitionListener() {
@Override
public void onTransitionStart(Transition transition) {
animateRevealHide(bgViewGroup);
}
@Override
public void onTransitionEnd(Transition transition) {
}
@Override
public void onTransitionCancel(Transition transition) {
}
@Override
public void onTransitionPause(Transition transition) {
}
@Override
public void onTransitionResume(Transition transition) {
}
});
}
use of android.transition.Transition in project plaid by nickbutcher.
the class FeedAdapter method setGridItemContentTransitions.
/**
* The shared element transition to dribbble shots & dn stories can intersect with the FAB.
* This can cause a strange layers-passing-through-each-other effect. On return hide the FAB
* and animate it back in after the transition.
*/
private void setGridItemContentTransitions(View gridItem) {
final View fab = host.findViewById(R.id.fab);
if (!ViewUtils.viewsIntersect(gridItem, fab))
return;
Transition reenter = TransitionInflater.from(host).inflateTransition(R.transition.grid_overlap_fab_reenter);
reenter.addListener(new TransitionUtils.TransitionListenerAdapter() {
@Override
public void onTransitionEnd(Transition transition) {
// we only want these content transitions in certain cases so clear out when done.
host.getWindow().setReenterTransition(null);
}
});
host.getWindow().setReenterTransition(reenter);
}
use of android.transition.Transition in project android_frameworks_base by ResurrectionRemix.
the class BackStackRecord method configureTransitions.
/**
* Configures custom transitions for a specific fragment container.
*
* @param containerId The container ID of the fragments to configure the transition for.
* @param state The Transition State keeping track of the executing transitions.
* @param firstOutFragments The list of first fragments to be removed, keyed on the
* container ID.
* @param lastInFragments The list of last fragments to be added, keyed on the
* container ID.
* @param isBack true if this is popping the back stack or false if this is a
* forward operation.
*/
private void configureTransitions(int containerId, TransitionState state, boolean isBack, SparseArray<Fragment> firstOutFragments, SparseArray<Fragment> lastInFragments) {
ViewGroup sceneRoot = (ViewGroup) mManager.mContainer.onFindViewById(containerId);
if (sceneRoot != null) {
Fragment inFragment = lastInFragments.get(containerId);
Fragment outFragment = firstOutFragments.get(containerId);
Transition enterTransition = getEnterTransition(inFragment, isBack);
TransitionSet sharedElementTransition = getSharedElementTransition(inFragment, outFragment, isBack);
Transition exitTransition = getExitTransition(outFragment, isBack);
if (enterTransition == null && sharedElementTransition == null && exitTransition == null) {
// no transitions!
return;
}
if (enterTransition != null) {
enterTransition.addTarget(state.nonExistentView);
}
ArrayMap<String, View> namedViews = null;
ArrayList<View> sharedElementTargets = new ArrayList<View>();
if (sharedElementTransition != null) {
namedViews = remapSharedElements(state, outFragment, isBack);
setSharedElementTargets(sharedElementTransition, state.nonExistentView, namedViews, sharedElementTargets);
// Notify the start of the transition.
SharedElementCallback callback = isBack ? outFragment.mEnterTransitionCallback : inFragment.mEnterTransitionCallback;
ArrayList<String> names = new ArrayList<String>(namedViews.keySet());
ArrayList<View> views = new ArrayList<View>(namedViews.values());
callback.onSharedElementStart(names, views, null);
}
ArrayList<View> exitingViews = captureExitingViews(exitTransition, outFragment, namedViews, state.nonExistentView);
if (exitingViews == null || exitingViews.isEmpty()) {
exitTransition = null;
}
excludeViews(enterTransition, exitTransition, exitingViews, true);
excludeViews(enterTransition, sharedElementTransition, sharedElementTargets, true);
excludeViews(exitTransition, sharedElementTransition, sharedElementTargets, true);
// Set the epicenter of the exit transition
if (mSharedElementTargetNames != null && namedViews != null) {
View epicenterView = namedViews.get(mSharedElementTargetNames.get(0));
if (epicenterView != null) {
if (exitTransition != null) {
setEpicenter(exitTransition, epicenterView);
}
if (sharedElementTransition != null) {
setEpicenter(sharedElementTransition, epicenterView);
}
}
}
Transition transition = mergeTransitions(enterTransition, exitTransition, sharedElementTransition, inFragment, isBack);
if (transition != null) {
ArrayList<View> hiddenFragments = new ArrayList<View>();
ArrayList<View> enteringViews = addTransitionTargets(state, enterTransition, sharedElementTransition, exitTransition, transition, sceneRoot, inFragment, outFragment, hiddenFragments, isBack, sharedElementTargets);
transition.setNameOverrides(state.nameOverrides);
// We want to exclude hidden views later, so we need a non-null list in the
// transition now.
transition.excludeTarget(state.nonExistentView, true);
// Now exclude all currently hidden fragments.
excludeHiddenFragments(hiddenFragments, containerId, transition);
TransitionManager.beginDelayedTransition(sceneRoot, transition);
// Remove the view targeting after the transition starts
removeTargetedViewsFromTransitions(sceneRoot, state.nonExistentView, enterTransition, enteringViews, exitTransition, exitingViews, sharedElementTransition, sharedElementTargets, transition, hiddenFragments);
}
}
}
use of android.transition.Transition in project android_frameworks_base by ResurrectionRemix.
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.Transition in project android_frameworks_base by ResurrectionRemix.
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));
}
}
}
}
Aggregations