use of android.animation.AnimatorSet in project Euclid by Yalantis.
the class EuclidActivity method getCloseProfileAnimatorSet.
/**
* This method creates if needed the set of transition animations, which hides profile toolbar, profile avatar
* and profile details views. Also it calls notifyDataSetChanged() on the ListView's adapter,
* so it starts slide-in left animation on list items.
*
* @return - animator set that starts transition animations.
*/
private AnimatorSet getCloseProfileAnimatorSet() {
if (mCloseProfileAnimatorSet == null) {
Animator profileToolbarAnimator = ObjectAnimator.ofFloat(mToolbarProfile, View.X, 0, mToolbarProfile.getWidth());
Animator profilePhotoAnimator = ObjectAnimator.ofFloat(mOverlayListItemView, View.X, 0, mOverlayListItemView.getWidth());
profilePhotoAnimator.setStartDelay(getStepDelayHideDetailsAnimation());
Animator profileButtonAnimator = ObjectAnimator.ofFloat(mButtonProfile, View.X, mInitialProfileButtonX, mOverlayListItemView.getWidth() + mInitialProfileButtonX);
profileButtonAnimator.setStartDelay(getStepDelayHideDetailsAnimation() * 2);
Animator profileDetailsAnimator = ObjectAnimator.ofFloat(mProfileDetails, View.X, 0, mToolbarProfile.getWidth());
profileDetailsAnimator.setStartDelay(getStepDelayHideDetailsAnimation() * 2);
List<Animator> profileAnimators = new ArrayList<>();
profileAnimators.add(profileToolbarAnimator);
profileAnimators.add(profilePhotoAnimator);
profileAnimators.add(profileButtonAnimator);
profileAnimators.add(profileDetailsAnimator);
mCloseProfileAnimatorSet = new AnimatorSet();
mCloseProfileAnimatorSet.playTogether(profileAnimators);
mCloseProfileAnimatorSet.setDuration(getAnimationDurationCloseProfileDetails());
mCloseProfileAnimatorSet.setInterpolator(new AccelerateInterpolator());
mCloseProfileAnimatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
if (mListViewAnimator != null) {
mListViewAnimator.reset();
mListViewAnimationAdapter.notifyDataSetChanged();
}
}
@Override
public void onAnimationEnd(Animator animation) {
mToolbarProfile.setVisibility(View.INVISIBLE);
mButtonProfile.setVisibility(View.INVISIBLE);
mProfileDetails.setVisibility(View.INVISIBLE);
mListView.setEnabled(true);
mListViewAnimator.disableAnimations();
mState = EuclidState.Closed;
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
}
return mCloseProfileAnimatorSet;
}
use of android.animation.AnimatorSet 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.animation.AnimatorSet in project actor-platform by actorapp.
the class ExplorerFragment method onCreateAnimator.
@Override
public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
Log.d("Explorer animation", "CreateAnimator: " + transit + " " + enter + " " + nextAnim);
int animationLength = 0;
if (nextAnim == R.animator.picker_fragment_explorer_welcome_enter) {
list.setAlpha(0);
list.post(new Runnable() {
@Override
public void run() {
list.setAlpha(1);
int offsetIncreaseOffset = 0;
for (int i = 0; i < list.getChildCount(); i++) {
View searchItemView = list.getChildAt(i);
AnimationSet slideInAnimation = new AnimationSet(true);
slideInAnimation.setInterpolator(new MaterialInterpolator());
slideInAnimation.setDuration(180);
if (items.get(i) instanceof HeaderItem) {
offsetIncreaseOffset += 150;
slideInAnimation.setStartOffset(i * 50 + offsetIncreaseOffset);
offsetIncreaseOffset += 200;
} else
slideInAnimation.setStartOffset(i * 50 + offsetIncreaseOffset);
AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
slideInAnimation.addAnimation(alphaAnimation);
TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, 150, 0);
slideInAnimation.addAnimation(translateAnimation);
searchItemView.startAnimation(slideInAnimation);
}
}
});
animationLength = list.getChildCount() * 100 + 50;
Log.d("Explorer animation", "CreateAnimator: enter");
} else if (nextAnim == R.animator.picker_fragment_explorer_enter) {
list.setAlpha(0);
list.post(new Runnable() {
@Override
public void run() {
list.setAlpha(1);
int offsetIncreaseOffset = 0;
for (int i = 0; i < list.getChildCount(); i++) {
View searchItemView = list.getChildAt(i);
AnimationSet slideInAnimation = new AnimationSet(true);
slideInAnimation.setInterpolator(new MaterialInterpolator());
slideInAnimation.setDuration(100);
slideInAnimation.setStartOffset(i * 50 + offsetIncreaseOffset);
AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
slideInAnimation.addAnimation(alphaAnimation);
TranslateAnimation translateAnimation = new TranslateAnimation(100, 0, 0, 0);
slideInAnimation.addAnimation(translateAnimation);
searchItemView.startAnimation(slideInAnimation);
}
}
});
animationLength = list.getChildCount() * 100 + 50;
Log.d("Explorer animation", "CreateAnimator: enter");
} else if (nextAnim == R.animator.picker_fragment_explorer_welcome_exit || nextAnim == R.animator.picker_fragment_explorer_exit) {
for (int i = 0; i < list.getChildCount(); i++) {
View searchItemView = list.getChildAt(i);
AnimationSet slideInAnimation = new AnimationSet(true);
slideInAnimation.setInterpolator(new MaterialInterpolator());
slideInAnimation.setDuration(100);
slideInAnimation.setStartOffset(i * 50);
slideInAnimation.setFillAfter(true);
AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
alphaAnimation.setFillAfter(true);
slideInAnimation.addAnimation(alphaAnimation);
TranslateAnimation translateAnimation = new TranslateAnimation(0, -100, 0, 0);
slideInAnimation.addAnimation(translateAnimation);
searchItemView.startAnimation(slideInAnimation);
}
// list.getChildCount() * 100 + 50;
animationLength = 0;
Log.d("Explorer animation", "CreateAnimator: exit");
} else if (nextAnim == R.animator.picker_fragment_explorer_return) {
list.setAlpha(0);
list.post(new Runnable() {
@Override
public void run() {
list.setAlpha(1);
for (int i = 0; i < list.getChildCount(); i++) {
View searchItemView = list.getChildAt(i);
AnimationSet slideInAnimation = new AnimationSet(true);
slideInAnimation.setInterpolator(new MaterialInterpolator());
slideInAnimation.setDuration(100);
slideInAnimation.setStartOffset(i * 50);
AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
slideInAnimation.addAnimation(alphaAnimation);
TranslateAnimation translateAnimation = new TranslateAnimation(-100, 0, 0, 0);
slideInAnimation.addAnimation(translateAnimation);
searchItemView.startAnimation(slideInAnimation);
}
}
});
animationLength = list.getChildCount() * 100 + 50;
Log.d("Explorer animation", "CreateAnimator: return");
} else if (nextAnim == R.animator.picker_fragment_explorer_out) {
for (int i = 0; i < list.getChildCount(); i++) {
View searchItemView = list.getChildAt(i);
AnimationSet slideInAnimation = new AnimationSet(true);
slideInAnimation.setInterpolator(new MaterialInterpolator());
slideInAnimation.setDuration(100);
slideInAnimation.setStartOffset(i * 50);
slideInAnimation.setFillAfter(true);
AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
alphaAnimation.setFillAfter(true);
slideInAnimation.addAnimation(alphaAnimation);
TranslateAnimation translateAnimation = new TranslateAnimation(0, 100, 0, 0);
slideInAnimation.addAnimation(translateAnimation);
searchItemView.startAnimation(slideInAnimation);
}
if (items.size() == 1) {
AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
alphaAnimation.setInterpolator(new MaterialInterpolator());
alphaAnimation.setDuration(100);
alphaAnimation.setFillAfter(true);
emptyView.startAnimation(alphaAnimation);
statusView.startAnimation(alphaAnimation);
animationLength = 250;
}
//else
// list.getChildCount() * 100 + 50;
animationLength = 0;
Log.d("Explorer animation", "CreateAnimator: out");
}
AnimatorSet animator = (AnimatorSet) AnimatorInflater.loadAnimator(pickerActivity, R.animator.picker_fragment_explorer_enter);
animator.setDuration(animationLength);
return animator;
}
use of android.animation.AnimatorSet in project android_frameworks_base by ParanoidAndroid.
the class KeyButtonView method setPressed.
public void setPressed(boolean pressed) {
if (mGlowBG != null) {
if (pressed != isPressed()) {
if (mPressedAnim != null && mPressedAnim.isRunning()) {
mPressedAnim.cancel();
}
final AnimatorSet as = mPressedAnim = new AnimatorSet();
if (pressed) {
if (mGlowScale < GLOW_MAX_SCALE_FACTOR)
mGlowScale = GLOW_MAX_SCALE_FACTOR;
if (mGlowAlpha < BUTTON_QUIESCENT_ALPHA)
mGlowAlpha = BUTTON_QUIESCENT_ALPHA;
setDrawingAlpha(1f);
as.playTogether(ObjectAnimator.ofFloat(this, "glowAlpha", 1f), ObjectAnimator.ofFloat(this, "glowScale", GLOW_MAX_SCALE_FACTOR));
as.setDuration(50);
} else {
mOldDrawingAlpha = BUTTON_QUIESCENT_ALPHA;
as.playTogether(ObjectAnimator.ofFloat(this, "glowAlpha", 0f), ObjectAnimator.ofFloat(this, "glowScale", 1f), ObjectAnimator.ofFloat(this, "drawingAlpha", BUTTON_QUIESCENT_ALPHA));
as.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
setDrawingAlpha(BUTTON_QUIESCENT_ALPHA);
}
});
as.setDuration(500);
}
as.start();
}
}
super.setPressed(pressed);
}
use of android.animation.AnimatorSet in project android_frameworks_base by ParanoidAndroid.
the class KeyguardWidgetCarousel method animatePagesToCarousel.
void animatePagesToCarousel() {
if (mChildrenTransformsAnimator != null) {
mChildrenTransformsAnimator.cancel();
mChildrenTransformsAnimator = null;
}
int count = getChildCount();
PropertyValuesHolder alpha;
PropertyValuesHolder outlineAlpha;
PropertyValuesHolder rotationY;
PropertyValuesHolder pivotX;
PropertyValuesHolder pivotY;
ArrayList<Animator> anims = new ArrayList<Animator>();
for (int i = 0; i < count; i++) {
KeyguardWidgetFrame child = getWidgetPageAt(i);
float finalAlpha = getAlphaForPage(mScreenCenter, i, true);
float finalOutlineAlpha = getOutlineAlphaForPage(mScreenCenter, i, true);
getTransformForPage(mScreenCenter, i, mTmpTransform);
boolean inVisibleRange = (i >= mCurrentPage - 1 && i <= mCurrentPage + 1);
ObjectAnimator a;
alpha = PropertyValuesHolder.ofFloat("contentAlpha", finalAlpha);
outlineAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", finalOutlineAlpha);
pivotX = PropertyValuesHolder.ofFloat("pivotX", mTmpTransform[0]);
pivotY = PropertyValuesHolder.ofFloat("pivotY", mTmpTransform[1]);
rotationY = PropertyValuesHolder.ofFloat("rotationY", mTmpTransform[2]);
if (inVisibleRange) {
// for the central pages we animate into a rotated state
a = ObjectAnimator.ofPropertyValuesHolder(child, alpha, outlineAlpha, pivotX, pivotY, rotationY);
} else {
a = ObjectAnimator.ofPropertyValuesHolder(child, alpha, outlineAlpha);
a.setInterpolator(mFastFadeInterpolator);
}
anims.add(a);
}
int duration = REORDERING_ZOOM_IN_OUT_DURATION;
mChildrenTransformsAnimator = new AnimatorSet();
mChildrenTransformsAnimator.playTogether(anims);
mChildrenTransformsAnimator.setDuration(duration);
mChildrenTransformsAnimator.start();
}
Aggregations