Search in sources :

Example 1 with EpicenterCallback

use of android.transition.Transition.EpicenterCallback 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)

Example 2 with EpicenterCallback

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

the class TransitionTest method testClone.

public void testClone() throws Throwable {
    View square1 = mActivity.findViewById(R.id.square1);
    View square2 = mActivity.findViewById(R.id.square2);
    View square3 = mActivity.findViewById(R.id.square3);
    Fade fade = new Fade();
    fade.setStartDelay(1000);
    fade.setDuration(1001);
    fade.addTarget(square1);
    fade.excludeTarget(square2, true);
    fade.excludeChildren(square3, true);
    fade.addTarget(R.id.square4);
    fade.excludeTarget(R.id.square3, true);
    fade.excludeChildren(R.id.square2, true);
    fade.addTarget("hello");
    fade.excludeTarget("world", true);
    fade.addTarget(View.class);
    fade.excludeTarget(TextView.class, true);
    fade.setMatchOrder(Transition.MATCH_ID);
    fade.setPropagation(new CircularPropagation());
    fade.setPathMotion(new ArcMotion());
    fade.setInterpolator(new AccelerateInterpolator());
    fade.setNameOverrides(new ArrayMap<>());
    EpicenterCallback epicenterCallback = new EpicenterCallback() {

        @Override
        public Rect onGetEpicenter(Transition transition) {
            return null;
        }
    };
    fade.setEpicenterCallback(epicenterCallback);
    Fade clone = (Fade) fade.clone();
    assertEquals(fade.mStartDelay, clone.mStartDelay);
    assertEquals(fade.mDuration, clone.mDuration);
    assertEquals(fade.mInterpolator, clone.mInterpolator);
    assertEquals(fade.mPropagation, clone.mPropagation);
    assertEquals(fade.getPathMotion(), clone.getPathMotion());
    assertEquals(fade.getEpicenterCallback(), clone.getEpicenterCallback());
    assertEquals(fade.mNameOverrides, clone.mNameOverrides);
    assertEquals(fade.mMatchOrder, clone.mMatchOrder);
    assertEquals(fade.mTargets, clone.mTargets);
    assertEquals(fade.mTargetExcludes, clone.mTargetExcludes);
    assertEquals(fade.mTargetChildExcludes, clone.mTargetChildExcludes);
    assertEquals(fade.mTargetIds, clone.mTargetIds);
    assertEquals(fade.mTargetIdExcludes, clone.mTargetIdExcludes);
    assertEquals(fade.mTargetIdChildExcludes, clone.mTargetIdChildExcludes);
    assertEquals(fade.mTargetNames, clone.mTargetNames);
    assertEquals(fade.mTargetNameExcludes, clone.mTargetNameExcludes);
    assertEquals(fade.mTargetTypes, clone.mTargetTypes);
    assertEquals(fade.mTargetTypeExcludes, clone.mTargetTypeExcludes);
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) EpicenterCallback(android.transition.Transition.EpicenterCallback) TextView(android.widget.TextView) View(android.view.View)

Example 3 with EpicenterCallback

use of android.transition.Transition.EpicenterCallback in project android_frameworks_base by AOSPA.

the class TransitionTest method testClone.

