Search in sources :

Example 46 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project SmartAndroidSource by jaychou2012.

the class PopoverView method showPopoverFromRectInViewGroup.

// ********************************************************************
// PUBLIC METHODS
// ********************************************************************
/**
	 * This method shows a popover in a ViewGroup, from an origin rect (relative
	 * to the Application Window)
	 * 
	 * @param group
	 *            The group we want to insert the popup. Normally a Relative
	 *            Layout so it can stand on top of everything
	 * @param originRect
	 *            The rect we want the popup to appear from (relative to the
	 *            Application Window!)
	 * @param arrowDirections
	 *            The mask of bits to tell in which directions we want the
	 *            popover to be shown
	 * @param animated
	 *            Whether is animated, or not
	 */
public void showPopoverFromRectInViewGroup(ViewGroup group, Rect originRect, int arrowDirections, boolean animated) {
    // First, tell delegate we will show
    if (delegate != null)
        delegate.popoverViewWillShow(this);
    // Save superview
    superview = group;
    // First, add the view to the view group. The popover will cover the
    // whole area
    android.view.ViewGroup.LayoutParams insertParams = new android.view.ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.FILL_PARENT);
    group.addView(this, insertParams);
    // Now, save rect for the layout (is the same as the superview)
    popoverLayoutRect = PopoverView.getFrameForView(superview);
    // Add available rects
    addAvailableRects(originRect, arrowDirections);
    // Get best rect
    Integer best = getBestRect();
    // Add popover
    Rect bestRect = possibleRects.get(best);
    addPopoverInRect(bestRect);
    // Add arrow image
    addArrow(originRect, best);
    // If we don't want animation, just tell the delegate
    if (!animated) {
        // Tell delegate we did show
        if (delegate != null)
            delegate.popoverViewDidShow(this);
    } else // If we want animation, animate it!
    {
        // Continue only if we are not animating
        if (!isAnimating) {
            // Create alpha animation, with its listener
            AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
            animation.setDuration(fadeAnimationTime);
            animation.setAnimationListener(new AnimationListener() {

                @Override
                public void onAnimationStart(Animation animation) {
                // Nothing to do here
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                // Nothing to do here
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    // End animation
                    isAnimating = false;
                    // Tell delegate we did show
                    if (delegate != null)
                        delegate.popoverViewDidShow(PopoverView.this);
                }
            });
            // Start animation
            isAnimating = true;
            startAnimation(animation);
        }
    }
}
Also used : Rect(android.graphics.Rect) ViewGroup(android.view.ViewGroup) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 47 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project SmartAndroidSource by jaychou2012.

the class PopoverView method dissmissPopover.

/**
	 * Dismiss the current shown popover
	 * 
	 * @param animated
	 *            Whether it should be dismissed animated or not
	 */
public void dissmissPopover(boolean animated) {
    // Tell delegate we will dismiss
    if (delegate != null)
        delegate.popoverViewWillDismiss(PopoverView.this);
    // If we don't want animation
    if (!animated) {
        // Just remove views
        popoverView.removeAllViews();
        removeAllViews();
        superview.removeView(this);
        // Tell delegate we did dismiss
        if (delegate != null)
            delegate.popoverViewDidDismiss(PopoverView.this);
    } else {
        // Continue only if there is not an animation in progress
        if (!isAnimating) {
            // Create alpha animation, with its listener
            AlphaAnimation animation = new AlphaAnimation(1.0f, 0.0f);
            animation.setDuration(fadeAnimationTime);
            animation.setAnimationListener(new AnimationListener() {

                @Override
                public void onAnimationStart(Animation animation) {
                // Nothing to do here
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                // Nothing to do here
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    // Remove the view
                    popoverView.removeAllViews();
                    removeAllViews();
                    PopoverView.this.superview.removeView(PopoverView.this);
                    // End animation
                    isAnimating = false;
                    // Tell delegate we did dismiss
                    if (delegate != null)
                        delegate.popoverViewDidDismiss(PopoverView.this);
                }
            });
            // Start animation
            isAnimating = true;
            startAnimation(animation);
        }
    }
}
Also used : AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 48 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project KJFrameForAndroid by kymjs.

