Search in sources :

Example 41 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project android-fb-like-slideout-navigation by AlexKorovyansky.

the class SlideoutHelper method initAnimations.

protected void initAnimations() {
    int displayWidth = ((WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
    final int shift = (mReverse ? -1 : 1) * (sWidth - displayWidth);
    mStartAnimation = new TranslateAnimation(TranslateAnimation.ABSOLUTE, 0, TranslateAnimation.ABSOLUTE, -shift, TranslateAnimation.ABSOLUTE, 0, TranslateAnimation.ABSOLUTE, 0);
    mStopAnimation = new TranslateAnimation(TranslateAnimation.ABSOLUTE, 0, TranslateAnimation.ABSOLUTE, shift, TranslateAnimation.ABSOLUTE, 0, TranslateAnimation.ABSOLUTE, 0);
    mStartAnimation.setDuration(DURATION_MS);
    mStartAnimation.setFillAfter(true);
    mStartAnimation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mCover.setAnimation(null);
            @SuppressWarnings("deprecation") final android.widget.AbsoluteLayout.LayoutParams lp = new android.widget.AbsoluteLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, -shift, 0);
            mCover.setLayoutParams(lp);
        }
    });
    mStopAnimation.setDuration(DURATION_MS);
    mStopAnimation.setFillAfter(true);
    mStopAnimation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mActivity.finish();
            mActivity.overridePendingTransition(0, 0);
        }
    });
}
Also used : LayoutParams(android.widget.RelativeLayout.LayoutParams) TranslateAnimation(android.view.animation.TranslateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 42 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project Roundr by MohammadAdib.

the class StandOutWindow method close.

/**
	 * Close a window corresponding to the id.
	 * 
	 * @param id
	 *            The id of the window.
	 */
public final synchronized void close(final int id) {
    // get the view corresponding to the id
    final Window window = getWindow(id);
    if (window == null) {
        return;
    }
    if (window.visibility == Window.VISIBILITY_TRANSITION) {
        return;
    }
    // alert callbacks and cancel if instructed
    if (onClose(id, window)) {
        Log.w(TAG, "Window " + id + " close cancelled by implementation.");
        return;
    }
    // remove hidden notification
    mNotificationManager.cancel(getClass().hashCode() + id);
    unfocus(window);
    window.visibility = Window.VISIBILITY_TRANSITION;
    // get animation
    Animation animation = getCloseAnimation(id);
    // remove window
    try {
        // animate
        if (animation != null) {
            animation.setAnimationListener(new AnimationListener() {

                @Override
                public void onAnimationStart(Animation animation) {
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    // remove the window from the window manager
                    mWindowManager.removeView(window);
                    window.visibility = Window.VISIBILITY_GONE;
                    // remove view from internal map
                    sWindowCache.removeCache(id, StandOutWindow.this.getClass());
                    // if we just released the last window, quit
                    if (getExistingIds().size() == 0) {
                        // tell Android to remove the persistent
                        // notification
                        // the Service will be shutdown by the system on low
                        // memory
                        startedForeground = false;
                        stopForeground(true);
                    }
                }
            });
            window.getChildAt(0).startAnimation(animation);
        } else {
            // remove the window from the window manager
            mWindowManager.removeView(window);
            // remove view from internal map
            sWindowCache.removeCache(id, getClass());
            // if we just released the last window, quit
            if (sWindowCache.getCacheSize(getClass()) == 0) {
                // tell Android to remove the persistent notification
                // the Service will be shutdown by the system on low memory
                startedForeground = false;
                stopForeground(true);
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : Window(wei.mark.standout.ui.Window) PopupWindow(android.widget.PopupWindow) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 43 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project JustAndroid by chinaltz.

the class AbAnimationUtil method playLandAnimation.

/**
     * 跳动-落下动画.
     *
     * @param view the view
     * @param offsetY the offset y
     */
private void playLandAnimation(final View view, final float offsetY) {
    float originalY = -offsetY;
    float finalY = 0;
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(new TranslateAnimation(0, 0, originalY, finalY));
    animationSet.setDuration(200);
    animationSet.setInterpolator(new AccelerateInterpolator());
    animationSet.setFillAfter(true);
    animationSet.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            //两秒后再调
            view.postDelayed(new Runnable() {

                @Override
                public void run() {
                    playJumpAnimation(view, offsetY);
                }
            }, 2000);
        }
    });
    view.startAnimation(animationSet);
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation) ScaleAnimation(android.view.animation.ScaleAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) RotateAnimation(android.view.animation.RotateAnimation) AnimationListener(android.view.animation.Animation.AnimationListener) AnimationSet(android.view.animation.AnimationSet)

Example 44 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project JustAndroid by chinaltz.

the class AbAnimationUtil method playJumpAnimation.

/**
	 * 跳动-跳起动画.
	 *
	 * @param view the view
	 * @param offsetY the offset y
	 */
private void playJumpAnimation(final View view, final float offsetY) {
    float originalY = 0;
    float finalY = -offsetY;
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(new TranslateAnimation(0, 0, originalY, finalY));
    animationSet.setDuration(300);
    animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animationSet.setFillAfter(true);
    animationSet.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            playLandAnimation(view, offsetY);
        }
    });
    view.startAnimation(animationSet);
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) ScaleAnimation(android.view.animation.ScaleAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) RotateAnimation(android.view.animation.RotateAnimation) AnimationListener(android.view.animation.Animation.AnimationListener) AnimationSet(android.view.animation.AnimationSet)

Example 45 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project superCleanMaster by joyoyao.

the class SplishActivity method setListener.

/**
     * 监听事件
     */
public void setListener() {
    /**
         * 动画切换原理:开始时是用第一个渐现动画,当第一个动画结束时开始第二个放大动画,当第二个动画结束时调用第三个渐隐动画,
         * 第三个动画结束时修改显示的内容并且重新调用第一个动画,从而达到循环效果
         */
    mFadeIn.setAnimationListener(new AnimationListener() {

        public void onAnimationStart(Animation animation) {
        }

        public void onAnimationRepeat(Animation animation) {
        }

        public void onAnimationEnd(Animation animation) {
            mImageView.startAnimation(mFadeInScale);
        }
    });
    mFadeInScale.setAnimationListener(new AnimationListener() {

        public void onAnimationStart(Animation animation) {
        }

        public void onAnimationRepeat(Animation animation) {
        }

        public void onAnimationEnd(Animation animation) {
            startActivity(MainActivity.class);
            finish();
        // mImageView.startAnimation(mFadeOut);
        }
    });
    mFadeOut.setAnimationListener(new AnimationListener() {

        public void onAnimationStart(Animation animation) {
        }

        public void onAnimationRepeat(Animation animation) {
        }

        public void onAnimationEnd(Animation animation) {
        // startActivity(MainActivity.class);
        }
    });
}
Also used : Animation(android.view.animation.Animation) 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