public void testClone() throws Throwable {
    View square1 = mActivity.findViewById(R.id.square1);
    View square2 = mActivity.findViewById(R.id.square2);
    View square3 = mActivity.findViewById(R.id.square3);
    Fade fade = new Fade();
    fade.setStartDelay(1000);
    fade.setDuration(1001);
    fade.addTarget(square1);
    fade.excludeTarget(square2, true);
    fade.excludeChildren(square3, true);
    fade.addTarget(R.id.square4);
    fade.excludeTarget(R.id.square3, true);
    fade.excludeChildren(R.id.square2, true);
    fade.addTarget("hello");
    fade.excludeTarget("world", true);
    fade.addTarget(View.class);
    fade.excludeTarget(TextView.class, true);
    fade.setMatchOrder(Transition.MATCH_ID);
    fade.setPropagation(new CircularPropagation());
    fade.setPathMotion(new ArcMotion());
    fade.setInterpolator(new AccelerateInterpolator());
    fade.setNameOverrides(new ArrayMap<>());
    EpicenterCallback epicenterCallback = new EpicenterCallback() {

        @Override
        public Rect onGetEpicenter(Transition transition) {
            return null;
        }
    };
    fade.setEpicenterCallback(epicenterCallback);
    Fade clone = (Fade) fade.clone();
    assertEquals(fade.mStartDelay, clone.mStartDelay);
    assertEquals(fade.mDuration, clone.mDuration);
    assertEquals(fade.mInterpolator, clone.mInterpolator);
    assertEquals(fade.mPropagation, clone.mPropagation);
    assertEquals(fade.getPathMotion(), clone.getPathMotion());
    assertEquals(fade.getEpicenterCallback(), clone.getEpicenterCallback());
    assertEquals(fade.mNameOverrides, clone.mNameOverrides);
    assertEquals(fade.mMatchOrder, clone.mMatchOrder);
    assertEquals(fade.mTargets, clone.mTargets);
    assertEquals(fade.mTargetExcludes, clone.mTargetExcludes);
    assertEquals(fade.mTargetChildExcludes, clone.mTargetChildExcludes);
    assertEquals(fade.mTargetIds, clone.mTargetIds);
    assertEquals(fade.mTargetIdExcludes, clone.mTargetIdExcludes);
    assertEquals(fade.mTargetIdChildExcludes, clone.mTargetIdChildExcludes);
    assertEquals(fade.mTargetNames, clone.mTargetNames);
    assertEquals(fade.mTargetNameExcludes, clone.mTargetNameExcludes);
    assertEquals(fade.mTargetTypes, clone.mTargetTypes);
    assertEquals(fade.mTargetTypeExcludes, clone.mTargetTypeExcludes);
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) EpicenterCallback(android.transition.Transition.EpicenterCallback) TextView(android.widget.TextView) View(android.view.View)

Example 4 with EpicenterCallback

use of android.transition.Transition.EpicenterCallback in project android_frameworks_base by DirtyUnicorns.

the class TransitionTest method testClone.

public void testClone() throws Throwable {
    View square1 = mActivity.findViewById(R.id.square1);
    View square2 = mActivity.findViewById(R.id.square2);
    View square3 = mActivity.findViewById(R.id.square3);
    Fade fade = new Fade();
    fade.setStartDelay(1000);
    fade.setDuration(1001);
    fade.addTarget(square1);
    fade.excludeTarget(square2, true);
    fade.excludeChildren(square3, true);
    fade.addTarget(R.id.square4);
    fade.excludeTarget(R.id.square3, true);
    fade.excludeChildren(R.id.square2, true);
    fade.addTarget("hello");
    fade.excludeTarget("world", true);
    fade.addTarget(View.class);
    fade.excludeTarget(TextView.class, true);
    fade.setMatchOrder(Transition.MATCH_ID);
    fade.setPropagation(new CircularPropagation());
    fade.setPathMotion(new ArcMotion());
    fade.setInterpolator(new AccelerateInterpolator());
    fade.setNameOverrides(new ArrayMap<>());
    EpicenterCallback epicenterCallback = new EpicenterCallback() {

        @Override
        public Rect onGetEpicenter(Transition transition) {
            return null;
        }
    };
    fade.setEpicenterCallback(epicenterCallback);
    Fade clone = (Fade) fade.clone();
    assertEquals(fade.mStartDelay, clone.mStartDelay);
    assertEquals(fade.mDuration, clone.mDuration);
    assertEquals(fade.mInterpolator, clone.mInterpolator);
    assertEquals(fade.mPropagation, clone.mPropagation);
    assertEquals(fade.getPathMotion(), clone.getPathMotion());
    assertEquals(fade.getEpicenterCallback(), clone.getEpicenterCallback());
    assertEquals(fade.mNameOverrides, clone.mNameOverrides);
    assertEquals(fade.mMatchOrder, clone.mMatchOrder);
    assertEquals(fade.mTargets, clone.mTargets);
    assertEquals(fade.mTargetExcludes, clone.mTargetExcludes);
    assertEquals(fade.mTargetChildExcludes, clone.mTargetChildExcludes);
    assertEquals(fade.mTargetIds, clone.mTargetIds);
    assertEquals(fade.mTargetIdExcludes, clone.mTargetIdExcludes);
    assertEquals(fade.mTargetIdChildExcludes, clone.mTargetIdChildExcludes);
    assertEquals(fade.mTargetNames, clone.mTargetNames);
    assertEquals(fade.mTargetNameExcludes, clone.mTargetNameExcludes);
    assertEquals(fade.mTargetTypes, clone.mTargetTypes);
    assertEquals(fade.mTargetTypeExcludes, clone.mTargetTypeExcludes);
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) EpicenterCallback(android.transition.Transition.EpicenterCallback) TextView(android.widget.TextView) View(android.view.View)

