void EnterTransitionCoordinator::StartSharedElementTransition(
    /* [in] */ IBundle* sharedElementState)
{
    AutoPtr<IViewGroup> vg;
    GetDecor((IViewGroup**)&vg);
    IView* decorView = IView::Probe(vg);
    if (decorView == NULL) {
        return;
    }
    // Remove rejected shared elements
    AutoPtr<IArrayList> rejectedNames;
    CArrayList::New(ICollection::Probe(mAllSharedElementNames), (IArrayList**)&rejectedNames);
    rejectedNames->RemoveAll(ICollection::Probe(mSharedElementNames));
    AutoPtr<IArrayList> rejectedSnapshots = CreateSnapshots(
        sharedElementState, ICollection::Probe(rejectedNames));
    if (mListener != NULL) {
        mListener->OnRejectSharedElements(IList::Probe(rejectedSnapshots));
    }
    StartRejectedAnimations(rejectedSnapshots);

    // Now start shared element transition
    AutoPtr<IArrayList> sharedElementSnapshots = CreateSnapshots(
        sharedElementState, ICollection::Probe(mSharedElementNames));
    ShowViews(mSharedElements, TRUE);
    ScheduleSetSharedElementEnd(sharedElementSnapshots);
    AutoPtr<IArrayList> originalImageViewState = SetSharedElementState(
        sharedElementState, sharedElementSnapshots);
    RequestLayoutForSharedElements();

    Boolean startEnterTransition = AllowOverlappingTransitions() && !mIsReturning;
    Boolean startSharedElementTransition = TRUE;
    SetGhostVisibility(IView::INVISIBLE);
    ScheduleGhostVisibilityChange(IView::INVISIBLE);
    AutoPtr<ITransition> transition = BeginTransition(
        vg, startEnterTransition, startSharedElementTransition);
    ScheduleGhostVisibilityChange(IView::VISIBLE);
    SetGhostVisibility(IView::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.
        AutoPtr<IRunnable> runnable = new OnAnimationRunnable(this);
        decorView->PostOnAnimation(runnable);
    }
}
ECode EnterTransitionCoordinator::OnAnimationRunnable::Run()
{
    if (mAnimations++ < EnterTransitionCoordinator::MIN_ANIMATION_FRAMES) {
        AutoPtr<IViewGroup> vg;
        mHost->GetDecor((IViewGroup**)&vg);
        IView* decorView = IView::Probe(vg);
        if (decorView != NULL) {
            decorView->PostOnAnimation(this);
        }
    }
    else if (mHost->mResultReceiver != NULL) {
        mHost->mResultReceiver->Send(
            IActivityTransitionCoordinator::MSG_HIDE_SHARED_ELEMENTS, NULL);
        mHost->mResultReceiver = NULL; // all done sending messages.
    }
    return NOERROR;
}