Search in sources :

Example 51 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project JamsMusicPlayer by psaravan.

the class QueueDrawerFragment method animatePlayToPause.

/**
     * Animates the play button to a pause button.
     */
private void animatePlayToPause() {
    //Check to make sure the current icon is the play icon.
    if (mPlayPauseButton.getId() != R.drawable.play_light)
        return;
    //Fade out the play button.
    final ScaleAnimation scaleOut = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, mPlayPauseButton.getWidth() / 2, mPlayPauseButton.getHeight() / 2);
    scaleOut.setDuration(150);
    scaleOut.setInterpolator(new AccelerateInterpolator());
    //Scale in the pause button.
    final ScaleAnimation scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, mPlayPauseButton.getWidth() / 2, mPlayPauseButton.getHeight() / 2);
    scaleIn.setDuration(150);
    scaleIn.setInterpolator(new DecelerateInterpolator());
    scaleOut.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mPlayPauseButton.setImageResource(R.drawable.pause_light);
            mPlayPauseButton.setPadding(0, 0, 0, 0);
            mPlayPauseButton.startAnimation(scaleIn);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    scaleIn.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mPlayPauseButton.setScaleX(1.0f);
            mPlayPauseButton.setScaleY(1.0f);
            mPlayPauseButton.setId(R.drawable.pause_light);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    mPlayPauseButton.startAnimation(scaleOut);
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ScaleAnimation(android.view.animation.ScaleAnimation) Animation(android.view.animation.Animation) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 52 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project JamsMusicPlayer by psaravan.

the class PlaylistPagerFragment method hideLyrics.

/**
     * Slides down the album art to hide lyrics.
     */
