Search in sources :

Example 41 with Animation

use of android.view.animation.Animation in project material by rey5137.

the class ListPopupWindow method show.

/**
     * Show the popup list. If the list is already showing, this method
     * will recalculate the popup's size and position.
     */
public void show() {
    int height = buildDropDown();
    int widthSpec = 0;
    int heightSpec = 0;
    boolean noInputMethod = isInputMethodNotNeeded();
    if (mPopup.isShowing()) {
        if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) {
            // The call to PopupWindow's update method below can accept -1 for any
            // value you do not want to update.
            widthSpec = -1;
        } else if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) {
            widthSpec = getAnchorView().getWidth();
        } else {
            widthSpec = mDropDownWidth;
        }
        if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
            // The call to PopupWindow's update method below can accept -1 for any
            // value you do not want to update.
            heightSpec = noInputMethod ? height : ViewGroup.LayoutParams.MATCH_PARENT;
            if (noInputMethod) {
                mPopup.setWindowLayoutMode(mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ? ViewGroup.LayoutParams.MATCH_PARENT : 0, 0);
            } else {
                mPopup.setWindowLayoutMode(mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ? ViewGroup.LayoutParams.MATCH_PARENT : 0, ViewGroup.LayoutParams.MATCH_PARENT);
            }
        } else if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) {
            heightSpec = height;
        } else {
            heightSpec = mDropDownHeight;
        }
        mPopup.setOutsideTouchable(!mForceIgnoreOutsideTouch && !mDropDownAlwaysVisible);
        mPopup.update(getAnchorView(), mDropDownHorizontalOffset, mDropDownVerticalOffset, widthSpec, heightSpec);
    } else {
        if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) {
            widthSpec = ViewGroup.LayoutParams.MATCH_PARENT;
        } else {
            if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) {
                mPopup.setWidth(getAnchorView().getWidth());
            } else {
                mPopup.setWidth(mDropDownWidth);
            }
        }
        if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
            heightSpec = ViewGroup.LayoutParams.MATCH_PARENT;
        } else {
            if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) {
                mPopup.setHeight(height);
            } else {
                mPopup.setHeight(mDropDownHeight);
            }
        }
        mPopup.setWindowLayoutMode(widthSpec, heightSpec);
        setPopupClipToScreenEnabled(true);
        // use outside touchable to dismiss drop down when touching outside of it, so
        // only set this if the dropdown is not always visible
        mPopup.setOutsideTouchable(!mForceIgnoreOutsideTouch && !mDropDownAlwaysVisible);
        mPopup.setTouchInterceptor(mTouchInterceptor);
        PopupWindowCompat.showAsDropDown(mPopup, getAnchorView(), mDropDownHorizontalOffset, mDropDownVerticalOffset, mDropDownGravity);
        mDropDownList.setSelection(ListView.INVALID_POSITION);
        if (!mModal || mDropDownList.isInTouchMode()) {
            clearListSelection();
        }
        if (!mModal) {
            mHandler.post(mHideSelector);
        }
        // show item animation
        if (mItemAnimationId != 0)
            mPopup.getContentView().getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

                @Override
                public boolean onPreDraw() {
                    mPopup.getContentView().getViewTreeObserver().removeOnPreDrawListener(this);
                    for (int i = 0, count = mDropDownList.getChildCount(); i < count; i++) {
                        View v = mDropDownList.getChildAt(i);
                        Animation anim = AnimationUtils.loadAnimation(mContext, mItemAnimationId);
                        anim.setStartOffset(mItemAnimationOffset * i);
                        v.startAnimation(anim);
                    }
                    return false;
                }
            });
    }
}
Also used : Animation(android.view.animation.Animation) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView)

Example 42 with Animation

use of android.view.animation.Animation in project material by rey5137.

the class ToolbarManager method animateOut.

