Search in sources :

Example 21 with TransitionSet

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

the class ContactsExpansion method addContact.

private void addContact(ViewGroup container, int dataIndex, int thumbnailID) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View contactItem = inflater.inflate(R.layout.contact_collapsed, container, false);
    ImageView thumbnailView = (ImageView) contactItem.findViewById(R.id.contact_picture);
    thumbnailView.setImageResource(thumbnailID);
    ((TextView) contactItem.findViewById(R.id.contact_name)).setText(contactsData[dataIndex++]);
    ((TextView) contactItem.findViewById(R.id.contact_street)).setText(contactsData[dataIndex++]);
    ((TextView) contactItem.findViewById(R.id.contact_city)).setText(contactsData[dataIndex++]);
    ((TextView) contactItem.findViewById(R.id.contact_phone)).setText(contactsData[dataIndex++]);
    ((TextView) contactItem.findViewById(R.id.contact_email)).setText(contactsData[dataIndex++]);
    container.addView(contactItem);
    final TransitionSet myTransition = new TransitionSet();
    myTransition.addTransition(new Fade(Fade.IN)).addTransition(new Rotate().addTarget(R.id.contact_arrow)).addTransition(new ChangeBounds()).addTransition(new Fade(Fade.OUT)).addTransition(new Crossfade().addTarget(R.id.contact_picture));
    final ToggleScene toggleScene = new ToggleScene(container, myTransition);
    contactItem.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            currentItem = v;
            toggleScene.changeToScene();
        }
    });
}
Also used : Rotate(android.transition.Rotate) TransitionSet(android.transition.TransitionSet) ChangeBounds(android.transition.ChangeBounds) LayoutInflater(android.view.LayoutInflater) Crossfade(android.transition.Crossfade) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Fade(android.transition.Fade)

Example 22 with TransitionSet

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

the class Demo3 method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_screen);
    View container = (View) findViewById(R.id.container);
    mSceneRoot = (ViewGroup) container.getParent();
    mSearchScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
    mResultsScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.results_screen, this);
    TransitionSet transition = new TransitionSet();
    transition.addTransition(new Fade()).addTransition(new ChangeBounds()).addTransition(new Recolor());
    mTransitionManager = new TransitionManager();
    mTransitionManager.setTransition(mSearchScreen, transition);
    mTransitionManager.setTransition(mResultsScreen, transition);
}
Also used : TransitionManager(android.transition.TransitionManager) TransitionSet(android.transition.TransitionSet) ChangeBounds(android.transition.ChangeBounds) View(android.view.View) Fade(android.transition.Fade) Recolor(android.transition.Recolor)

Example 23 with TransitionSet

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

the class Demo4 method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_screen);
    View container = (View) findViewById(R.id.container);
    mSceneRoot = (ViewGroup) container.getParent();
    mSearchScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
    mResultsScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.results_screen, this);
    TransitionSet transitionToResults = new TransitionSet();
    Fade fade = new Fade();
    fade.addTarget(R.id.resultsText).addTarget(R.id.resultsList);
    fade.setStartDelay(300);
    fade.setDuration(1000);
    transitionToResults.addTransition(fade).addTransition(new ChangeBounds().addTarget(R.id.searchContainer)).addTransition(new Recolor().addTarget(R.id.container));
    TransitionSet transitionToSearch = new TransitionSet();
    transitionToSearch.addTransition(fade).addTransition(new ChangeBounds().addTarget(R.id.searchContainer)).addTransition(new Recolor().addTarget(R.id.container));
    mTransitionManager = new TransitionManager();
    mTransitionManager.setTransition(mSearchScreen, transitionToSearch);
    mTransitionManager.setTransition(mResultsScreen, transitionToResults);
}
Also used : TransitionManager(android.transition.TransitionManager) TransitionSet(android.transition.TransitionSet) ChangeBounds(android.transition.ChangeBounds) View(android.view.View) Fade(android.transition.Fade) Recolor(android.transition.Recolor)

Example 24 with TransitionSet

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

Example 25 with TransitionSet

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

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