private void hideLyrics() {
    TranslateAnimation slideDownAnimation = new TranslateAnimation(coverArt, 400, new DecelerateInterpolator(2.0f), View.VISIBLE, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -2.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    slideDownAnimation.animate();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) TranslateAnimation(com.jams.music.player.Animations.TranslateAnimation)

Example 53 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project weiciyuan by qii.

the class FriendsTimeLineFragment method addNewDataAndRememberPositionAutoRefresh.

private void addNewDataAndRememberPositionAutoRefresh(final MessageListBean newValue) {
    int initSize = getList().getSize();
    if (getActivity() != null && newValue.getSize() > 0) {
        if (hasActionMode()) {
            AppLogger.v("ListView have ActionMode, skip notifyDataSetChanged");
            return;
        }
        final HeaderListView headerListView = (HeaderListView) getListView();
        View firstChildView = getListView().getChildAt(0);
        boolean isFirstViewHeader = headerListView.isThisViewHeader(firstChildView);
        if (isFirstViewHeader && !headerListView.isInTouchByUser()) {
            //                //Overlay is Android 4.3 method
            if (!Utility.isJB2()) {
                getList().addNewData(newValue);
                getAdapter().notifyDataSetChanged();
                Utility.setListViewItemPosition(getListView(), 0, 0, null);
                return;
            }
            //animate add item
            final ListView listView = getListView();
            final ArrayList<Pair<Long, Bitmap>> previousViewsBitmap = new ArrayList<Pair<Long, Bitmap>>();
            final HashMap<Long, Integer> previousViewsTop = new HashMap<Long, Integer>();
            final HashMap<Long, View> previousViews = new HashMap<Long, View>();
            int childCount = listView.getChildCount();
            for (int i = 0; i < childCount; i++) {
                View childView = listView.getChildAt(i);
                if (headerListView.isThisViewHeader(childView)) {
                    continue;
                }
                int firstAdapterItemPosition = listView.getFirstVisiblePosition();
                int currentAdapterItemPosition = firstAdapterItemPosition + i - listView.getHeaderViewsCount();
                long currentAdapterItemId = getAdapter().getItemId(currentAdapterItemPosition);
                int childViewTop = childView.getTop();
                Bitmap bitmap = Utility.getBitmapFromView(childView);
                Pair<Long, Bitmap> pair = new Pair<Long, Bitmap>(currentAdapterItemId, bitmap);
                previousViewsBitmap.add(pair);
                previousViewsTop.put(currentAdapterItemId, childViewTop);
                childView.setHasTransientState(true);
                previousViews.put(currentAdapterItemId, childView);
            }
            getList().addNewData(newValue);
            getAdapter().notifyDataSetChanged();
            getListView().getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

                @Override
                public boolean onPreDraw() {
                    listView.getViewTreeObserver().removeOnPreDrawListener(this);
                    DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator();
                    final ViewGroupOverlay overlay = listView.getOverlay();
                    Set<Long> previousViewsId = previousViews.keySet();
                    boolean somePreviousViewsAreStillInScreen = false;
                    ArrayList<View> newAddedItemViews = new ArrayList<View>();
                    int deltaY = 0;
                    int childCount = listView.getChildCount();
                    for (int i = 0; i < childCount; i++) {
                        View childView = listView.getChildAt(i);
                        if (headerListView.isThisViewHeader(childView)) {
                            continue;
                        }
                        int firstAdapterItemPosition = listView.getFirstVisiblePosition();
                        int currentAdapterItemPosition = firstAdapterItemPosition + i - listView.getHeaderViewsCount();
                        long currentAdapterItemId = getAdapter().getItemId(currentAdapterItemPosition);
                        if (previousViewsId.contains(currentAdapterItemId)) {
                            somePreviousViewsAreStillInScreen = true;
                            deltaY = childView.getTop() - previousViewsTop.get(currentAdapterItemId);
                        } else {
                            newAddedItemViews.add(childView);
                        }
                    }
                    if (!somePreviousViewsAreStillInScreen) {
                        deltaY = listView.getHeight();
                    }
                    for (View view : newAddedItemViews) {
                        view.setTranslationY(-deltaY);
                        view.animate().translationY(0).setInterpolator(decelerateInterpolator);
                    }
                    for (Pair<Long, Bitmap> pair : previousViewsBitmap) {
                        long id = pair.first;
                        int top = previousViewsTop.get(id);
                        final View view = previousViews.get(id);
                        final Bitmap bitmap = pair.second;
                        final ImageView imageView = new ImageView(getActivity());
                        imageView.setImageBitmap(bitmap);
                        imageView.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
                        imageView.layout(0, 0, imageView.getMeasuredWidth(), imageView.getMeasuredHeight());
                        overlay.add(imageView);
                        imageView.setTranslationY(top);
                        view.setAlpha(0);
                        imageView.animate().translationY(top + deltaY).setInterpolator(decelerateInterpolator).withEndAction(new Runnable() {

                            @Override
                            public void run() {
                                overlay.remove(imageView);
                                bitmap.recycle();
                                view.setAlpha(1.0f);
                                view.setHasTransientState(false);
                            }
                        });
                    }
                    return true;
                }
            });
            return;
        }
        getList().addNewData(newValue);
        Runnable endAction = new Runnable() {

            @Override
            public void run() {
                newMsgTipBar.setValue(newValue, false);
                newMsgTipBar.setType(TopTipBar.Type.ALWAYS);
            }
        };
        //keep current read position when user touch listview
        if (isFirstViewHeader && headerListView.isInTouchByUser()) {
            int index = getListView().getFirstVisiblePosition();
            getAdapter().notifyDataSetChanged();
            int finalSize = getList().getSize();
            final int positionAfterRefresh = index + finalSize - initSize + getListView().getHeaderViewsCount();
            //use 1 px to show newMsgTipBar
            Utility.setListViewItemPosition(getListView(), positionAfterRefresh, 1, endAction);
            return;
        }
        //need to calc the first child view's top distance
        int index = getListView().getFirstVisiblePosition();
        View firstAdapterItemView = Utility.getListViewFirstAdapterItemView(getListView());
        final int top = (firstAdapterItemView == null) ? 0 : firstAdapterItemView.getTop();
        getAdapter().notifyDataSetChanged();
        int finalSize = getList().getSize();
        final int positionAfterRefresh = index + finalSize - initSize;
        Utility.setListViewItemPosition(getListView(), positionAfterRefresh, top, endAction);
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HeaderListView(org.qii.weiciyuan.support.lib.HeaderListView) Bitmap(android.graphics.Bitmap) ListView(android.widget.ListView) HeaderListView(org.qii.weiciyuan.support.lib.HeaderListView) VelocityListView(org.qii.weiciyuan.support.lib.VelocityListView) ImageView(android.widget.ImageView) ViewTreeObserver(android.view.ViewTreeObserver) Pair(android.util.Pair) ViewGroupOverlay(android.view.ViewGroupOverlay) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) HeaderListView(org.qii.weiciyuan.support.lib.HeaderListView) VelocityListView(org.qii.weiciyuan.support.lib.VelocityListView) WifiAutoDownloadPictureRunnable(org.qii.weiciyuan.othercomponent.WifiAutoDownloadPictureRunnable)