Example 5 with EpicenterCallback

use of android.transition.Transition.EpicenterCallback in project android_frameworks_base by ResurrectionRemix.

the class TransitionTest method testClone.

public void testClone() throws Throwable {
    View square1 = mActivity.findViewById(R.id.square1);
    View square2 = mActivity.findViewById(R.id.square2);
    View square3 = mActivity.findViewById(R.id.square3);
    Fade fade = new Fade();
    fade.setStartDelay(1000);
    fade.setDuration(1001);
    fade.addTarget(square1);
    fade.excludeTarget(square2, true);
    fade.excludeChildren(square3, true);
    fade.addTarget(R.id.square4);
    fade.excludeTarget(R.id.square3, true);
    fade.excludeChildren(R.id.square2, true);
    fade.addTarget("hello");
    fade.excludeTarget("world", true);
    fade.addTarget(View.class);
    fade.excludeTarget(TextView.class, true);
    fade.setMatchOrder(Transition.MATCH_ID);
    fade.setPropagation(new CircularPropagation());
    fade.setPathMotion(new ArcMotion());
    fade.setInterpolator(new AccelerateInterpolator());
    fade.setNameOverrides(new ArrayMap<>());
    EpicenterCallback epicenterCallback = new EpicenterCallback() {

        @Override
        public Rect onGetEpicenter(Transition transition) {
            return null;
        }
    };
    fade.setEpicenterCallback(epicenterCallback);
    Fade clone = (Fade) fade.clone();
    assertEquals(fade.mStartDelay, clone.mStartDelay);
    assertEquals(fade.mDuration, clone.mDuration);
    assertEquals(fade.mInterpolator, clone.mInterpolator);
    assertEquals(fade.mPropagation, clone.mPropagation);
    assertEquals(fade.getPathMotion(), clone.getPathMotion());
    assertEquals(fade.getEpicenterCallback(), clone.getEpicenterCallback());
    assertEquals(fade.mNameOverrides, clone.mNameOverrides);
    assertEquals(fade.mMatchOrder, clone.mMatchOrder);
    assertEquals(fade.mTargets, clone.mTargets);
    assertEquals(fade.mTargetExcludes, clone.mTargetExcludes);
    assertEquals(fade.mTargetChildExcludes, clone.mTargetChildExcludes);
    assertEquals(fade.mTargetIds, clone.mTargetIds);
    assertEquals(fade.mTargetIdExcludes, clone.mTargetIdExcludes);
    assertEquals(fade.mTargetIdChildExcludes, clone.mTargetIdChildExcludes);
    assertEquals(fade.mTargetNames, clone.mTargetNames);
    assertEquals(fade.mTargetNameExcludes, clone.mTargetNameExcludes);
    assertEquals(fade.mTargetTypes, clone.mTargetTypes);
    assertEquals(fade.mTargetTypeExcludes, clone.mTargetTypeExcludes);
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) EpicenterCallback(android.transition.Transition.EpicenterCallback) TextView(android.widget.TextView) View(android.view.View)

Aggregations

EpicenterCallback (android.transition.Transition.EpicenterCallback)6 View (android.view.View)6 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)5 TextView (android.widget.TextView)5 Rect (android.graphics.Rect)1 Transition (android.transition.Transition)1 TransitionListenerAdapter (android.transition.Transition.TransitionListenerAdapter)1 ViewGroup (android.view.ViewGroup)1 ViewParent (android.view.ViewParent)1 LayoutParams (android.view.WindowManager.LayoutParams)1