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) {
}
});
}
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;
}
}
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);
}
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;
}
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();
}
Aggregations