Search in sources :

Example 1 with OnSharedElementsReadyListener

use of android.app.SharedElementCallback.OnSharedElementsReadyListener in project platform_frameworks_base by android.

the class EnterTransitionCoordinator method onTakeSharedElements.

private void onTakeSharedElements() {
    if (!mIsReadyForTransition || mSharedElementsBundle == null) {
        return;
    }
    final Bundle sharedElementState = mSharedElementsBundle;
    mSharedElementsBundle = null;
    OnSharedElementsReadyListener listener = new OnSharedElementsReadyListener() {

        @Override
        public void onSharedElementsReady() {
            final View decorView = getDecor();
            if (decorView != null) {
                decorView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

                    @Override
                    public boolean onPreDraw() {
                        decorView.getViewTreeObserver().removeOnPreDrawListener(this);
                        startTransition(new Runnable() {

                            @Override
                            public void run() {
                                startSharedElementTransition(sharedElementState);
                            }
                        });
                        return false;
                    }
                });
                decorView.invalidate();
            }
        }
    };
    if (mListener == null) {
        listener.onSharedElementsReady();
    } else {
        mListener.onSharedElementsArrived(mSharedElementNames, mSharedElements, listener);
    }
}
Also used : Bundle(android.os.Bundle) OnSharedElementsReadyListener(android.app.SharedElementCallback.OnSharedElementsReadyListener) View(android.view.View) ViewTreeObserver(android.view.ViewTreeObserver) OnPreDrawListener(android.view.ViewTreeObserver.OnPreDrawListener)

Example 2 with OnSharedElementsReadyListener

use of android.app.SharedElementCallback.OnSharedElementsReadyListener in project android_frameworks_base by DirtyUnicorns.

the class EnterTransitionCoordinator method onTakeSharedElements.

private void onTakeSharedElements() {
    if (!mIsReadyForTransition || mSharedElementsBundle == null) {
        return;
    }
    final Bundle sharedElementState = mSharedElementsBundle;
    mSharedElementsBundle = null;
    OnSharedElementsReadyListener listener = new OnSharedElementsReadyListener() {

        @Override
        public void onSharedElementsReady() {
            final View decorView = getDecor();
            if (decorView != null) {
                decorView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

                    @Override
                    public boolean onPreDraw() {
                        decorView.getViewTreeObserver().removeOnPreDrawListener(this);
                        startTransition(new Runnable() {

                            @Override
                            public void run() {
                                startSharedElementTransition(sharedElementState);
                            }
                        });
                        return false;
                    }
                });
                decorView.invalidate();
            }
        }
    };
    if (mListener == null) {
        listener.onSharedElementsReady();
    } else {
        mListener.onSharedElementsArrived(mSharedElementNames, mSharedElements, listener);
    }
}
Also used : Bundle(android.os.Bundle) OnSharedElementsReadyListener(android.app.SharedElementCallback.OnSharedElementsReadyListener) View(android.view.View) ViewTreeObserver(android.view.ViewTreeObserver) OnPreDrawListener(android.view.ViewTreeObserver.OnPreDrawListener)

Example 3 with OnSharedElementsReadyListener

use of android.app.SharedElementCallback.OnSharedElementsReadyListener in project android_frameworks_base by DirtyUnicorns.

the class ExitTransitionCoordinator method notifyComplete.

protected void notifyComplete() {
    if (isReadyToNotify()) {
        if (!mSharedElementNotified) {
            mSharedElementNotified = true;
            delayCancel();
            if (mListener == null) {
                mResultReceiver.send(MSG_TAKE_SHARED_ELEMENTS, mSharedElementBundle);
                notifyExitComplete();
            } else {
                final ResultReceiver resultReceiver = mResultReceiver;
                final Bundle sharedElementBundle = mSharedElementBundle;
                mListener.onSharedElementsArrived(mSharedElementNames, mSharedElements, new OnSharedElementsReadyListener() {

                    @Override
                    public void onSharedElementsReady() {
                        resultReceiver.send(MSG_TAKE_SHARED_ELEMENTS, sharedElementBundle);
                        notifyExitComplete();
                    }
                });
            }
        } else {
            notifyExitComplete();
        }
    }
}
Also used : Bundle(android.os.Bundle) OnSharedElementsReadyListener(android.app.SharedElementCallback.OnSharedElementsReadyListener) ResultReceiver(android.os.ResultReceiver)

Example 4 with OnSharedElementsReadyListener

use of android.app.SharedElementCallback.OnSharedElementsReadyListener in project android_frameworks_base by AOSPA.

the class ExitTransitionCoordinator method notifyComplete.

protected void notifyComplete() {
    if (isReadyToNotify()) {
        if (!mSharedElementNotified) {
            mSharedElementNotified = true;
            delayCancel();
            if (mListener == null) {
                mResultReceiver.send(MSG_TAKE_SHARED_ELEMENTS, mSharedElementBundle);
                notifyExitComplete();
            } else {
                final ResultReceiver resultReceiver = mResultReceiver;
                final Bundle sharedElementBundle = mSharedElementBundle;
                mListener.onSharedElementsArrived(mSharedElementNames, mSharedElements, new OnSharedElementsReadyListener() {

                    @Override
                    public void onSharedElementsReady() {
                        resultReceiver.send(MSG_TAKE_SHARED_ELEMENTS, sharedElementBundle);
                        notifyExitComplete();
                    }
                });
            }
        } else {
            notifyExitComplete();
        }
    }
}
Also used : Bundle(android.os.Bundle) OnSharedElementsReadyListener(android.app.SharedElementCallback.OnSharedElementsReadyListener) ResultReceiver(android.os.ResultReceiver)

Example 5 with OnSharedElementsReadyListener

use of android.app.SharedElementCallback.OnSharedElementsReadyListener in project android_frameworks_base by crdroidandroid.

the class ExitTransitionCoordinator method notifyComplete.

protected void notifyComplete() {
    if (isReadyToNotify()) {
        if (!mSharedElementNotified) {
            mSharedElementNotified = true;
            delayCancel();
            if (mListener == null) {
                mResultReceiver.send(MSG_TAKE_SHARED_ELEMENTS, mSharedElementBundle);
                notifyExitComplete();
            } else {
                final ResultReceiver resultReceiver = mResultReceiver;
                final Bundle sharedElementBundle = mSharedElementBundle;
                mListener.onSharedElementsArrived(mSharedElementNames, mSharedElements, new OnSharedElementsReadyListener() {

                    @Override
                    public void onSharedElementsReady() {
                        resultReceiver.send(MSG_TAKE_SHARED_ELEMENTS, sharedElementBundle);
                        notifyExitComplete();
                    }
                });
            }
        } else {
            notifyExitComplete();
        }
    }
}
Also used : Bundle(android.os.Bundle) OnSharedElementsReadyListener(android.app.SharedElementCallback.OnSharedElementsReadyListener) ResultReceiver(android.os.ResultReceiver)

Aggregations

OnSharedElementsReadyListener (android.app.SharedElementCallback.OnSharedElementsReadyListener)10 Bundle (android.os.Bundle)10 ResultReceiver (android.os.ResultReceiver)5 View (android.view.View)5 ViewTreeObserver (android.view.ViewTreeObserver)5 OnPreDrawListener (android.view.ViewTreeObserver.OnPreDrawListener)5