Search in sources :

Example 36 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project remusic by aa112901.

the class PlayingActivity method setViewPager.

private void setViewPager() {
    mViewPager.setOffscreenPageLimit(2);
    PlaybarPagerTransformer transformer = new PlaybarPagerTransformer();
    mAdapter = new FragmentAdapter(getSupportFragmentManager());
    mViewPager.setAdapter(mAdapter);
    mViewPager.setPageTransformer(true, transformer);
    // 改变viewpager动画时间
    try {
        Field mField = ViewPager.class.getDeclaredField("mScroller");
        mField.setAccessible(true);
        MyScroller mScroller = new MyScroller(mViewPager.getContext().getApplicationContext(), new LinearInterpolator());
        mField.set(mViewPager, mScroller);
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(final int pPosition) {
            if (pPosition < 1) {
                //首位之前,跳转到末尾(N)
                MusicPlayer.setQueuePosition(MusicPlayer.getQueue().length);
                mViewPager.setCurrentItem(MusicPlayer.getQueue().length, false);
                isNextOrPreSetPage = false;
                return;
            } else if (pPosition > MusicPlayer.getQueue().length) {
                //末位之后,跳转到首位(1)
                MusicPlayer.setQueuePosition(0);
                //false:不显示跳转过程的动画
                mViewPager.setCurrentItem(1, false);
                isNextOrPreSetPage = false;
                return;
            } else {
                if (!isNextOrPreSetPage) {
                    if (pPosition < MusicPlayer.getQueuePosition() + 1) {
                        //                            HandlerUtil.getInstance(PlayingActivity.this).postDelayed(new Runnable() {
                        //                                @Override
                        //                                public void run() {
                        //                                  //  MusicPlayer.previous(PlayingActivity.this, true);
                        //                                    Message msg = new Message();
                        //                                    msg.what = 0;
                        //                                    mPlayHandler.sendMessage(msg);
                        //                                }
                        //                            }, 500);
                        Message msg = new Message();
                        msg.what = PRE_MUSIC;
                        mPlayHandler.sendMessageDelayed(msg, TIME_DELAY);
                    } else if (pPosition > MusicPlayer.getQueuePosition() + 1) {
                        //                            HandlerUtil.getInstance(PlayingActivity.this).postDelayed(new Runnable() {
                        //                                @Override
                        //                                public void run() {
                        //                                  //  MusicPlayer.mNext();
                        //
                        //
                        //                                }
                        //                            }, 500);
                        Message msg = new Message();
                        msg.what = NEXT_MUSIC;
                        mPlayHandler.sendMessageDelayed(msg, TIME_DELAY);
                    }
                }
            }
            //MusicPlayer.setQueuePosition(pPosition - 1);
            isNextOrPreSetPage = false;
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageScrollStateChanged(int pState) {
        }
    });
}
Also used : Message(android.os.Message) AlbumViewPager(com.wm.remusic.widget.AlbumViewPager) ViewPager(android.support.v4.view.ViewPager) Field(java.lang.reflect.Field) LinearInterpolator(android.view.animation.LinearInterpolator)

Example 37 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project remusic by aa112901.

the class PlayingActivity method updateTrackInfo.

