use of android.animation.AnimatorSet in project TourGuide by worker8.
the class TourGuide method performAnimationOn.
private void performAnimationOn(final View view) {
if (mTechnique != null && mTechnique == Technique.HORIZONTAL_LEFT) {
final AnimatorSet animatorSet = new AnimatorSet();
final AnimatorSet animatorSet2 = new AnimatorSet();
Animator.AnimatorListener lis1 = new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
view.setScaleX(1f);
view.setScaleY(1f);
view.setTranslationX(0);
animatorSet2.start();
}
};
Animator.AnimatorListener lis2 = new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
view.setScaleX(1f);
view.setScaleY(1f);
view.setTranslationX(0);
animatorSet.start();
}
};
long fadeInDuration = 800;
long scaleDownDuration = 800;
long goLeftXDuration = 2000;
long fadeOutDuration = goLeftXDuration;
float translationX = getScreenWidth() / 2;
final ValueAnimator fadeInAnim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
fadeInAnim.setDuration(fadeInDuration);
final ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.85f);
scaleDownX.setDuration(scaleDownDuration);
final ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.85f);
scaleDownY.setDuration(scaleDownDuration);
final ObjectAnimator goLeftX = ObjectAnimator.ofFloat(view, "translationX", -translationX);
goLeftX.setDuration(goLeftXDuration);
final ValueAnimator fadeOutAnim = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
fadeOutAnim.setDuration(fadeOutDuration);
final ValueAnimator fadeInAnim2 = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
fadeInAnim2.setDuration(fadeInDuration);
final ObjectAnimator scaleDownX2 = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.85f);
scaleDownX2.setDuration(scaleDownDuration);
final ObjectAnimator scaleDownY2 = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.85f);
scaleDownY2.setDuration(scaleDownDuration);
final ObjectAnimator goLeftX2 = ObjectAnimator.ofFloat(view, "translationX", -translationX);
goLeftX2.setDuration(goLeftXDuration);
final ValueAnimator fadeOutAnim2 = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
fadeOutAnim2.setDuration(fadeOutDuration);
animatorSet.play(fadeInAnim);
animatorSet.play(scaleDownX).with(scaleDownY).after(fadeInAnim);
animatorSet.play(goLeftX).with(fadeOutAnim).after(scaleDownY);
animatorSet2.play(fadeInAnim2);
animatorSet2.play(scaleDownX2).with(scaleDownY2).after(fadeInAnim2);
animatorSet2.play(goLeftX2).with(fadeOutAnim2).after(scaleDownY2);
animatorSet.addListener(lis1);
animatorSet2.addListener(lis2);
animatorSet.start();
/* these animatorSets are kept track in FrameLayout, so that they can be cleaned up when FrameLayout is detached from window */
mFrameLayout.addAnimatorSet(animatorSet);
mFrameLayout.addAnimatorSet(animatorSet2);
} else if (mTechnique != null && mTechnique == Technique.HORIZONTAL_RIGHT) {
//TODO: new feature
} else if (mTechnique != null && mTechnique == Technique.VERTICAL_UPWARD) {
//TODO: new feature
} else if (mTechnique != null && mTechnique == Technique.VERTICAL_DOWNWARD) {
//TODO: new feature
} else {
// do click for default case
final AnimatorSet animatorSet = new AnimatorSet();
final AnimatorSet animatorSet2 = new AnimatorSet();
Animator.AnimatorListener lis1 = new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
view.setScaleX(1f);
view.setScaleY(1f);
view.setTranslationX(0);
animatorSet2.start();
}
};
Animator.AnimatorListener lis2 = new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
view.setScaleX(1f);
view.setScaleY(1f);
view.setTranslationX(0);
animatorSet.start();
}
};
long fadeInDuration = 800;
long scaleDownDuration = 800;
long fadeOutDuration = 800;
long delay = 1000;
final ValueAnimator delayAnim = ObjectAnimator.ofFloat(view, "translationX", 0);
delayAnim.setDuration(delay);
final ValueAnimator fadeInAnim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
fadeInAnim.setDuration(fadeInDuration);
final ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.85f);
scaleDownX.setDuration(scaleDownDuration);
final ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.85f);
scaleDownY.setDuration(scaleDownDuration);
final ObjectAnimator scaleUpX = ObjectAnimator.ofFloat(view, "scaleX", 0.85f, 1f);
scaleUpX.setDuration(scaleDownDuration);
final ObjectAnimator scaleUpY = ObjectAnimator.ofFloat(view, "scaleY", 0.85f, 1f);
scaleUpY.setDuration(scaleDownDuration);
final ValueAnimator fadeOutAnim = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
fadeOutAnim.setDuration(fadeOutDuration);
final ValueAnimator delayAnim2 = ObjectAnimator.ofFloat(view, "translationX", 0);
delayAnim2.setDuration(delay);
final ValueAnimator fadeInAnim2 = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
fadeInAnim2.setDuration(fadeInDuration);
final ObjectAnimator scaleDownX2 = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.85f);
scaleDownX2.setDuration(scaleDownDuration);
final ObjectAnimator scaleDownY2 = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.85f);
scaleDownY2.setDuration(scaleDownDuration);
final ObjectAnimator scaleUpX2 = ObjectAnimator.ofFloat(view, "scaleX", 0.85f, 1f);
scaleUpX2.setDuration(scaleDownDuration);
final ObjectAnimator scaleUpY2 = ObjectAnimator.ofFloat(view, "scaleY", 0.85f, 1f);
scaleUpY2.setDuration(scaleDownDuration);
final ValueAnimator fadeOutAnim2 = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
fadeOutAnim2.setDuration(fadeOutDuration);
view.setAlpha(0);
animatorSet.setStartDelay(mToolTip != null ? mToolTip.mEnterAnimation.getDuration() : 0);
animatorSet.play(fadeInAnim);
animatorSet.play(scaleDownX).with(scaleDownY).after(fadeInAnim);
animatorSet.play(scaleUpX).with(scaleUpY).with(fadeOutAnim).after(scaleDownY);
animatorSet.play(delayAnim).after(scaleUpY);
animatorSet2.play(fadeInAnim2);
animatorSet2.play(scaleDownX2).with(scaleDownY2).after(fadeInAnim2);
animatorSet2.play(scaleUpX2).with(scaleUpY2).with(fadeOutAnim2).after(scaleDownY2);
animatorSet2.play(delayAnim2).after(scaleUpY2);
animatorSet.addListener(lis1);
animatorSet2.addListener(lis2);
animatorSet.start();
/* these animatorSets are kept track in FrameLayout, so that they can be cleaned up when FrameLayout is detached from window */
mFrameLayout.addAnimatorSet(animatorSet);
mFrameLayout.addAnimatorSet(animatorSet2);
}
}
use of android.animation.AnimatorSet in project XobotOS by xamarin.
the class ActionBarImpl method hide.
@Override
public void hide() {
if (mCurrentShowAnim != null) {
mCurrentShowAnim.end();
}
if (mContainerView.getVisibility() == View.GONE) {
return;
}
if (mShowHideAnimationEnabled) {
mContainerView.setAlpha(1);
mContainerView.setTransitioning(true);
AnimatorSet anim = new AnimatorSet();
AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mContainerView, "alpha", 0));
if (mContentView != null) {
b.with(ObjectAnimator.ofFloat(mContentView, "translationY", 0, -mContainerView.getHeight()));
b.with(ObjectAnimator.ofFloat(mContainerView, "translationY", -mContainerView.getHeight()));
}
if (mSplitView != null && mSplitView.getVisibility() == View.VISIBLE) {
mSplitView.setAlpha(1);
b.with(ObjectAnimator.ofFloat(mSplitView, "alpha", 0));
}
anim.addListener(mHideListener);
mCurrentShowAnim = anim;
anim.start();
} else {
mHideListener.onAnimationEnd(null);
}
}
use of android.animation.AnimatorSet in project XobotOS by xamarin.
the class ActionBarImpl method show.
void show(boolean markHiddenBeforeMode) {
if (mCurrentShowAnim != null) {
mCurrentShowAnim.end();
}
if (mContainerView.getVisibility() == View.VISIBLE) {
if (markHiddenBeforeMode)
mWasHiddenBeforeMode = false;
return;
}
mContainerView.setVisibility(View.VISIBLE);
if (mShowHideAnimationEnabled) {
mContainerView.setAlpha(0);
AnimatorSet anim = new AnimatorSet();
AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mContainerView, "alpha", 1));
if (mContentView != null) {
b.with(ObjectAnimator.ofFloat(mContentView, "translationY", -mContainerView.getHeight(), 0));
mContainerView.setTranslationY(-mContainerView.getHeight());
b.with(ObjectAnimator.ofFloat(mContainerView, "translationY", 0));
}
if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
mSplitView.setAlpha(0);
mSplitView.setVisibility(View.VISIBLE);
b.with(ObjectAnimator.ofFloat(mSplitView, "alpha", 1));
}
anim.addListener(mShowListener);
mCurrentShowAnim = anim;
anim.start();
} else {
mContainerView.setAlpha(1);
mContainerView.setTranslationY(0);
mShowListener.onAnimationEnd(null);
}
}
use of android.animation.AnimatorSet in project platform_frameworks_base by android.
the class WindowDecorActionBar method doHide.
public void doHide(boolean fromSystem) {
if (mCurrentShowAnim != null) {
mCurrentShowAnim.end();
}
if (mCurWindowVisibility == View.VISIBLE && (mShowHideAnimationEnabled || fromSystem)) {
mContainerView.setAlpha(1);
mContainerView.setTransitioning(true);
AnimatorSet anim = new AnimatorSet();
float endingY = -mContainerView.getHeight();
if (fromSystem) {
int[] topLeft = { 0, 0 };
mContainerView.getLocationInWindow(topLeft);
endingY -= topLeft[1];
}
ObjectAnimator a = ObjectAnimator.ofFloat(mContainerView, View.TRANSLATION_Y, endingY);
a.addUpdateListener(mUpdateListener);
AnimatorSet.Builder b = anim.play(a);
if (mContentAnimations && mContentView != null) {
b.with(ObjectAnimator.ofFloat(mContentView, View.TRANSLATION_Y, 0, endingY));
}
if (mSplitView != null && mSplitView.getVisibility() == View.VISIBLE) {
mSplitView.setAlpha(1);
b.with(ObjectAnimator.ofFloat(mSplitView, View.TRANSLATION_Y, mSplitView.getHeight()));
}
anim.setInterpolator(AnimationUtils.loadInterpolator(mContext, com.android.internal.R.interpolator.accelerate_cubic));
anim.setDuration(250);
anim.addListener(mHideListener);
mCurrentShowAnim = anim;
anim.start();
} else {
mHideListener.onAnimationEnd(null);
}
}
use of android.animation.AnimatorSet in project Transitions-Everywhere by andkulikov.
the class Crossfade method createAnimator.
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
if (startValues == null || endValues == null || Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
return null;
}
if (sRectEvaluator == null) {
sRectEvaluator = new RectEvaluator();
}
final boolean useParentOverlay = mFadeBehavior != FADE_BEHAVIOR_REVEAL;
final View view = endValues.view;
Map<String, Object> startVals = startValues.values;
Map<String, Object> endVals = endValues.values;
Rect startBounds = (Rect) startVals.get(PROPNAME_BOUNDS);
Rect endBounds = (Rect) endVals.get(PROPNAME_BOUNDS);
Bitmap startBitmap = (Bitmap) startVals.get(PROPNAME_BITMAP);
Bitmap endBitmap = (Bitmap) endVals.get(PROPNAME_BITMAP);
final BitmapDrawable startDrawable = (BitmapDrawable) startVals.get(PROPNAME_DRAWABLE);
final BitmapDrawable endDrawable = (BitmapDrawable) endVals.get(PROPNAME_DRAWABLE);
if (Transition.DBG) {
Log.d(LOG_TAG, "StartBitmap.sameAs(endBitmap) = " + startBitmap.sameAs(endBitmap) + " for start, end: " + startBitmap + ", " + endBitmap);
}
if (startDrawable != null && endDrawable != null && !startBitmap.sameAs(endBitmap)) {
ViewGroupOverlayUtils.addCrossfadeOverlay(useParentOverlay, view, mFadeBehavior, startDrawable, endDrawable);
// The transition works by placing the end drawable under the start drawable and
// gradually fading out the start drawable. So it's not really a cross-fade, but rather
// a reveal of the end scene over time. Also, animate the bounds of both drawables
// to mimic the change in the size of the view itself between scenes.
ObjectAnimator anim;
if (mFadeBehavior == FADE_BEHAVIOR_OUT_IN) {
// Fade out completely halfway through the transition
anim = ObjectAnimator.ofInt(startDrawable, "alpha", 255, 0, 0);
} else {
anim = ObjectAnimator.ofInt(startDrawable, "alpha", 0);
}
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
// TODO: some way to auto-invalidate views based on drawable changes? callbacks?
view.invalidate(startDrawable.getBounds());
}
});
ObjectAnimator anim1 = null;
if (mFadeBehavior == FADE_BEHAVIOR_OUT_IN) {
// start fading in halfway through the transition
anim1 = ObjectAnimator.ofFloat(view, View.ALPHA, 0, 0, 1);
} else if (mFadeBehavior == FADE_BEHAVIOR_CROSSFADE) {
anim1 = ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1);
}
if (Transition.DBG) {
Log.d(LOG_TAG, "Crossfade: created anim " + anim + " for start, end values " + startValues + ", " + endValues);
}
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
ViewGroupOverlayUtils.removeCrossfadeOverlay(useParentOverlay, view, mFadeBehavior, startDrawable, endDrawable);
}
});
AnimatorSet set = new AnimatorSet();
set.playTogether(anim);
if (anim1 != null) {
set.playTogether(anim1);
}
if (mResizeBehavior == RESIZE_BEHAVIOR_SCALE && !startBounds.equals(endBounds)) {
if (Transition.DBG) {
Log.d(LOG_TAG, "animating from startBounds to endBounds: " + startBounds + ", " + endBounds);
}
Animator anim2 = ObjectAnimator.ofObject(startDrawable, "bounds", sRectEvaluator, startBounds, endBounds);
set.playTogether(anim2);
if (mResizeBehavior == RESIZE_BEHAVIOR_SCALE) {
// TODO: How to handle resizing with a CROSSFADE (vs. REVEAL) effect
// when we are animating the view directly?
Animator anim3 = ObjectAnimator.ofObject(endDrawable, "bounds", sRectEvaluator, startBounds, endBounds);
set.playTogether(anim3);
}
}
return set;
} else {
return null;
}
}
Aggregations