the class Browser method initBarAnim.

/**
     * 初始化上下栏的动画并设置结束监听事件
     */
private void initBarAnim() {
    animBottomIn = AnimationUtils.loadAnimation(aty, R.anim.anim_bottom_in);
    animBottomOut = AnimationUtils.loadAnimation(aty, R.anim.anim_bottom_out);
    animBottomIn.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mLayoutBottom.setVisibility(View.VISIBLE);
        }
    });
    animBottomOut.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mLayoutBottom.setVisibility(View.GONE);
        }
    });
}
Also used : Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 49 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project KJFrameForAndroid by kymjs.

the class Main method cancleExit.

/********************** 再按一下退出 *****************************/
/**
     * 取消退出
     */
private void cancleExit() {
    Animation anim = KJAnimations.getTranslateAnimation(0, 0, titleBarHeight, 0, 300);
    mTvTitle.startAnimation(anim);
    Animation anim2 = KJAnimations.getTranslateAnimation(0, 0, titleBarHeight, 300, 0);
    anim2.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mTvDoubleClickTip.setVisibility(View.GONE);
        }
    });
    mTvDoubleClickTip.startAnimation(anim2);
}
Also used : Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 50 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project ArcMenu by daCapricorn.

the class ArcLayout method bindChildAnimation.

private void bindChildAnimation(final View child, final int index, final long duration) {
    final boolean expanded = mExpanded;
    final int centerX = getWidth() / 2;
    final int centerY = getHeight() / 2;
    final int radius = expanded ? 0 : mRadius;
    final int childCount = getChildCount();
    final float perDegrees = (mToDegrees - mFromDegrees) / (childCount - 1);
    Rect frame = computeChildFrame(centerX, centerY, radius, mFromDegrees + index * perDegrees, mChildSize);
    final int toXDelta = frame.left - child.getLeft();
    final int toYDelta = frame.top - child.getTop();
    Interpolator interpolator = mExpanded ? new AccelerateInterpolator() : new OvershootInterpolator(1.5f);
    final long startOffset = computeStartOffset(childCount, mExpanded, index, 0.1f, duration, interpolator);
    Animation animation = mExpanded ? createShrinkAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator) : createExpandAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator);
    final boolean isLast = getTransformedIndex(expanded, childCount, index) == childCount - 1;
    animation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (isLast) {
                postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        onAllAnimationsEnd();
                    }
                }, 0);
            }
        }
    });
    child.setAnimation(animation);
}
Also used : Rect(android.graphics.Rect) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) OvershootInterpolator(android.view.animation.OvershootInterpolator) RotateAnimation(android.view.animation.RotateAnimation) Animation(android.view.animation.Animation) Interpolator(android.view.animation.Interpolator) LinearInterpolator(android.view.animation.LinearInterpolator) OvershootInterpolator(android.view.animation.OvershootInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimationListener(android.view.animation.Animation.AnimationListener)

Aggregations

Animation (android.view.animation.Animation)80 AnimationListener (android.view.animation.Animation.AnimationListener)80 AlphaAnimation (android.view.animation.AlphaAnimation)25 TranslateAnimation (android.view.animation.TranslateAnimation)20 View (android.view.View)14 LinearInterpolator (android.view.animation.LinearInterpolator)12 RotateAnimation (android.view.animation.RotateAnimation)10 ScaleAnimation (android.view.animation.ScaleAnimation)10 ImageView (android.widget.ImageView)10 Rect (android.graphics.Rect)7 PopupWindow (android.widget.PopupWindow)6 Window (wei.mark.standout.ui.Window)6 ViewGroup (android.view.ViewGroup)5 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)5 SuppressLint (android.annotation.SuppressLint)4 Interpolator (android.view.animation.Interpolator)4 OvershootInterpolator (android.view.animation.OvershootInterpolator)4 TextView (android.widget.TextView)4 Notification (android.app.Notification)3 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)3