Search in sources :

Example 36 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project android_packages_apps_Camera by CyanogenMod.

the class PieRenderer method openCurrentItem.

private void openCurrentItem() {
    if ((mCurrentItem != null) && mCurrentItem.hasItems()) {
        mCurrentItem.setSelected(false);
        mOpenItem = mCurrentItem;
        mOpening = true;
        mXFade = new LinearAnimation(1, 0);
        mXFade.setDuration(PIE_XFADE_DURATION);
        mXFade.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mXFade = null;
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        mXFade.startNow();
        mOverlay.startAnimation(mXFade);
    }
}
Also used : Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 37 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project android_packages_apps_Camera by CyanogenMod.

the class PieRenderer method fadeIn.

private void fadeIn() {
    mFadeIn = new LinearAnimation(0, 1);
    mFadeIn.setDuration(PIE_FADE_IN_DURATION);
    mFadeIn.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mFadeIn = null;
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    mFadeIn.startNow();
    mOverlay.startAnimation(mFadeIn);
}
Also used : Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 38 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project android-toolbox by Knickedi.

the class ViewStateFlipper method initialize.

// PRIVATE ====================================================================================
private void initialize(AttributeSet attrs) {
    mCachedState = new ImageView(getContext());
    mCachedState.setVisibility(View.GONE);
    super.addView(mCachedState, -1, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    mAnimationListener = new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mCachedState.setVisibility(View.GONE);
        }
    };
    if (attrs == null) {
        return;
    }
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ViewStateFlipper);
    int res;
    if ((res = a.getResourceId(R.styleable.ViewStateFlipper_animationIn, 0)) != 0) {
        setAnimation(AnimType.IN, AnimationUtils.loadAnimation(getContext(), res));
    }
    if ((res = a.getResourceId(R.styleable.ViewStateFlipper_animationOut, 0)) != 0) {
        setAnimation(AnimType.OUT, AnimationUtils.loadAnimation(getContext(), res));
    }
    if ((res = a.getResourceId(R.styleable.ViewStateFlipper_animationReverseIn, 0)) != 0) {
        setAnimation(AnimType.IN_REVERSE, AnimationUtils.loadAnimation(getContext(), res));
    }
    if ((res = a.getResourceId(R.styleable.ViewStateFlipper_animationReverseOut, 0)) != 0) {
        setAnimation(AnimType.OUT_REVERSE, AnimationUtils.loadAnimation(getContext(), res));
    }
    a.recycle();
}
Also used : FrameLayout(android.widget.FrameLayout) TypedArray(android.content.res.TypedArray) Animation(android.view.animation.Animation) ImageView(android.widget.ImageView) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 39 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project Android-SlideExpandableListView by tjerkw.

the class AbstractSlideExpandableListAdapter method animateView.

/**
 * Performs either COLLAPSE or EXPAND animation on the target view
 * @param target the view to animate
 * @param type the animation type, either ExpandCollapseAnimation.COLLAPSE
 *			 or ExpandCollapseAnimation.EXPAND
 */
private void animateView(final View target, final int type) {
    Animation anim = new ExpandCollapseAnimation(target, type);
    anim.setDuration(getAnimationDuration());
    anim.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (type == ExpandCollapseAnimation.EXPAND) {
                if (parent instanceof ListView) {
                    ListView listView = (ListView) parent;
                    int movement = target.getBottom();
                    Rect r = new Rect();
                    boolean visible = target.getGlobalVisibleRect(r);
                    Rect r2 = new Rect();
                    listView.getGlobalVisibleRect(r2);
                    if (!visible) {
                        listView.smoothScrollBy(movement, getAnimationDuration());
                    } else {
                        if (r2.bottom == r.bottom) {
                            listView.smoothScrollBy(movement, getAnimationDuration());
                        }
                    }
                }
            }
        }
    });
    target.startAnimation(anim);
}
Also used : Rect(android.graphics.Rect) ListView(android.widget.ListView) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 40 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project StandOut by pingpongboss.

the class StandOutWindow method hide.

/**
 * Hide a window corresponding to the id. Show a notification for the hidden
 * window.
 *
 * @param id
 *            The id of the window.
 */
public final synchronized void hide(int id) {
    // get the view corresponding to the id
    final Window window = getWindow(id);
    if (window == null) {
        throw new IllegalArgumentException("Tried to hide(" + id + ") a null window.");
    }
    // alert callbacks and cancel if instructed
    if (onHide(id, window)) {
        Log.d(TAG, "Window " + id + " hide cancelled by implementation.");
        return;
    }
    // ignore if window is already hidden
    if (window.visibility == Window.VISIBILITY_GONE) {
        Log.d(TAG, "Window " + id + " is already hidden.");
    }
    // check if hide enabled
    if (Utils.isSet(window.flags, StandOutFlags.FLAG_WINDOW_HIDE_ENABLE)) {
        window.visibility = Window.VISIBILITY_TRANSITION;
        // get the hidden notification for this view
        Notification notification = getHiddenNotification(id);
        // get animation
        Animation animation = getHideAnimation(id);
        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;
                    }
                });
                window.getChildAt(0).startAnimation(animation);
            } else {
                // remove the window from the window manager
                mWindowManager.removeView(window);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        // display the notification
        notification.flags = notification.flags | Notification.FLAG_NO_CLEAR | Notification.FLAG_AUTO_CANCEL;
        mNotificationManager.notify(getClass().hashCode() + id, notification);
    } else {
        // if hide not enabled, close window
        close(id);
    }
}
Also used : Window(wei.mark.standout.ui.Window) PopupWindow(android.widget.PopupWindow) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener) Notification(android.app.Notification)

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