Example 54 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project weiciyuan by qii.

the class UserInfoFragment method displayCoverPicture.

private void displayCoverPicture() {
    if (cover.getDrawable() != null) {
        return;
    }
    //        final int height = viewPager.getHeight();
    final int height = Utility.dip2px(200);
    final int width = Utility.getMaxLeftWidthOrHeightImageViewCanRead(height);
    final String picPath = userBean.getCover_image();
    blur.setAlpha(0f);
    blur.setOriImageUrl(picPath);
    ArrayList<ImageView> imageViewArrayList = new ArrayList<ImageView>();
    imageViewArrayList.add(cover);
    imageViewArrayList.add(blur);
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, -100f, Animation.RELATIVE_TO_SELF, 0f);
    animation.setDuration(3000);
    animation.setInterpolator(new DecelerateInterpolator());
    ArrayList<Animation> animationArray = new ArrayList<Animation>();
    animationArray.add(animation);
    TimeLineBitmapDownloader.getInstance().display(imageViewArrayList, width, height, picPath, FileLocationMethod.cover, animationArray);
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ArrayList(java.util.ArrayList) TranslateAnimation(android.view.animation.TranslateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) ImageView(android.widget.ImageView) BlurImageView(org.qii.weiciyuan.support.lib.BlurImageView) TimeLineAvatarImageView(org.qii.weiciyuan.support.lib.TimeLineAvatarImageView) TextPaint(android.text.TextPaint)

Example 55 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project FlyRefresh by race604.

the class FlyRefreshLayout method startRefresh.

@Override
public void startRefresh() {
    if (mFlyAnimator != null) {
        mFlyAnimator.end();
    }
    final View iconView = getIconView();
    UIUtils.clearAnimator(iconView);
    AnimatorSet flyUpAnim = new AnimatorSet();
    flyUpAnim.setDuration(800);
    ObjectAnimator transX = ObjectAnimator.ofFloat(iconView, "translationX", 0, getWidth());
    ObjectAnimator transY = ObjectAnimator.ofFloat(iconView, "translationY", 0, -mHeaderController.getHeight());
    transY.setInterpolator(PathInterpolatorCompat.create(0.7f, 1f));
    ObjectAnimator rotation = ObjectAnimator.ofFloat(iconView, "rotation", -45, 0);
    rotation.setInterpolator(new DecelerateInterpolator());
    ObjectAnimator rotationX = ObjectAnimator.ofFloat(iconView, "rotationX", 0, 60);
    rotationX.setInterpolator(new DecelerateInterpolator());
    flyUpAnim.playTogether(transX, transY, rotationX, ObjectAnimator.ofFloat(iconView, "scaleX", 1, 0.5f), ObjectAnimator.ofFloat(iconView, "scaleY", 1, 0.5f), rotation);
    mFlyAnimator = flyUpAnim;
    mFlyAnimator.start();
    if (mListener != null) {
        mListener.onRefresh(FlyRefreshLayout.this);
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) View(android.view.View) MountanScenceView(com.race604.flyrefresh.internal.MountanScenceView)

Aggregations

DecelerateInterpolator (android.view.animation.DecelerateInterpolator)312 ObjectAnimator (android.animation.ObjectAnimator)80 Animator (android.animation.Animator)66 ValueAnimator (android.animation.ValueAnimator)59 View (android.view.View)58 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)55 AnimatorSet (android.animation.AnimatorSet)52 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)36 ImageView (android.widget.ImageView)32 AlphaAnimation (android.view.animation.AlphaAnimation)30 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)29 Animation (android.view.animation.Animation)21 TextView (android.widget.TextView)20 Point (android.graphics.Point)18 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)18 Paint (android.graphics.Paint)14 LinearInterpolator (android.view.animation.LinearInterpolator)14 ScaleAnimation (android.view.animation.ScaleAnimation)14 AnimatorSet (com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet)14 ObjectAnimator (com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator)14