private void animateOut() {
    ActionMenuView menuView = getMenuView();
    int count = menuView == null ? 0 : menuView.getChildCount();
    Animation slowestAnimation = null;
    mAnimations.clear();
    mAnimations.ensureCapacity(count);
    for (int i = 0; i < count; i++) {
        View child = menuView.getChildAt(i);
        Animation anim = mAnimator.getOutAnimation(child, i);
        mAnimations.add(anim);
        if (anim != null)
            if (slowestAnimation == null || slowestAnimation.getStartOffset() + slowestAnimation.getDuration() < anim.getStartOffset() + anim.getDuration())
                slowestAnimation = anim;
    }
    if (slowestAnimation == null)
        mOutAnimationEndListener.onAnimationEnd(null);
    else {
        slowestAnimation.setAnimationListener(mOutAnimationEndListener);
        for (int i = 0; i < count; i++) {
            Animation anim = mAnimations.get(i);
            if (anim != null)
                menuView.getChildAt(i).startAnimation(anim);
        }
    }
    mAnimations.clear();
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) ActionMenuView(android.support.v7.widget.ActionMenuView) View(android.view.View) ActionMenuView(android.support.v7.widget.ActionMenuView)

Example 43 with Animation

use of android.view.animation.Animation in project material by rey5137.

the class RecurringPickerDialog method animOut.

private void animOut(final View v, final boolean setGone, final boolean immediately) {
    if (!isShowing() || v.getVisibility() != View.VISIBLE || immediately) {
        v.setVisibility(setGone ? View.GONE : View.INVISIBLE);
        return;
    }
    Animation anim = new AlphaAnimation(1f, 0f);
    anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime));
    anim.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            v.setVisibility(setGone ? View.GONE : View.INVISIBLE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    v.startAnimation(anim);
}
Also used : Animation(android.view.animation.Animation) AlphaAnimation(android.view.animation.AlphaAnimation) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 44 with Animation

use of android.view.animation.Animation in project material by rey5137.

the class RecurringPickerDialog method animIn.

private void animIn(final View v, boolean immediately) {
    if (v.getVisibility() == View.VISIBLE)
        return;
    if (!isShowing() || immediately) {
        v.setVisibility(View.VISIBLE);
        return;
    }
    Animation anim = new AlphaAnimation(0f, 1f);
    anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime));
    anim.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
            v.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    v.startAnimation(anim);
}
Also used : Animation(android.view.animation.Animation) AlphaAnimation(android.view.animation.AlphaAnimation) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 45 with Animation

use of android.view.animation.Animation in project android-Ultra-Pull-To-Refresh by liaohuqiu.

the class RentalsSunDrawable method setupAnimations.

private void setupAnimations() {
    mAnimation = new Animation() {

        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setRotate(interpolatedTime);
        }
    };
    mAnimation.setRepeatCount(Animation.INFINITE);
    mAnimation.setRepeatMode(Animation.RESTART);
    mAnimation.setInterpolator(LINEAR_INTERPOLATOR);
    mAnimation.setDuration(ANIMATION_DURATION);
}
Also used : Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation)

Aggregations

Animation (android.view.animation.Animation)620 AlphaAnimation (android.view.animation.AlphaAnimation)164 TranslateAnimation (android.view.animation.TranslateAnimation)125 ScaleAnimation (android.view.animation.ScaleAnimation)99 AnimationListener (android.view.animation.Animation.AnimationListener)80 AnimationSet (android.view.animation.AnimationSet)71 View (android.view.View)68 Transformation (android.view.animation.Transformation)62 RotateAnimation (android.view.animation.RotateAnimation)43 Point (android.graphics.Point)35 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)35 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)35 WindowAnimation_activityOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation)35 WindowAnimation_activityOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation)35 WindowAnimation_taskCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation)35 WindowAnimation_taskCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation)35 WindowAnimation_taskOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation)35 WindowAnimation_taskOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation)35 WindowAnimation_taskToBackEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation)35 WindowAnimation_taskToBackExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation)35