use of android.animation.AnimatorSet in project paper-onboarding-android by Ramotion.
the class PaperOnboardingEngine method createContentIconShowAnimation.
/**
* @param currentContentIcon currently displayed view with icon
* @param newContentIcon newly created and prepared view to display
* @return animator set with this animation
*/
protected AnimatorSet createContentIconShowAnimation(final View currentContentIcon, final View newContentIcon) {
int positionDeltaPx = dpToPixels(CONTENT_ICON_POS_DELTA_Y_DP);
AnimatorSet animations = new AnimatorSet();
Animator currentContentMoveUp = ObjectAnimator.ofFloat(currentContentIcon, "y", 0, -positionDeltaPx);
currentContentMoveUp.setDuration(ANIM_CONTENT_ICON_HIDE_TIME);
currentContentMoveUp.addListener(new AnimatorEndListener() {
@Override
public void onAnimationEnd(Animator animation) {
mContentIconContainer.removeView(currentContentIcon);
}
});
Animator currentContentFadeOut = ObjectAnimator.ofFloat(currentContentIcon, "alpha", 1, 0);
currentContentFadeOut.setDuration(ANIM_CONTENT_ICON_HIDE_TIME);
animations.playTogether(currentContentMoveUp, currentContentFadeOut);
Animator newContentMoveUp = ObjectAnimator.ofFloat(newContentIcon, "y", positionDeltaPx, 0);
newContentMoveUp.setDuration(ANIM_CONTENT_ICON_SHOW_TIME);
Animator newContentFadeIn = ObjectAnimator.ofFloat(newContentIcon, "alpha", 0, 1);
newContentFadeIn.setDuration(ANIM_CONTENT_ICON_SHOW_TIME);
animations.playTogether(newContentMoveUp, newContentFadeIn);
animations.setInterpolator(new DecelerateInterpolator());
return animations;
}
use of android.animation.AnimatorSet 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.animation.AnimatorSet in project Fairphone by Kwamecorp.
the class AppWidgetResizeFrame method snapToWidget.
public void snapToWidget(boolean animate) {
final DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
int xOffset = mCellLayout.getLeft() + mCellLayout.getPaddingLeft() + mDragLayer.getPaddingLeft() - mWorkspace.getScrollX();
int yOffset = mCellLayout.getTop() + mCellLayout.getPaddingTop() + mDragLayer.getPaddingTop() - mWorkspace.getScrollY();
int newWidth = mWidgetView.getWidth() + 2 * mBackgroundPadding - mWidgetPaddingLeft - mWidgetPaddingRight;
int newHeight = mWidgetView.getHeight() + 2 * mBackgroundPadding - mWidgetPaddingTop - mWidgetPaddingBottom;
int newX = mWidgetView.getLeft() - mBackgroundPadding + xOffset + mWidgetPaddingLeft;
int newY = mWidgetView.getTop() - mBackgroundPadding + yOffset + mWidgetPaddingTop;
// down accordingly to provide a proper touch target.
if (newY < 0) {
// In this case we shift the touch region down to start at the top of the DragLayer
mTopTouchRegionAdjustment = -newY;
} else {
mTopTouchRegionAdjustment = 0;
}
if (newY + newHeight > mDragLayer.getHeight()) {
// In this case we shift the touch region up to end at the bottom of the DragLayer
mBottomTouchRegionAdjustment = -(newY + newHeight - mDragLayer.getHeight());
} else {
mBottomTouchRegionAdjustment = 0;
}
if (!animate) {
lp.width = newWidth;
lp.height = newHeight;
lp.x = newX;
lp.y = newY;
mLeftHandle.setAlpha(1.0f);
mRightHandle.setAlpha(1.0f);
mTopHandle.setAlpha(1.0f);
mBottomHandle.setAlpha(1.0f);
requestLayout();
} else {
PropertyValuesHolder width = PropertyValuesHolder.ofInt("width", lp.width, newWidth);
PropertyValuesHolder height = PropertyValuesHolder.ofInt("height", lp.height, newHeight);
PropertyValuesHolder x = PropertyValuesHolder.ofInt("x", lp.x, newX);
PropertyValuesHolder y = PropertyValuesHolder.ofInt("y", lp.y, newY);
ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(lp, width, height, x, y);
ObjectAnimator leftOa = LauncherAnimUtils.ofFloat(mLeftHandle, "alpha", 1.0f);
ObjectAnimator rightOa = LauncherAnimUtils.ofFloat(mRightHandle, "alpha", 1.0f);
ObjectAnimator topOa = LauncherAnimUtils.ofFloat(mTopHandle, "alpha", 1.0f);
ObjectAnimator bottomOa = LauncherAnimUtils.ofFloat(mBottomHandle, "alpha", 1.0f);
oa.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
requestLayout();
}
});
AnimatorSet set = LauncherAnimUtils.createAnimatorSet();
if (mResizeMode == AppWidgetProviderInfo.RESIZE_VERTICAL) {
set.playTogether(oa, topOa, bottomOa);
} else if (mResizeMode == AppWidgetProviderInfo.RESIZE_HORIZONTAL) {
set.playTogether(oa, leftOa, rightOa);
} else {
set.playTogether(oa, leftOa, rightOa, topOa, bottomOa);
}
set.setDuration(SNAP_DURATION);
set.start();
}
}
use of android.animation.AnimatorSet in project Fairphone by Kwamecorp.
the class AppsCustomizeTabHost method onTabChanged.
@Override
public void onTabChanged(String tabId) {
final AppsCustomizePagedView.ContentType type = getContentTypeForTabTag(tabId);
// Animate the changing of the tab content by fading pages in and out
final Resources res = getResources();
final int duration = res.getInteger(R.integer.config_tabTransitionDuration);
// We post a runnable here because there is a delay while the first page is loading and
// the feedback from having changed the tab almost feels better than having it stick
post(new Runnable() {
@Override
public void run() {
if (mAppsCustomizePane.getMeasuredWidth() <= 0 || mAppsCustomizePane.getMeasuredHeight() <= 0) {
reloadCurrentPage();
return;
}
// Take the visible pages and re-parent them temporarily to mAnimatorBuffer
// and then cross fade to the new pages
int[] visiblePageRange = new int[2];
mAppsCustomizePane.getVisiblePages(visiblePageRange);
if (visiblePageRange[0] == -1 && visiblePageRange[1] == -1) {
// If we can't get the visible page ranges, then just skip the animation
reloadCurrentPage();
return;
}
ArrayList<View> visiblePages = new ArrayList<View>();
for (int i = visiblePageRange[0]; i <= visiblePageRange[1]; i++) {
visiblePages.add(mAppsCustomizePane.getPageAt(i));
}
// We want the pages to be rendered in exactly the same way as they were when
// their parent was mAppsCustomizePane -- so set the scroll on mAnimationBuffer
// to be exactly the same as mAppsCustomizePane, and below, set the left/top
// parameters to be correct for each of the pages
mAnimationBuffer.scrollTo(mAppsCustomizePane.getScrollX(), 0);
// add the pages to mAnimationBuffer in reverse order to match that behavior
for (int i = visiblePages.size() - 1; i >= 0; i--) {
View child = visiblePages.get(i);
if (child instanceof PagedViewCellLayout) {
((PagedViewCellLayout) child).resetChildrenOnKeyListeners();
} else if (child instanceof PagedViewGridLayout) {
((PagedViewGridLayout) child).resetChildrenOnKeyListeners();
}
PagedViewWidget.setDeletePreviewsWhenDetachedFromWindow(false);
mAppsCustomizePane.removeView(child);
PagedViewWidget.setDeletePreviewsWhenDetachedFromWindow(true);
mAnimationBuffer.setAlpha(1f);
mAnimationBuffer.setVisibility(View.VISIBLE);
LayoutParams p = new FrameLayout.LayoutParams(child.getMeasuredWidth(), child.getMeasuredHeight());
p.setMargins((int) child.getLeft(), (int) child.getTop(), 0, 0);
mAnimationBuffer.addView(child, p);
}
// Toggle the new content
onTabChangedStart();
onTabChangedEnd(type);
// Animate the transition
ObjectAnimator outAnim = LauncherAnimUtils.ofFloat(mAnimationBuffer, "alpha", 0f);
outAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mAnimationBuffer.setVisibility(View.GONE);
mAnimationBuffer.removeAllViews();
}
@Override
public void onAnimationCancel(Animator animation) {
mAnimationBuffer.setVisibility(View.GONE);
mAnimationBuffer.removeAllViews();
}
});
ObjectAnimator inAnim = LauncherAnimUtils.ofFloat(mAppsCustomizePane, "alpha", 1f);
inAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
reloadCurrentPage();
}
});
final AnimatorSet animSet = LauncherAnimUtils.createAnimatorSet();
animSet.playTogether(outAnim, inAnim);
animSet.setDuration(duration);
post(new Runnable() {
public void run() {
animSet.start();
}
});
}
});
}
use of android.animation.AnimatorSet in project Fairphone by Kwamecorp.
the class LauncherTransitionable method runNewAppsAnimation.
/**
* Runs a new animation that scales up icons that were added while Launcher
* was in the background.
*
* @param immediate
* whether to run the animation or show the results immediately
*/
private void runNewAppsAnimation(boolean immediate) {
AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
Collection<Animator> bounceAnims = new ArrayList<Animator>();
// Order these new views spatially so that they animate in order
Collections.sort(mNewShortcutAnimateViews, new Comparator<View>() {
@Override
public int compare(View a, View b) {
CellLayout.LayoutParams alp = (CellLayout.LayoutParams) a.getLayoutParams();
CellLayout.LayoutParams blp = (CellLayout.LayoutParams) b.getLayoutParams();
int cellCountX = LauncherModel.getCellCountX();
return (alp.cellY * cellCountX + alp.cellX) - (blp.cellY * cellCountX + blp.cellX);
}
});
// requested)
if (immediate) {
for (View v : mNewShortcutAnimateViews) {
v.setAlpha(1f);
v.setScaleX(1f);
v.setScaleY(1f);
}
} else {
for (int i = 0; i < mNewShortcutAnimateViews.size(); ++i) {
View v = mNewShortcutAnimateViews.get(i);
ValueAnimator bounceAnim = LauncherAnimUtils.ofPropertyValuesHolder(v, PropertyValuesHolder.ofFloat("alpha", 1f), PropertyValuesHolder.ofFloat("scaleX", 1f), PropertyValuesHolder.ofFloat("scaleY", 1f));
bounceAnim.setDuration(InstallShortcutReceiver.NEW_SHORTCUT_BOUNCE_DURATION);
bounceAnim.setStartDelay(i * InstallShortcutReceiver.NEW_SHORTCUT_STAGGER_DELAY);
bounceAnim.setInterpolator(new SmoothPagedView.OvershootInterpolator());
bounceAnims.add(bounceAnim);
}
anim.playTogether(bounceAnims);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (mWorkspace != null) {
mWorkspace.postDelayed(mBuildLayersRunnable, 500);
}
}
});
anim.start();
}
// Clean up
mNewShortcutAnimatePage = -1;
mNewShortcutAnimateViews.clear();
new Thread("clearNewAppsThread") {
public void run() {
mSharedPrefs.edit().putInt(InstallShortcutReceiver.NEW_APPS_PAGE_KEY, -1).putStringSet(InstallShortcutReceiver.NEW_APPS_LIST_KEY, null).commit();
}
}.start();
}
Aggregations