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;
}
}
Aggregations