Search in sources :

Example 21 with Transition

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

Example 22 with Transition

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

Example 23 with Transition

use of android.transition.Transition in project platform_frameworks_base by android.

the class EnterTransitionCoordinator method startEnterTransition.

private void startEnterTransition(Transition transition) {
    ViewGroup decorView = getDecor();
    if (!mIsReturning && decorView != null) {
        Drawable background = decorView.getBackground();
        if (background != null) {
            background = background.mutate();
            getWindow().setBackgroundDrawable(background);
            mBackgroundAnimator = ObjectAnimator.ofInt(background, "alpha", 255);
            mBackgroundAnimator.setDuration(getFadeDuration());
            mBackgroundAnimator.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    makeOpaque();
                }
            });
            mBackgroundAnimator.start();
        } else if (transition != null) {
            transition.addListener(new Transition.TransitionListenerAdapter() {

                @Override
                public void onTransitionEnd(Transition transition) {
                    transition.removeListener(this);
                    makeOpaque();
                }
            });
        } else {
            makeOpaque();
        }
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ViewGroup(android.view.ViewGroup) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Drawable(android.graphics.drawable.Drawable) Transition(android.transition.Transition)

Example 24 with Transition

use of android.transition.Transition in project platform_frameworks_base by android.

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 25 with Transition

use of android.transition.Transition in project platform_frameworks_base by android.

the class ActivityTransitionState method startExitBackTransition.

public boolean startExitBackTransition(final Activity activity) {
    if (mEnteringNames == null || mCalledExitCoordinator != null) {
        return false;
    } else {
        if (!mHasExited) {
            mHasExited = true;
            Transition enterViewsTransition = null;
            ViewGroup decor = null;
            boolean delayExitBack = false;
            if (mEnterTransitionCoordinator != null) {
                enterViewsTransition = mEnterTransitionCoordinator.getEnterViewsTransition();
                decor = mEnterTransitionCoordinator.getDecor();
                delayExitBack = mEnterTransitionCoordinator.cancelEnter();
                mEnterTransitionCoordinator = null;
                if (enterViewsTransition != null && decor != null) {
                    enterViewsTransition.pause(decor);
                }
            }
            mReturnExitCoordinator = new ExitTransitionCoordinator(activity, activity.getWindow(), activity.mEnterTransitionListener, mEnteringNames, null, null, true);
            if (enterViewsTransition != null && decor != null) {
                enterViewsTransition.resume(decor);
            }
            if (delayExitBack && decor != null) {
                final ViewGroup finalDecor = decor;
                decor.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

                    @Override
                    public boolean onPreDraw() {
                        finalDecor.getViewTreeObserver().removeOnPreDrawListener(this);
                        if (mReturnExitCoordinator != null) {
                            mReturnExitCoordinator.startExit(activity.mResultCode, activity.mResultData);
                        }
                        return true;
                    }
                });
            } else {
                mReturnExitCoordinator.startExit(activity.mResultCode, activity.mResultData);
            }
        }
        return true;
    }
}
Also used : ViewGroup(android.view.ViewGroup) Transition(android.transition.Transition) ViewTreeObserver(android.view.ViewTreeObserver)

Aggregations

Transition (android.transition.Transition)163 TransitionSet (android.transition.TransitionSet)57 View (android.view.View)51 ViewGroup (android.view.ViewGroup)36 ArrayList (java.util.ArrayList)23 TransitionInflater (android.transition.TransitionInflater)19 ViewTreeObserver (android.view.ViewTreeObserver)18 Fade (android.transition.Fade)17 ChangeBounds (android.transition.ChangeBounds)14 TextView (android.widget.TextView)11 TargetApi (android.annotation.TargetApi)10 Rect (android.graphics.Rect)10 List (java.util.List)10 AutoTransition (android.transition.AutoTransition)9 Scene (android.transition.Scene)8 ObjectAnimator (android.animation.ObjectAnimator)7 AdapterView (android.widget.AdapterView)6 ImageView (android.widget.ImageView)6 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5