Search in sources :

Example 96 with Transition

use of android.transition.Transition in project Material-Animations by lgvalle.

the class TransitionActivity2 method setupWindowAnimations.

private void setupWindowAnimations() {
    Transition transition;
    if (type == TYPE_PROGRAMMATICALLY) {
        transition = buildEnterTransition();
    } else {
        transition = TransitionInflater.from(this).inflateTransition(R.transition.explode);
    }
    getWindow().setEnterTransition(transition);
}
Also used : Transition(android.transition.Transition)

Example 97 with Transition

use of android.transition.Transition in project UltimateAndroid by cymcsg.

the class DetailActivity3 method setupEnterAnimations.

private void setupEnterAnimations() {
    Transition enterTransition = getWindow().getSharedElementEnterTransition();
    enterTransition.addListener(new Transition.TransitionListener() {

        @Override
        public void onTransitionStart(Transition transition) {
        }

        @Override
        public void onTransitionEnd(Transition transition) {
            animateRevealShow(bgViewGroup);
        }

        @Override
        public void onTransitionCancel(Transition transition) {
        }

        @Override
        public void onTransitionPause(Transition transition) {
        }

        @Override
        public void onTransitionResume(Transition transition) {
        }
    });
}
Also used : Transition(android.transition.Transition)

Example 98 with Transition

use of android.transition.Transition in project android-topeka by googlesamples.

the class SignInFragment method performSignInWithTransition.

private void performSignInWithTransition(View v) {
    final Activity activity = getActivity();
    if (v == null || ApiLevelHelper.isLowerThan(Build.VERSION_CODES.LOLLIPOP)) {
        // Don't run a transition if the passed view is null
        CategorySelectionActivity.start(activity, mPlayer);
        activity.finish();
        return;
    }
    if (ApiLevelHelper.isAtLeast(Build.VERSION_CODES.LOLLIPOP)) {
        activity.getWindow().getSharedElementExitTransition().addListener(new TransitionListenerAdapter() {

            @Override
            public void onTransitionEnd(Transition transition) {
                activity.finish();
            }
        });
        final Pair[] pairs = TransitionHelper.createSafeTransitionParticipants(activity, true, new Pair<>(v, activity.getString(R.string.transition_avatar)));
        @SuppressWarnings("unchecked") ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, pairs);
        CategorySelectionActivity.start(activity, mPlayer, activityOptions);
    }
}
Also used : Transition(android.transition.Transition) CategorySelectionActivity(com.google.samples.apps.topeka.activity.CategorySelectionActivity) Activity(android.app.Activity) TransitionListenerAdapter(com.google.samples.apps.topeka.widget.TransitionListenerAdapter) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) Pair(android.support.v4.util.Pair)

Example 99 with Transition

use of android.transition.Transition in project native-navigation by airbnb.

the class AutoSharedElementCallback method onSharedElementStart.

@TargetApi(TARGET_API)
@Override
public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
    Transition enterTransition = sharedElementEnterTransition == null ? getDefaultSharedElementEnterTransition() : sharedElementEnterTransition;
    Transition returnTransition = sharedElementReturnTransition == null ? getDefaultSharedElementReturnTransition() : sharedElementReturnTransition;
    crossFadePartialMatchImageViews(sharedElementNames, sharedElements, sharedElementSnapshots, (int) returnTransition.getDuration());
    Window window = activity.getWindow();
    window.setSharedElementEnterTransition(enterTransition);
    window.setSharedElementReturnTransition(returnTransition);
    boolean entering = !endCalledSinceOnMap;
    window.setTransitionBackgroundFadeDuration(entering ? enterBackgroundFadeDuration : returnBackgroundFadeDuration);
}
Also used : Window(android.view.Window) Transition(android.transition.Transition) TargetApi(android.annotation.TargetApi)

Example 100 with Transition

use of android.transition.Transition in project platform_frameworks_base by android.

the class PopupWindow method dismiss.