public void updateTrackInfo() {
    if (MusicPlayer.getQueueSize() == 0) {
        return;
    }
    Fragment fragment = (RoundFragment) mViewPager.getAdapter().instantiateItem(mViewPager, mViewPager.getCurrentItem());
    if (fragment != null) {
        View v = fragment.getView();
        if (mViewWeakReference.get() != v && v != null) {
            ((ViewGroup) v).setAnimationCacheEnabled(false);
            if (mViewWeakReference != null)
                mViewWeakReference.clear();
            mViewWeakReference = new WeakReference<View>(v);
            mActiveView = mViewWeakReference.get();
        }
    }
    if (mActiveView != null) {
        //            animatorWeakReference = new WeakReference<>((ObjectAnimator) mActiveView.getTag(R.id.tag_animator));
        //            mRotateAnim = animatorWeakReference.get();
        mRotateAnim = (ObjectAnimator) mActiveView.getTag(R.id.tag_animator);
    }
    //mProgress.setMax((int) MusicPlayer.mDuration());
    mAnimatorSet = new AnimatorSet();
    if (MusicPlayer.isPlaying()) {
        mProgress.removeCallbacks(mUpdateProgress);
        mProgress.postDelayed(mUpdateProgress, 200);
        mControl.setImageResource(R.drawable.play_rdi_btn_pause);
        if (mAnimatorSet != null && mRotateAnim != null && !mRotateAnim.isRunning()) {
            //修复从playactivity回到Main界面null
            if (mNeedleAnim == null) {
                mNeedleAnim = ObjectAnimator.ofFloat(mNeedle, "rotation", -30, 0);
                mNeedleAnim.setDuration(200);
                mNeedleAnim.setRepeatMode(0);
                mNeedleAnim.setInterpolator(new LinearInterpolator());
            }
            mAnimatorSet.play(mNeedleAnim).before(mRotateAnim);
            mAnimatorSet.start();
        }
    } else {
        mProgress.removeCallbacks(mUpdateProgress);
        mControl.setImageResource(R.drawable.play_rdi_btn_play);
        if (mNeedleAnim != null) {
            mNeedleAnim.reverse();
            mNeedleAnim.end();
        }
        if (mRotateAnim != null && mRotateAnim.isRunning()) {
            mRotateAnim.cancel();
            float valueAvatar = (float) mRotateAnim.getAnimatedValue();
            mRotateAnim.setFloatValues(valueAvatar, 360f + valueAvatar);
        }
    }
    isNextOrPreSetPage = false;
    if (MusicPlayer.getQueuePosition() + 1 != mViewPager.getCurrentItem()) {
        mViewPager.setCurrentItem(MusicPlayer.getQueuePosition() + 1);
        isNextOrPreSetPage = true;
    }
}
Also used : RoundFragment(com.wm.remusic.fragment.RoundFragment) LinearInterpolator(android.view.animation.LinearInterpolator) ViewGroup(android.view.ViewGroup) AnimatorSet(android.animation.AnimatorSet) PlayQueueFragment(com.wm.remusic.fragment.PlayQueueFragment) Fragment(android.support.v4.app.Fragment) RoundFragment(com.wm.remusic.fragment.RoundFragment) SimpleMoreFragment(com.wm.remusic.fragment.SimpleMoreFragment) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) LrcView(com.wm.remusic.lrc.LrcView)

Example 38 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project remusic by aa112901.

the class RoundFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    //        animatorWeakReference = new  WeakReference<ObjectAnimator>(new ObjectAnimator());
    //        animator = animatorWeakReference.get();
    animatorWeakReference = new WeakReference(ObjectAnimator.ofFloat(getView(), "rotation", new float[] { 0.0F, 360.0F }));
    animator = animatorWeakReference.get();
    //animator = ObjectAnimator.ofFloat(getView(), "rotation", new float[]{0.0F, 360.0F});
    animator.setRepeatCount(Integer.MAX_VALUE);
    animator.setDuration(25000L);
    animator.setInterpolator(new LinearInterpolator());
    if (getView() != null)
        getView().setTag(R.id.tag_animator, this.animator);
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) WeakReference(java.lang.ref.WeakReference)

Example 39 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project remusic by aa112901.

