Java Code Examples for android.transition.TransitionManager#endTransitions()

The following examples show how to use android.transition.TransitionManager#endTransitions() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivityOptions.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * This method should be called when the {@link #startSharedElementAnimation(Window, Pair[])}
 * animation must be stopped and the Views reset. This can happen if there was an error
 * from startActivity or a springboard activity and the animation should stop and reset.
 *
 * @hide
 */
public static void stopSharedElementAnimation(Window window) {
    final View decorView = window.getDecorView();
    if (decorView == null) {
        return;
    }
    final ExitTransitionCoordinator exit = (ExitTransitionCoordinator)
            decorView.getTag(com.android.internal.R.id.cross_task_transition);
    if (exit != null) {
        exit.cancelPendingTransitions();
        decorView.setTagInternal(com.android.internal.R.id.cross_task_transition, null);
        TransitionManager.endTransitions((ViewGroup) decorView);
        exit.resetViews();
        exit.clearState();
        decorView.setVisibility(View.VISIBLE);
    }
}
 
Example 2
Source File: ExitTransitionCoordinator.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void resetViews() {
    ViewGroup decorView = getDecor();
    if (decorView != null) {
        TransitionManager.endTransitions(decorView);
    }
    if (mTransitioningViews != null) {
        showViews(mTransitioningViews, true);
        setTransitioningViewsVisiblity(View.VISIBLE, true);
    }
    showViews(mSharedElements, true);
    mIsHidden = true;
    if (!mIsReturning && decorView != null) {
        decorView.suppressLayout(false);
    }
    moveSharedElementsFromOverlay();
    clearState();
}
 
Example 3
Source File: PopupWindow.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Display the content view in a popup window at the specified location.
 *
 * @param token Window token to use for creating the new window
 * @param gravity the gravity which controls the placement of the popup window
 * @param x the popup's x location offset
 * @param y the popup's y location offset
 *
 * @hide Internal use only. Applications should use
 *       {@link #showAtLocation(View, int, int, int)} instead.
 */
public void showAtLocation(IBinder token, int gravity, int x, int y) {
    if (isShowing() || mContentView == null) {
        return;
    }

    TransitionManager.endTransitions(mDecorView);

    detachFromAnchor();

    mIsShowing = true;
    mIsDropdown = false;
    mGravity = gravity;

    final WindowManager.LayoutParams p = createPopupLayoutParams(token);
    preparePopup(p);

    p.x = x;
    p.y = y;

    invokePopup(p);
}
 
Example 4
Source File: PopupWindow.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Displays the content view in a popup window anchored to the corner of
 * another view. The window is positioned according to the specified
 * gravity and offset by the specified x and y coordinates.
 * <p>
 * If there is not enough room on screen to show the popup in its entirety,
 * this method tries to find a parent scroll view to scroll. If no parent
 * view can be scrolled, the specified vertical gravity will be ignored and
 * the popup will anchor itself such that it is visible.
 * <p>
 * If the view later scrolls to move <code>anchor</code> to a different
 * location, the popup will be moved correspondingly.
 *
 * @param anchor the view on which to pin the popup window
 * @param xoff A horizontal offset from the anchor in pixels
 * @param yoff A vertical offset from the anchor in pixels
 * @param gravity Alignment of the popup relative to the anchor
 *
 * @see #dismiss()
 */
public void showAsDropDown(View anchor, int xoff, int yoff, int gravity) {
    if (isShowing() || !hasContentView()) {
        return;
    }

    TransitionManager.endTransitions(mDecorView);

    attachToAnchor(anchor, xoff, yoff, gravity);

    mIsShowing = true;
    mIsDropdown = true;

    final WindowManager.LayoutParams p =
            createPopupLayoutParams(anchor.getApplicationWindowToken());
    preparePopup(p);

    final boolean aboveAnchor = findDropDownPosition(anchor, p, xoff, yoff,
            p.width, p.height, gravity, mAllowScrollingAnchorParent);
    updateAboveAnchor(aboveAnchor);
    p.accessibilityIdOfAnchor = (anchor != null) ? anchor.getAccessibilityViewId() : -1;

    invokePopup(p);
}
 
Example 5
Source File: PopupWindow.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Cancels all pending or current transitions.
 */
public void cancelTransitions() {
    TransitionManager.endTransitions(this);

    // If the cleanup runnable is still around, that means the
    // transition never started. We should run it now to clean up.
    if (mCleanupAfterExit != null) {
        mCleanupAfterExit.run();
    }
}
 
Example 6
Source File: PopupWindow.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewDetachedFromWindow(View v) {
    v.removeOnAttachStateChangeListener(this);

    if (isAttachedToWindow()) {
        TransitionManager.endTransitions(PopupDecorView.this);
    }
}