Search in sources :

Example 56 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project FloatingStickies 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) {
        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);
                        }
                    }
                });
                gracePeriod = System.currentTimeMillis();
                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 57 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project FlycoDialog_Master by H07000223.

the class BottomTopBaseDialog method showWithAnim.

/** show dialog and mAnimateView with inner show com.flyco.animation(设置dialog和animateView显示动画) */
protected void showWithAnim() {
    if (mInnerShowAnim != null) {
        mInnerShowAnim.setDuration(mInnerAnimDuration);
        mInnerShowAnim.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                mIsInnerShowAnim = true;
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mIsInnerShowAnim = false;
            }
        });
        mLlControlHeight.startAnimation(mInnerShowAnim);
    }
    if (mAnimateView != null) {
        if (getWindowInAs() != null) {
            mWindowInAs = getWindowInAs();
        }
        mWindowInAs.duration(mInnerAnimDuration).playOn(mAnimateView);
    }
}
Also used : Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 58 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project KeepScore by nolanlawson.

the class PlayerView method fadeOutBadge.

private void fadeOutBadge(final Runnable onAnimationComplete) {
    synchronized (lock) {
        if (// animation is already running, so shouldn't
        !animationRunning.get() && // start a new one
        lastIncremented.get() != // counter was reset, in which
        0 && // to fade
        badgeTextView.getVisibility() == View.VISIBLE) {
            // animation isn't already showing, and the badge is visible
            animationRunning.set(true);
            animationWasCanceled.set(false);
            badgeLinearLayout.setVisibility(View.VISIBLE);
            // show an animation for the badge with the textview and the
            // background linearlayout fading out
            Animation fadeOutAnimation = AnimationUtils.loadAnimation(context, android.R.anim.fade_out);
            fadeOutAnimation.setDuration(ANIMATION_TIME);
            fadeOutAnimation.setAnimationListener(new AnimationListener() {

                @Override
                public void onAnimationStart(Animation animation) {
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    synchronized (lock) {
                        log.d("onAnimationEnd, setting visiblity to invisible");
                        if (!animationWasCanceled.get()) {
                            badgeTextView.setVisibility(View.INVISIBLE);
                        }
                        // necessary to update again to set the history text
                        // view correctly
                        onAnimationComplete.run();
                        animationRunning.set(false);
                    }
                }
            });
            badgeTextView.setAnimation(fadeOutAnimation);
            fadeOutAnimation.start();
            TransitionDrawable transitionDrawable = (TransitionDrawable) badgeLinearLayout.getBackground();
            transitionDrawable.setCrossFadeEnabled(true);
            transitionDrawable.startTransition(ANIMATION_TIME);
        } else {
            // just don't show it - the animation might already be showing,
            // or maybe the badge is
            // already invisible
            badgeLinearLayout.setVisibility(View.INVISIBLE);
            badgeTextView.setVisibility(View.INVISIBLE);
            // this ensures that the history text view gets updated
            // properly, even if the user
            // exits the activity while the animation is in progress (e.g.
            // by going to the Settings)
            onAnimationComplete.run();
        }
    }
}
Also used : TransitionDrawable(android.graphics.drawable.TransitionDrawable) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 59 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project platform_frameworks_base by android.

the class SlidingTab method startAnimating.

void startAnimating(final boolean holdAfter) {
    mAnimating = true;
    final Animation trans1;
    final Animation trans2;
    final Slider slider = mCurrentSlider;
    final Slider other = mOtherSlider;
    final int dx;
    final int dy;
    if (isHorizontal()) {
        int right = slider.tab.getRight();
        int width = slider.tab.getWidth();
        int left = slider.tab.getLeft();
        int viewWidth = getWidth();
        // how much of tab to show at the end of anim
        int holdOffset = holdAfter ? 0 : width;
        dx = slider == mRightSlider ? -(right + viewWidth - holdOffset) : (viewWidth - left) + viewWidth - holdOffset;
        dy = 0;
    } else {
        int top = slider.tab.getTop();
        int bottom = slider.tab.getBottom();
        int height = slider.tab.getHeight();
        int viewHeight = getHeight();
        // how much of tab to show at end of anim
        int holdOffset = holdAfter ? 0 : height;
        dx = 0;
        dy = slider == mRightSlider ? (top + viewHeight - holdOffset) : -((viewHeight - bottom) + viewHeight - holdOffset);
    }
    trans1 = new TranslateAnimation(0, dx, 0, dy);
    trans1.setDuration(ANIM_DURATION);
    trans1.setInterpolator(new LinearInterpolator());
    trans1.setFillAfter(true);
    trans2 = new TranslateAnimation(0, dx, 0, dy);
    trans2.setDuration(ANIM_DURATION);
    trans2.setInterpolator(new LinearInterpolator());
    trans2.setFillAfter(true);
    trans1.setAnimationListener(new AnimationListener() {

        public void onAnimationEnd(Animation animation) {
            Animation anim;
            if (holdAfter) {
                anim = new TranslateAnimation(dx, dx, dy, dy);
                // plenty of time for transitions
                anim.setDuration(1000);
                mAnimating = false;
            } else {
                anim = new AlphaAnimation(0.5f, 1.0f);
                anim.setDuration(ANIM_DURATION);
                resetView();
            }
            anim.setAnimationListener(mAnimationDoneListener);
            /* Animation can be the same for these since the animation just holds */
            mLeftSlider.startAnimation(anim, anim);
            mRightSlider.startAnimation(anim, anim);
        }

        public void onAnimationRepeat(Animation animation) {
        }

        public void onAnimationStart(Animation animation) {
        }
    });
    slider.hideTarget();
    slider.startAnimation(trans1, trans2);
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation) AnimationListener(android.view.animation.Animation.AnimationListener) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 60 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project Fairphone by Kwamecorp.

the class EdgeSwipeAppMenuHelper method setMenuSideExitAnimation.

private void setMenuSideExitAnimation() {
    // draw back the menu
    // load the correct side for the animation
    Animation animation = null;
    if (getCurrentSide() == Side.LEFT) {
        animation = AnimationUtils.loadAnimation(menuRoot.getContext(), R.anim.menu_disappear_to_left_animation);
    } else {
        animation = AnimationUtils.loadAnimation(menuRoot.getContext(), R.anim.menu_disappear_to_right_animation);
    }
    getMenuContainerView().setVisibility(View.VISIBLE);
    contentVisible = true;
    backVisible = true;
    animation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            menuRoot.setVisibility(View.INVISIBLE);
            contentVisible = false;
            if (!backVisible) {
                getMenuContainerView().setVisibility(View.GONE);
            }
        }
    });
    menuContent.startAnimation(animation);
}
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