Search in sources :

Example 51 with Transition

use of android.transition.Transition 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 52 with Transition

use of android.transition.Transition 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)

Example 53 with Transition

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

the class ExitTransitionCoordinator method startSharedElementExit.

private void startSharedElementExit(final ViewGroup decorView) {
    Transition transition = getSharedElementExitTransition();
    transition.addListener(new Transition.TransitionListenerAdapter() {

        @Override
        public void onTransitionEnd(Transition transition) {
            transition.removeListener(this);
            if (isViewsTransitionComplete()) {
                delayCancel();
            }
        }
    });
    final ArrayList<View> sharedElementSnapshots = createSnapshots(mExitSharedElementBundle, mSharedElementNames);
    decorView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

        @Override
        public boolean onPreDraw() {
            decorView.getViewTreeObserver().removeOnPreDrawListener(this);
            setSharedElementState(mExitSharedElementBundle, sharedElementSnapshots);
            return true;
        }
    });
    setGhostVisibility(View.INVISIBLE);
    scheduleGhostVisibilityChange(View.INVISIBLE);
    if (mListener != null) {
        mListener.onSharedElementEnd(mSharedElementNames, mSharedElements, sharedElementSnapshots);
    }
    TransitionManager.beginDelayedTransition(decorView, transition);
    scheduleGhostVisibilityChange(View.VISIBLE);
    setGhostVisibility(View.VISIBLE);
    decorView.invalidate();
}
Also used : Transition(android.transition.Transition) View(android.view.View) ViewTreeObserver(android.view.ViewTreeObserver)

Example 54 with Transition

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

the class ExitTransitionCoordinator method beginTransitions.

private void beginTransitions() {
    Transition sharedElementTransition = getSharedElementExitTransition();
    Transition viewsTransition = getExitTransition();
    Transition transition = mergeTransitions(sharedElementTransition, viewsTransition);
    ViewGroup decorView = getDecor();
    if (transition != null && decorView != null) {
        setGhostVisibility(View.INVISIBLE);
        scheduleGhostVisibilityChange(View.INVISIBLE);
        if (viewsTransition != null) {
            setTransitioningViewsVisiblity(View.VISIBLE, false);
        }
        TransitionManager.beginDelayedTransition(decorView, transition);
        scheduleGhostVisibilityChange(View.VISIBLE);
        setGhostVisibility(View.VISIBLE);
        if (viewsTransition != null) {
            setTransitioningViewsVisiblity(View.INVISIBLE, false);
        }
        decorView.invalidate();
    } else {
        transitionStarted();
    }
}
Also used : ViewGroup(android.view.ViewGroup) Transition(android.transition.Transition)

Example 55 with Transition

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

the class ExitTransitionCoordinator method getSharedElementExitTransition.

private Transition getSharedElementExitTransition() {
    Transition sharedElementTransition = null;
    if (!mSharedElements.isEmpty()) {
        sharedElementTransition = configureTransition(getSharedElementTransition(), false);
    }
    if (sharedElementTransition == null) {
        sharedElementTransitionComplete();
    } else {
        sharedElementTransition.addListener(new ContinueTransitionListener() {

            @Override
            public void onTransitionEnd(Transition transition) {
                transition.removeListener(this);
                sharedElementTransitionComplete();
                if (mIsHidden) {
                    showViews(mSharedElements, true);
                }
            }
        });
        mSharedElements.get(0).invalidate();
    }
    return sharedElementTransition;
}
Also used : Transition(android.transition.Transition)

Aggregations

Transition (android.transition.Transition)176 TransitionSet (android.transition.TransitionSet)62 View (android.view.View)54 ViewGroup (android.view.ViewGroup)37 ArrayList (java.util.ArrayList)23 TransitionInflater (android.transition.TransitionInflater)19 Fade (android.transition.Fade)18 ViewTreeObserver (android.view.ViewTreeObserver)18 ChangeBounds (android.transition.ChangeBounds)17 Rect (android.graphics.Rect)12 List (java.util.List)12 TargetApi (android.annotation.TargetApi)11 TextView (android.widget.TextView)11 AutoTransition (android.transition.AutoTransition)10 Scene (android.transition.Scene)8 ObjectAnimator (android.animation.ObjectAnimator)7 Fragment (android.support.v4.app.Fragment)6 FragmentTransaction (android.support.v4.app.FragmentTransaction)6 AdapterView (android.widget.AdapterView)6 ImageView (android.widget.ImageView)6