use of android.view.animation.LinearInterpolator in project Titanic by RomainPiel.
the class Titanic method start.
public void start(final TitanicTextView textView) {
final Runnable animate = new Runnable() {
@Override
public void run() {
textView.setSinking(true);
// horizontal animation. 200 = wave.png width
ObjectAnimator maskXAnimator = ObjectAnimator.ofFloat(textView, "maskX", 0, 200);
maskXAnimator.setRepeatCount(ValueAnimator.INFINITE);
maskXAnimator.setDuration(1000);
maskXAnimator.setStartDelay(0);
int h = textView.getHeight();
// vertical animation
// maskY = 0 -> wave vertically centered
// repeat mode REVERSE to go back and forth
ObjectAnimator maskYAnimator = ObjectAnimator.ofFloat(textView, "maskY", h / 2, -h / 2);
maskYAnimator.setRepeatCount(ValueAnimator.INFINITE);
maskYAnimator.setRepeatMode(ValueAnimator.REVERSE);
maskYAnimator.setDuration(10000);
maskYAnimator.setStartDelay(0);
// now play both animations together
animatorSet = new AnimatorSet();
animatorSet.playTogether(maskXAnimator, maskYAnimator);
animatorSet.setInterpolator(new LinearInterpolator());
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
textView.setSinking(false);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
textView.postInvalidate();
} else {
textView.postInvalidateOnAnimation();
}
animatorSet = null;
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
if (animatorListener != null) {
animatorSet.addListener(animatorListener);
}
animatorSet.start();
}
};
if (!textView.isSetUp()) {
textView.setAnimationSetupCallback(new TitanicTextView.AnimationSetupCallback() {
@Override
public void onSetupAnimation(final TitanicTextView target) {
animate.run();
}
});
} else {
animate.run();
}
}
use of android.view.animation.LinearInterpolator in project android-common by Trinea.
the class DropDownListView method initDropDownStyle.
/**
* init drop down style, only init once
*/
private void initDropDownStyle() {
if (headerLayout != null) {
if (isDropDownStyle) {
addHeaderView(headerLayout);
} else {
removeHeaderView(headerLayout);
}
return;
}
if (!isDropDownStyle) {
return;
}
headerReleaseMinDistance = context.getResources().getDimensionPixelSize(R.dimen.drop_down_list_header_release_min_distance);
flipAnimation = new RotateAnimation(0, 180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
flipAnimation.setInterpolator(new LinearInterpolator());
flipAnimation.setDuration(250);
flipAnimation.setFillAfter(true);
reverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
reverseFlipAnimation.setInterpolator(new LinearInterpolator());
reverseFlipAnimation.setDuration(250);
reverseFlipAnimation.setFillAfter(true);
headerDefaultText = context.getString(R.string.drop_down_list_header_default_text);
headerPullText = context.getString(R.string.drop_down_list_header_pull_text);
headerReleaseText = context.getString(R.string.drop_down_list_header_release_text);
headerLoadingText = context.getString(R.string.drop_down_list_header_loading_text);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
headerLayout = (RelativeLayout) inflater.inflate(R.layout.drop_down_list_header, this, false);
headerText = (TextView) headerLayout.findViewById(R.id.drop_down_list_header_default_text);
headerImage = (ImageView) headerLayout.findViewById(R.id.drop_down_list_header_image);
headerProgressBar = (ProgressBar) headerLayout.findViewById(R.id.drop_down_list_header_progress_bar);
headerSecondText = (TextView) headerLayout.findViewById(R.id.drop_down_list_header_second_text);
headerLayout.setClickable(true);
headerLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onDropDown();
}
});
headerText.setText(headerDefaultText);
addHeaderView(headerLayout);
measureHeaderLayout(headerLayout);
headerOriginalHeight = headerLayout.getMeasuredHeight();
headerOriginalTopPadding = headerLayout.getPaddingTop();
currentHeaderStatus = HEADER_STATUS_CLICK_TO_LOAD;
}
use of android.view.animation.LinearInterpolator in project StarWars.Android by Yalantis.
the class BackgroundDrawableSwitchCompat method startAnimation.
private void startAnimation(boolean firstToSecond) {
if (animator != null) {
animator.cancel();
}
animator = ValueAnimator.ofInt(firstToSecond ? OPAQUE : TRANSPARENT, firstToSecond ? TRANSPARENT : OPAQUE);
animator.setDuration(THUMB_ANIMATION_DURATION);
animator.setInterpolator(new LinearInterpolator());
// animator.setRepeatMode(ValueAnimator.RESTART);
// animator.setRepeatCount(ValueAnimator.INFINITE);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mFirstDrawableAlpha = (int) animation.getAnimatedValue();
mSecondDrawableAlpha = OPAQUE - (int) animation.getAnimatedValue();
invalidate();
}
});
animator.start();
}
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;
}
}
Aggregations