Fields Summary |
---|
private static final String | ENTERING_SHARED_ELEMENTS |
private static final String | EXITING_MAPPED_FROM |
private static final String | EXITING_MAPPED_TO |
private ArrayList | mEnteringNamesThe shared elements that the calling Activity has said that they transferred to this
Activity. |
private ArrayList | mExitingFromThe names of shared elements that were shared to the called Activity. |
private ArrayList | mExitingToThe names of local Views that were shared out, mapped to those elements in mExitingFrom. |
private ArrayList | mExitingToViewThe local Views that were shared out, mapped to those elements in mExitingFrom. |
private ExitTransitionCoordinator | mCalledExitCoordinatorThe ExitTransitionCoordinator used to start an Activity. Used to make the elements restore
Visibility of exited Views. |
private ExitTransitionCoordinator | mReturnExitCoordinatorThe ExitTransitionCoordinator used to return to a previous Activity when called with
{@link android.app.Activity#finishAfterTransition()}. |
private EnterTransitionCoordinator | mEnterTransitionCoordinatorWe must be able to cancel entering transitions to stop changing the Window to
opaque when we exit before making the Window opaque. |
private ActivityOptions | mEnterActivityOptionsActivityOptions used on entering this Activity. |
private boolean | mHasExitedHas an exit transition been started? If so, we don't want to double-exit. |
private boolean | mIsEnterPostponedPostpone painting and starting the enter transition until this is false. |
private android.util.SparseArray | mExitTransitionCoordinatorsPotential exit transition coordinators. |
private int | mExitTransitionCoordinatorsKeyNext key for mExitTransitionCoordinator. |
private boolean | mIsEnterTriggered |
Methods Summary |
---|
public int | addExitTransitionCoordinator(ExitTransitionCoordinator exitTransitionCoordinator)
if (mExitTransitionCoordinators == null) {
mExitTransitionCoordinators =
new SparseArray<WeakReference<ExitTransitionCoordinator>>();
}
WeakReference<ExitTransitionCoordinator> ref = new WeakReference(exitTransitionCoordinator);
// clean up old references:
for (int i = mExitTransitionCoordinators.size() - 1; i >= 0; i--) {
WeakReference<ExitTransitionCoordinator> oldRef
= mExitTransitionCoordinators.valueAt(i);
if (oldRef.get() == null) {
mExitTransitionCoordinators.removeAt(i);
}
}
int newKey = mExitTransitionCoordinatorsKey++;
mExitTransitionCoordinators.append(newKey, ref);
return newKey;
|
public void | clear()
mEnteringNames = null;
mExitingFrom = null;
mExitingTo = null;
mExitingToView = null;
mCalledExitCoordinator = null;
mEnterTransitionCoordinator = null;
mEnterActivityOptions = null;
mExitTransitionCoordinators = null;
|
public void | enterReady(Activity activity)
if (mEnterActivityOptions == null || mIsEnterTriggered) {
return;
}
mIsEnterTriggered = true;
mHasExited = false;
ArrayList<String> sharedElementNames = mEnterActivityOptions.getSharedElementNames();
ResultReceiver resultReceiver = mEnterActivityOptions.getResultReceiver();
if (mEnterActivityOptions.isReturning()) {
restoreExitedViews();
activity.getWindow().getDecorView().setVisibility(View.VISIBLE);
}
mEnterTransitionCoordinator = new EnterTransitionCoordinator(activity,
resultReceiver, sharedElementNames, mEnterActivityOptions.isReturning());
if (!mIsEnterPostponed) {
startEnter();
}
|
public void | onResume()
restoreExitedViews();
|
public void | onStop()
restoreExitedViews();
if (mEnterTransitionCoordinator != null) {
mEnterTransitionCoordinator.stop();
mEnterTransitionCoordinator = null;
}
if (mReturnExitCoordinator != null) {
mReturnExitCoordinator.stop();
mReturnExitCoordinator = null;
}
|
public void | postponeEnterTransition()
mIsEnterPostponed = true;
|
public void | readState(android.os.Bundle bundle)
if (bundle != null) {
if (mEnterTransitionCoordinator == null || mEnterTransitionCoordinator.isReturning()) {
mEnteringNames = bundle.getStringArrayList(ENTERING_SHARED_ELEMENTS);
}
if (mEnterTransitionCoordinator == null) {
mExitingFrom = bundle.getStringArrayList(EXITING_MAPPED_FROM);
mExitingTo = bundle.getStringArrayList(EXITING_MAPPED_TO);
}
}
|
private void | restoreExitedViews()
if (mCalledExitCoordinator != null) {
mCalledExitCoordinator.resetViews();
mCalledExitCoordinator = null;
}
|
public void | saveState(android.os.Bundle bundle)
if (mEnteringNames != null) {
bundle.putStringArrayList(ENTERING_SHARED_ELEMENTS, mEnteringNames);
}
if (mExitingFrom != null) {
bundle.putStringArrayList(EXITING_MAPPED_FROM, mExitingFrom);
bundle.putStringArrayList(EXITING_MAPPED_TO, mExitingTo);
}
|
public void | setEnterActivityOptions(Activity activity, ActivityOptions options)
if (activity.getWindow().hasFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
&& options != null && mEnterActivityOptions == null
&& mEnterTransitionCoordinator == null
&& options.getAnimationType() == ActivityOptions.ANIM_SCENE_TRANSITION) {
mEnterActivityOptions = options;
mIsEnterTriggered = false;
if (mEnterActivityOptions.isReturning()) {
restoreExitedViews();
int result = mEnterActivityOptions.getResultCode();
if (result != 0) {
activity.onActivityReenter(result, mEnterActivityOptions.getResultData());
}
}
}
|
private void | startEnter()
if (mEnterActivityOptions.isReturning()) {
if (mExitingToView != null) {
mEnterTransitionCoordinator.viewInstancesReady(mExitingFrom, mExitingTo,
mExitingToView);
} else {
mEnterTransitionCoordinator.namedViewsReady(mExitingFrom, mExitingTo);
}
} else {
mEnterTransitionCoordinator.namedViewsReady(null, null);
mEnteringNames = mEnterTransitionCoordinator.getAllSharedElementNames();
}
mExitingFrom = null;
mExitingTo = null;
mExitingToView = null;
mEnterActivityOptions = null;
|
public boolean | startExitBackTransition(Activity activity)
if (mEnteringNames == 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, 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;
}
|
public void | startExitOutTransition(Activity activity, android.os.Bundle options)
if (!activity.getWindow().hasFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)) {
return;
}
ActivityOptions activityOptions = new ActivityOptions(options);
mEnterTransitionCoordinator = null;
if (activityOptions.getAnimationType() == ActivityOptions.ANIM_SCENE_TRANSITION) {
int key = activityOptions.getExitCoordinatorKey();
int index = mExitTransitionCoordinators.indexOfKey(key);
if (index >= 0) {
mCalledExitCoordinator = mExitTransitionCoordinators.valueAt(index).get();
mExitTransitionCoordinators.removeAt(index);
if (mCalledExitCoordinator != null) {
mExitingFrom = mCalledExitCoordinator.getAcceptedNames();
mExitingTo = mCalledExitCoordinator.getMappedNames();
mExitingToView = mCalledExitCoordinator.copyMappedViews();
mCalledExitCoordinator.startExit();
}
}
}
|
public void | startPostponedEnterTransition()
if (mIsEnterPostponed) {
mIsEnterPostponed = false;
if (mEnterTransitionCoordinator != null) {
startEnter();
}
}
|