/**
     * Disposes of the popup window. This method can be invoked only after
     * {@link #showAsDropDown(android.view.View)} has been executed. Failing
     * that, calling this method will have no effect.
     *
     * @see #showAsDropDown(android.view.View)
     */
public void dismiss() {
    if (!isShowing() || mIsTransitioningToDismiss) {
        return;
    }
    final PopupDecorView decorView = mDecorView;
    final View contentView = mContentView;
    final ViewGroup contentHolder;
    final ViewParent contentParent = contentView.getParent();
    if (contentParent instanceof ViewGroup) {
        contentHolder = ((ViewGroup) contentParent);
    } else {
        contentHolder = null;
    }
    // Ensure any ongoing or pending transitions are canceled.
    decorView.cancelTransitions();
    mIsShowing = false;
    mIsTransitioningToDismiss = true;
    // This method may be called as part of window detachment, in which
    // case the anchor view (and its root) will still return true from
    // isAttachedToWindow() during execution of this method; however, we
    // can expect the OnAttachStateChangeListener to have been called prior
    // to executing this method, so we can rely on that instead.
    final Transition exitTransition = mExitTransition;
    if (mIsAnchorRootAttached && exitTransition != null && decorView.isLaidOut()) {
        // The decor view is non-interactive and non-IME-focusable during exit transitions.
        final LayoutParams p = (LayoutParams) decorView.getLayoutParams();
        p.flags |= LayoutParams.FLAG_NOT_TOUCHABLE;
        p.flags |= LayoutParams.FLAG_NOT_FOCUSABLE;
        p.flags &= ~LayoutParams.FLAG_ALT_FOCUSABLE_IM;
        mWindowManager.updateViewLayout(decorView, p);
        // Once we start dismissing the decor view, all state (including
        // the anchor root) needs to be moved to the decor view since we
        // may open another popup while it's busy exiting.
        final View anchorRoot = mAnchorRoot != null ? mAnchorRoot.get() : null;
        final Rect epicenter = getTransitionEpicenter();
        exitTransition.setEpicenterCallback(new EpicenterCallback() {

            @Override
            public Rect onGetEpicenter(Transition transition) {
                return epicenter;
            }
        });
        decorView.startExitTransition(exitTransition, anchorRoot, new TransitionListenerAdapter() {

            @Override
            public void onTransitionEnd(Transition transition) {
                dismissImmediate(decorView, contentHolder, contentView);
            }
        });
    } else {
        dismissImmediate(decorView, contentHolder, contentView);
    }
    // Clears the anchor view.
    detachFromAnchor();
    if (mOnDismissListener != null) {
        mOnDismissListener.onDismiss();
    }
}
Also used : Rect(android.graphics.Rect) LayoutParams(android.view.WindowManager.LayoutParams) ViewGroup(android.view.ViewGroup) ViewParent(android.view.ViewParent) EpicenterCallback(android.transition.Transition.EpicenterCallback) Transition(android.transition.Transition) TransitionListenerAdapter(android.transition.Transition.TransitionListenerAdapter) View(android.view.View)

Aggregations

Transition (android.transition.Transition)176 TransitionSet (android.transition.TransitionSet)62 View (android.view.View)54 ViewGroup (android.view.ViewGroup)37 ArrayList (java.util.ArrayList)23 TransitionInflater (android.transition.TransitionInflater)19 Fade (android.transition.Fade)18 ViewTreeObserver (android.view.ViewTreeObserver)18 ChangeBounds (android.transition.ChangeBounds)17 Rect (android.graphics.Rect)12 List (java.util.List)12 TargetApi (android.annotation.TargetApi)11 TextView (android.widget.TextView)11 AutoTransition (android.transition.AutoTransition)10 Scene (android.transition.Scene)8 ObjectAnimator (android.animation.ObjectAnimator)7 Fragment (android.support.v4.app.Fragment)6 FragmentTransaction (android.support.v4.app.FragmentTransaction)6 AdapterView (android.widget.AdapterView)6 ImageView (android.widget.ImageView)6