Search in sources :

Example 61 with Transition

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

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

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

the class EnterTransitionCoordinator method startSharedElementTransition.

private void startSharedElementTransition(Bundle sharedElementState) {
    ViewGroup decorView = getDecor();
    if (decorView == null) {
        return;
    }
    // Remove rejected shared elements
    ArrayList<String> rejectedNames = new ArrayList<String>(mAllSharedElementNames);
    rejectedNames.removeAll(mSharedElementNames);
    ArrayList<View> rejectedSnapshots = createSnapshots(sharedElementState, rejectedNames);
    if (mListener != null) {
        mListener.onRejectSharedElements(rejectedSnapshots);
    }
    removeNullViews(rejectedSnapshots);
    startRejectedAnimations(rejectedSnapshots);
    // Now start shared element transition
    ArrayList<View> sharedElementSnapshots = createSnapshots(sharedElementState, mSharedElementNames);
    showViews(mSharedElements, true);
    scheduleSetSharedElementEnd(sharedElementSnapshots);
    ArrayList<SharedElementOriginalState> originalImageViewState = setSharedElementState(sharedElementState, sharedElementSnapshots);
    requestLayoutForSharedElements();
    boolean startEnterTransition = allowOverlappingTransitions() && !mIsReturning;
    boolean startSharedElementTransition = true;
    setGhostVisibility(View.INVISIBLE);
    scheduleGhostVisibilityChange(View.INVISIBLE);
    pauseInput();
    Transition transition = beginTransition(decorView, startEnterTransition, startSharedElementTransition);
    scheduleGhostVisibilityChange(View.VISIBLE);
    setGhostVisibility(View.VISIBLE);
    if (startEnterTransition) {
        startEnterTransition(transition);
    }
    setOriginalSharedElementState(mSharedElements, originalImageViewState);
    if (mResultReceiver != null) {
        // We can't trust that the view will disappear on the same frame that the shared
        // element appears here. Assure that we get at least 2 frames for double-buffering.
        decorView.postOnAnimation(new Runnable() {

            int mAnimations;

            @Override
            public void run() {
                if (mAnimations++ < MIN_ANIMATION_FRAMES) {
                    View decorView = getDecor();
                    if (decorView != null) {
                        decorView.postOnAnimation(this);
                    }
                } else if (mResultReceiver != null) {
                    mResultReceiver.send(MSG_HIDE_SHARED_ELEMENTS, null);
                    // all done sending messages.
                    mResultReceiver = null;
                }
            }
        });
    }
}
Also used : ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) View(android.view.View) Transition(android.transition.Transition)

Example 63 with Transition

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

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

Example 64 with Transition

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

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

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

the class PhoneWindow method getTransition.

private Transition getTransition(Transition currentValue, Transition defaultValue, int id) {
    if (currentValue != defaultValue) {
        return currentValue;
    }
    int transitionId = getWindowStyle().getResourceId(id, -1);
    Transition transition = defaultValue;
    if (transitionId != -1 && transitionId != R.transition.no_transition) {
        TransitionInflater inflater = TransitionInflater.from(getContext());
        transition = inflater.inflateTransition(transitionId);
        if (transition instanceof TransitionSet && ((TransitionSet) transition).getTransitionCount() == 0) {
            transition = null;
        }
    }
    return transition;
}
Also used : TransitionSet(android.transition.TransitionSet) Transition(android.transition.Transition) TransitionInflater(android.transition.TransitionInflater)

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