the class RecommendFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mContent = (ViewGroup) inflater.inflate(R.layout.fragment_recommend_container, container, false);
    mLayoutInflater = LayoutInflater.from(mContext);
    mRecommendView = mLayoutInflater.inflate(R.layout.recommend, container, false);
    String date = Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "";
    TextView dailyText = (TextView) mRecommendView.findViewById(R.id.daily_text);
    dailyText.setText(date);
    mItemLayout = (LinearLayout) mRecommendView.findViewById(R.id.item_change);
    mViewContent = (LinearLayout) mRecommendView.findViewById(R.id.recommend_layout);
    if (!PreferencesUtility.getInstance(mContext).isCurrentDayFirst(date)) {
        PreferencesUtility.getInstance(mContext).setCurrentDate(date);
        View dayRec = mLayoutInflater.inflate(R.layout.loading_daymusic, container, false);
        ImageView view1 = (ImageView) dayRec.findViewById(R.id.loading_dayimage);
        RotateAnimation rotateAnimation = new RotateAnimation(0, 360, 1, 0.5F, 1, 0.5F);
        rotateAnimation.setDuration(20000L);
        rotateAnimation.setInterpolator(new LinearInterpolator());
        rotateAnimation.setRepeatCount(Animation.INFINITE);
        rotateAnimation.setRepeatMode(Animation.INFINITE);
        view1.startAnimation(rotateAnimation);
        isDayFirst = true;
        mContent.addView(dayRec);
    }
    mLoadView = mLayoutInflater.inflate(R.layout.loading, null, false);
    mItemLayout.setVisibility(View.INVISIBLE);
    mViewContent.addView(mLoadView);
    mRecomendAdapter = new RecommendAdapter(null);
    mNewAlbumsAdapter = new NewAlbumsAdapter(null);
    mRadioAdapter = new RadioAdapter(null);
    TextView change = (TextView) mRecommendView.findViewById(R.id.change_item_position);
    change.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent itent = new Intent(mContext, NetItemChangeActivity.class);
            mContext.startActivity(itent);
        }
    });
    mLoodView = (LoodView) mRecommendView.findViewById(R.id.loop_view);
    if (!isDayFirst) {
        mContent.addView(mRecommendView);
    }
    return mContent;
}
Also used : Intent(android.content.Intent) SpannableString(android.text.SpannableString) ImageView(android.widget.ImageView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) LoodView(com.wm.remusic.widget.LoodView) NetItemChangeActivity(com.wm.remusic.activity.NetItemChangeActivity) RotateAnimation(android.view.animation.RotateAnimation) LinearInterpolator(android.view.animation.LinearInterpolator) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 40 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project android_frameworks_base by ParanoidAndroid.

the class KeyguardGlowStripView method makeEmGo.

public void makeEmGo() {
    if (mAnimator != null) {
        mAnimator.cancel();
    }
    float from = mLeftToRight ? 0f : 1f;
    float to = mLeftToRight ? 1f : 0f;
    mAnimator = ValueAnimator.ofFloat(from, to);
    mAnimator.setDuration(DURATION);
    mAnimator.setInterpolator(new LinearInterpolator());
    mAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mDrawDots = false;
            // make sure we draw one frame at the end with everything gone.
            invalidate();
        }

        @Override
        public void onAnimationStart(Animator animation) {
            mDrawDots = true;
        }
    });
    mAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mAnimationProgress = (Float) animation.getAnimatedValue();
            invalidate();
        }
    });
    mAnimator.start();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) LinearInterpolator(android.view.animation.LinearInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator)

Aggregations

LinearInterpolator (android.view.animation.LinearInterpolator)217 ValueAnimator (android.animation.ValueAnimator)65 Animator (android.animation.Animator)42 ObjectAnimator (android.animation.ObjectAnimator)39 Paint (android.graphics.Paint)30 ArrayList (java.util.ArrayList)28 AlphaAnimation (android.view.animation.AlphaAnimation)27 RotateAnimation (android.view.animation.RotateAnimation)24 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)22 PropertyValuesHolder (android.animation.PropertyValuesHolder)18 Animatable (android.graphics.drawable.Animatable)17 View (android.view.View)17 Animation (android.view.animation.Animation)17 Transformation (android.view.animation.Transformation)17 AnimatorSet (android.animation.AnimatorSet)14 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)14 TranslateAnimation (android.view.animation.TranslateAnimation)12 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)11 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)9 AnimationListener (android.view.animation.Animation.AnimationListener)8