private void setupAnimations() { mObjectAnimatorAngle = ObjectAnimator.ofFloat(this, mAngleProperty, 360f); mObjectAnimatorAngle.setInterpolator(ANGLE_INTERPOLATOR); mObjectAnimatorAngle.setDuration(ANGLE_ANIMATOR_DURATION); mObjectAnimatorAngle.setRepeatMode(ValueAnimator.RESTART); mObjectAnimatorAngle.setRepeatCount(ValueAnimator.INFINITE); mObjectAnimatorSweep = ObjectAnimator.ofFloat(this, mSweepProperty, 360f - MIN_SWEEP_ANGLE * 2); mObjectAnimatorSweep.setInterpolator(SWEEP_INTERPOLATOR); mObjectAnimatorSweep.setDuration(SWEEP_ANIMATOR_DURATION); mObjectAnimatorSweep.setRepeatMode(ValueAnimator.RESTART); mObjectAnimatorSweep.setRepeatCount(ValueAnimator.INFINITE); mObjectAnimatorSweep.addListener( new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) {} @Override public void onAnimationEnd(Animator animation) {} @Override public void onAnimationCancel(Animator animation) {} @Override public void onAnimationRepeat(Animator animation) { toggleAppearingMode(); } }); }
// 初始化歌曲列表 private void initLocalMusicList() { // fileInfos = MediaUtil.getFileInfos(getApplicationContext()); //获取歌曲对象集合 setListAdpter(MediaUtil.getMusicMaps(fileInfos)); // 显示歌曲列表 music_siger_tv.setText(fileInfos.get(listPosition).getArtist()); music_name_tv.setText(fileInfos.get(listPosition).getTitle()); music_play_bt.setPressed(play_bt_press); music_play_bt.setChecked(play_bt_check); anim = ObjectAnimator.ofFloat(music_album_iv, "rotation", 0, 360); lin = new LinearInterpolator(); anim.setDuration(6000); anim.setRepeatCount(-1); anim.setRepeatMode(ObjectAnimator.RESTART); anim.setInterpolator(lin); // 匀速 PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("alpha", 1f, 0f, 1f); PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("scaleX", 1f, 0, 1f); PropertyValuesHolder pvhZ = PropertyValuesHolder.ofFloat("scaleY", 1f, 0, 1f); animSongName = ObjectAnimator.ofPropertyValuesHolder(music_name_tv, pvhX, pvhY, pvhZ); // 渐现 animSongName.setDuration(1000); animSongName.setRepeatCount(0); animSongName.setRepeatMode(ObjectAnimator.RESTART); animSongSinger = ObjectAnimator.ofPropertyValuesHolder(music_siger_tv, pvhX, pvhY, pvhZ); // 渐现 animSongSinger.setDuration(1000); animSongSinger.setRepeatCount(0); animSongSinger.setRepeatMode(ObjectAnimator.RESTART); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); WaveProgressView waveProgressView = (WaveProgressView) findViewById(R.id.wave_progress_view); waveProgressView.setMax(100); ObjectAnimator progressAnim = ObjectAnimator.ofInt(waveProgressView, "progress", 0, waveProgressView.getMax()); progressAnim.setDuration(10 * 1000); progressAnim.setRepeatCount(ObjectAnimator.INFINITE); progressAnim.setRepeatMode(ObjectAnimator.RESTART); progressAnim.start(); waveProgressView = (WaveProgressView) findViewById(R.id.wave_progress_view_2); progressAnim = ObjectAnimator.ofInt(waveProgressView, "progress", 0, waveProgressView.getMax()); progressAnim.setDuration(15 * 1000); progressAnim.setRepeatCount(ObjectAnimator.INFINITE); progressAnim.setRepeatMode(ObjectAnimator.RESTART); progressAnim.start(); }
protected void flashButtons() { updateLevel(); btnsToFlash = new int[game.gameArray.size()]; for (int i = 0; i < game.gameArray.size(); i++) { switch (game.gameArray.get(i)) { case 1: btnsToFlash[i] = R.id.b1; break; case 2: btnsToFlash[i] = R.id.b2; break; case 3: btnsToFlash[i] = R.id.b3; break; case 4: btnsToFlash[i] = R.id.b4; break; } } ArrayList<ObjectAnimator> anims = new ArrayList<>(); counter = 0; for (int viewId : btnsToFlash) { ImageButton imgBtn = (ImageButton) findViewById(viewId); ObjectAnimator flashBtn = ObjectAnimator.ofFloat(imgBtn, "alpha", 1.0f, 0.0f); flashBtn.setRepeatCount(1); flashBtn.setRepeatMode(ObjectAnimator.REVERSE); flashBtn.setDuration(300); flashBtn.setStartDelay((counter * 500) + 500); anims.add(flashBtn); counter++; } counter = 0; for (ObjectAnimator anim : anims) { anim.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); currentButton = btnsToFlash[counter]; buttonPlayer.playButton(getApplicationContext(), currentButton); counter++; } }); anim.start(); } }
public void testIsStarted() throws Throwable { Object object = mActivity.view.newBall; String property = "y"; float startY = mActivity.mStartY; float endY = mActivity.mStartY + mActivity.mDeltaY; Interpolator interpolator = new AccelerateInterpolator(); ObjectAnimator objAnimator = ObjectAnimator.ofFloat(object, property, startY, endY); objAnimator.setDuration(mDuration); objAnimator.setRepeatCount(ValueAnimator.INFINITE); objAnimator.setInterpolator(interpolator); objAnimator.setRepeatMode(ValueAnimator.REVERSE); startAnimation(objAnimator); Thread.sleep(100); assertTrue(objAnimator.isStarted()); Thread.sleep(100); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final RegionView group = new RegionView(this); final TextView text = new TextView(this); text.setText(buildText()); group.addView(text); setContentView(group); ObjectAnimator animator = ObjectAnimator.ofFloat(group, "clipPosition", 0.0f, 1.0f); animator.setDuration(3000); animator.setRepeatCount(ValueAnimator.INFINITE); animator.setRepeatMode(ValueAnimator.REVERSE); animator.start(); }
public void testOfInt() throws Throwable { Object object = mActivity.view.newBall; String property = "backgroundColor"; int startColor = mActivity.view.RED; int endColor = mActivity.view.BLUE; ObjectAnimator colorAnimator = ObjectAnimator.ofInt(object, property, startColor, endColor); colorAnimator.setDuration(1000); colorAnimator.setEvaluator(new ArgbEvaluator()); colorAnimator.setRepeatCount(1); colorAnimator.setRepeatMode(ValueAnimator.REVERSE); colorAnimator.start(); startAnimation(mObjectAnimator, colorAnimator); Thread.sleep(100); Integer i = (Integer) colorAnimator.getAnimatedValue(); // We are going from less negative value to a more negative value assertTrue(i.intValue() <= startColor); assertTrue(endColor <= i.intValue()); }
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.winner); // doBindService(); final Animation animRotate = AnimationUtils.loadAnimation(this, R.anim.rotate); final Animation animRotate2 = AnimationUtils.loadAnimation(this, R.anim.rotatetwo); final Animation animRotate3 = AnimationUtils.loadAnimation(this, R.anim.rotate3); final Animation textAnimation = AnimationUtils.loadAnimation(this, R.anim.textanimation); String time = getIntent().getStringExtra("time"); String click = getIntent().getStringExtra("click"); TextView maintext = (TextView) findViewById(R.id.maintext); maintext.startAnimation(textAnimation); ObjectAnimator a; a = ObjectAnimator.ofInt(maintext, "textColor", Color.RED, Color.BLUE, Color.CYAN, Color.GREEN); a.setRepeatMode(ObjectAnimator.REVERSE); a.setRepeatCount(ObjectAnimator.INFINITE); a.setDuration(1500000); a.start(); final TextView exit = (TextView) findViewById(R.id.texttime); final TextView records = (TextView) findViewById(R.id.clicktext); exit.startAnimation(animRotate); records.startAnimation(animRotate2); final TextView tvTime = (TextView) findViewById(R.id.time); final TextView tvClick = (TextView) findViewById(R.id.click); tvClick.setText(click); tvTime.setText(time); }
public void testClone() throws Throwable { Object object = mActivity.view.newBall; String property = "y"; float startY = mActivity.mStartY; float endY = mActivity.mStartY + mActivity.mDeltaY; Interpolator interpolator = new AccelerateInterpolator(); ObjectAnimator objAnimator = ObjectAnimator.ofFloat(object, property, startY, endY); objAnimator.setDuration(mDuration); objAnimator.setRepeatCount(ValueAnimator.INFINITE); objAnimator.setInterpolator(interpolator); objAnimator.setRepeatMode(ValueAnimator.REVERSE); ObjectAnimator cloneAnimator = objAnimator.clone(); assertEquals(mDuration, cloneAnimator.getDuration()); assertEquals(ValueAnimator.INFINITE, cloneAnimator.getRepeatCount()); assertEquals(ValueAnimator.REVERSE, cloneAnimator.getRepeatMode()); assertEquals(object, cloneAnimator.getTarget()); assertEquals(property, cloneAnimator.getPropertyName()); assertEquals(interpolator, cloneAnimator.getInterpolator()); }
public void testSetFloatValues() throws Throwable { Object object = mActivity.view.newBall; String property = "y"; float startY = mActivity.mStartY; float endY = mActivity.mStartY + mActivity.mDeltaY; float[] values = {startY, endY}; ObjectAnimator objAnimator = new ObjectAnimator(); objAnimator.setTarget(object); objAnimator.setPropertyName(property); objAnimator.setFloatValues(values); objAnimator.setDuration(mDuration); objAnimator.setRepeatCount(ValueAnimator.INFINITE); objAnimator.setInterpolator(new AccelerateInterpolator()); objAnimator.setRepeatMode(ValueAnimator.REVERSE); startAnimation(objAnimator); Thread.sleep(100); float y = mActivity.view.newBall.getY(); assertTrue(y >= startY); assertTrue(y <= endY); }
public void flashAccuracy() { Log.w(LOG, "++++++= flashAccuracy .............."); ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(txtAccuracy, "alpha", 0, 1); objectAnimator.setRepeatMode(ObjectAnimator.REVERSE); objectAnimator.setDuration(200); objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); objectAnimator.addListener( new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) {} @Override public void onAnimationEnd(Animator animation) { flashAccuracy(); } @Override public void onAnimationCancel(Animator animation) {} @Override public void onAnimationRepeat(Animator animation) {} }); objectAnimator.start(); }