use of android.animation.AnimatorSet in project Klyph by jonathangerbaud.
the class DefaultHeaderTransformer method hideHeaderView.
@Override
public boolean hideHeaderView() {
final boolean changeVis = mHeaderView.getVisibility() != View.GONE;
if (changeVis) {
Animator animator;
if (mContentLayout.getAlpha() >= 0.5f) {
// If the content layout is showing, translate and fade out
animator = new AnimatorSet();
ObjectAnimator transAnim = ObjectAnimator.ofFloat(mContentLayout, "translationY", 0f, -mContentLayout.getHeight());
ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(mHeaderView, "alpha", 1f, 0f);
((AnimatorSet) animator).playTogether(transAnim, alphaAnim);
} else {
// If the content layout isn't showing (minimized), just fade out
animator = ObjectAnimator.ofFloat(mHeaderView, "alpha", 1f, 0f);
}
animator.setDuration(mAnimationDuration);
animator.addListener(new HideAnimationCallback());
animator.start();
}
return changeVis;
}
use of android.animation.AnimatorSet in project KJFrameForAndroid by kymjs.
the class KJDragGridView method createTranslationAnimations.
/**
* 创建移动动画
*
* @param view
* @param startX
* @param endX
* @param startY
* @param endY
* @return
*/
private AnimatorSet createTranslationAnimations(View view, float startX, float endX, float startY, float endY) {
ObjectAnimator animX = ObjectAnimator.ofFloat(view, "translationX", startX, endX);
ObjectAnimator animY = ObjectAnimator.ofFloat(view, "translationY", startY, endY);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.playTogether(animX, animY);
return animSetXY;
}
use of android.animation.AnimatorSet in project Klyph by jonathangerbaud.
the class KlyphAnimationAdapter method hideView.
private void hideView(View view) {
ObjectAnimator animator = ObjectAnimator.ofFloat(view, "alpha", 0);
AnimatorSet set = new AnimatorSet();
set.play(animator);
set.setDuration(0);
set.start();
}
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();
}
});
}
});
}
Aggregations