Search in sources :

Example 1 with RoundFragment

use of com.wm.remusic.fragment.RoundFragment 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)

Aggregations

AnimatorSet (android.animation.AnimatorSet)1 Fragment (android.support.v4.app.Fragment)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 LinearInterpolator (android.view.animation.LinearInterpolator)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 PlayQueueFragment (com.wm.remusic.fragment.PlayQueueFragment)1 RoundFragment (com.wm.remusic.fragment.RoundFragment)1 SimpleMoreFragment (com.wm.remusic.fragment.SimpleMoreFragment)1 LrcView (com.wm.remusic.lrc.LrcView)1