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();
}
});
}
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);
}
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);
}
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);
}
}
}
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;
}
Aggregations