Search in sources :

Example 46 with TransitionSet

use of android.transition.TransitionSet in project android_frameworks_base by crdroidandroid.

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;
}
Also used : TransitionSet(android.transition.TransitionSet) Transition(android.transition.Transition) TransitionInflater(android.transition.TransitionInflater)

Example 47 with TransitionSet

use of android.transition.TransitionSet in project android_frameworks_base by crdroidandroid.

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;
}
Also used : TransitionSet(android.transition.TransitionSet) Transition(android.transition.Transition)

Example 48 with TransitionSet

use of android.transition.TransitionSet in project android_frameworks_base by crdroidandroid.

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);
        }
    }
}
Also used : TransitionSet(android.transition.TransitionSet) ViewGroup(android.view.ViewGroup) Transition(android.transition.Transition) ArrayList(java.util.ArrayList) View(android.view.View)

Example 49 with TransitionSet

use of android.transition.TransitionSet in project android_frameworks_base by crdroidandroid.

the class BackStackRecord method removeTargets.

/**
     * This method removes the views from transitions that target ONLY those views.
     * The views list should match those added in addTargets and should contain
     * one view that is not in the view hierarchy (state.nonExistentView).
     */
public static void removeTargets(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);
            removeTargets(child, views);
        }
    } else if (!hasSimpleTarget(transition)) {
        List<View> targets = transition.getTargets();
        if (targets != null && targets.size() == views.size() && targets.containsAll(views)) {
            // We have an exact match. We must have added these earlier in addTargets
            for (int i = views.size() - 1; i >= 0; i--) {
                transition.removeTarget(views.get(i));
            }
        }
    }
}
Also used : TransitionSet(android.transition.TransitionSet) Transition(android.transition.Transition) ArrayList(java.util.ArrayList) List(java.util.List)

Example 50 with TransitionSet

use of android.transition.TransitionSet in project android_frameworks_base by crdroidandroid.

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));
            }
        }
    }
}
Also used : TransitionSet(android.transition.TransitionSet) Transition(android.transition.Transition) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

TransitionSet (android.transition.TransitionSet)127 ChangeBounds (android.transition.ChangeBounds)71 View (android.view.View)66 Transition (android.transition.Transition)57 Fade (android.transition.Fade)47 TransitionManager (android.transition.TransitionManager)32 Recolor (android.transition.Recolor)24 Crossfade (android.transition.Crossfade)20 ViewGroup (android.view.ViewGroup)17 TransitionInflater (android.transition.TransitionInflater)15 ArrayList (java.util.ArrayList)15 ChangeText (android.transition.ChangeText)12 TextView (android.widget.TextView)12 List (java.util.List)10 ImageView (android.widget.ImageView)9 Scene (android.transition.Scene)8 Visibility (android.transition.Visibility)5 GhostView (android.view.GhostView)5 AutoTransition (android.transition.AutoTransition)4 Rotate (android.transition.Rotate)4