use of android.animation.PropertyValuesHolder in project android_packages_apps_Launcher2 by CyanogenMod.
the class LauncherTransitionable method shrinkAndFadeInFolderIcon.
private void shrinkAndFadeInFolderIcon(final FolderIcon fi) {
if (fi == null)
return;
PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f);
PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f);
PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f);
final CellLayout cl = (CellLayout) fi.getParent().getParent();
// We remove and re-draw the FolderIcon in-case it has changed
mDragLayer.removeView(mFolderIconImageView);
copyFolderIconToImage(fi);
ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(mFolderIconImageView, alpha, scaleX, scaleY);
oa.setDuration(getResources().getInteger(R.integer.config_folderAnimDuration));
oa.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (cl != null) {
cl.clearFolderLeaveBehind();
// Remove the ImageView copy of the FolderIcon and make the original visible.
mDragLayer.removeView(mFolderIconImageView);
fi.setVisibility(View.VISIBLE);
}
}
});
oa.start();
}
use of android.animation.PropertyValuesHolder in project android_packages_apps_Launcher2 by CyanogenMod.
the class Folder method animateClosed.
public void animateClosed() {
if (!(getParent() instanceof DragLayer))
return;
PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0);
PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.9f);
PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.9f);
final ObjectAnimator oa = mOpenCloseAnimator = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);
oa.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
onCloseComplete();
setLayerType(LAYER_TYPE_NONE, null);
mState = STATE_SMALL;
}
@Override
public void onAnimationStart(Animator animation) {
sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, getContext().getString(R.string.folder_closed));
mState = STATE_ANIMATING;
}
});
oa.setDuration(mExpandDuration);
setLayerType(LAYER_TYPE_HARDWARE, null);
buildLayer();
post(new Runnable() {
public void run() {
// Check if the animator changed in the meantime
if (oa != mOpenCloseAnimator)
return;
oa.start();
}
});
}
use of android.animation.PropertyValuesHolder in project android_packages_apps_Launcher2 by CyanogenMod.
the class Folder method animateOpen.
public void animateOpen() {
positionAndSizeAsIcon();
if (!(getParent() instanceof DragLayer))
return;
centerAboutIcon();
PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1);
PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f);
PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f);
final ObjectAnimator oa = mOpenCloseAnimator = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);
oa.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, String.format(getContext().getString(R.string.folder_opened), mContent.getCountX(), mContent.getCountY()));
mState = STATE_ANIMATING;
}
@Override
public void onAnimationEnd(Animator animation) {
mState = STATE_OPEN;
setLayerType(LAYER_TYPE_NONE, null);
Cling cling = mLauncher.showFirstRunFoldersCling();
if (cling != null) {
cling.bringToFront();
}
setFocusOnFirstChild();
}
});
oa.setDuration(mExpandDuration);
setLayerType(LAYER_TYPE_HARDWARE, null);
buildLayer();
post(new Runnable() {
public void run() {
// Check if the animator changed in the meantime
if (oa != mOpenCloseAnimator)
return;
oa.start();
}
});
}
use of android.animation.PropertyValuesHolder in project android_packages_apps_Launcher2 by CyanogenMod.
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.PropertyValuesHolder in project AndroidChromium by JackyAndroid.
the class StackViewAnimation method createNewTabOpenedAnimator.
private Animator createNewTabOpenedAnimator(StackTab[] tabs, ViewGroup container, TabModel model, int focusIndex) {
Tab tab = model.getTabAt(focusIndex);
if (tab == null || !tab.isNativePage())
return null;
View view = tab.getView();
if (view == null)
return null;
// Set up the view hierarchy
if (view.getParent() != null)
((ViewGroup) view.getParent()).removeView(view);
ViewGroup bgView = new FrameLayout(view.getContext());
bgView.setBackgroundColor(tab.getBackgroundColor());
bgView.addView(view);
container.addView(bgView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
// Update any compositor state that needs to change
if (tabs != null && focusIndex >= 0 && focusIndex < tabs.length) {
tabs[focusIndex].setAlpha(0.f);
}
// Build the view animations
PropertyValuesHolder xScale = PropertyValuesHolder.ofFloat(View.SCALE_X, 0.f, 1.f);
PropertyValuesHolder yScale = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.f, 1.f);
PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0.f, 1.f);
ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(bgView, xScale, yScale, alpha);
animator.setDuration(TAB_OPENED_ANIMATION_DURATION);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_FOLLOW_THROUGH_CURVE);
float insetPx = TAB_OPENED_PIVOT_INSET_DP * mDpToPx;
bgView.setPivotY(TAB_OPENED_PIVOT_INSET_DP);
bgView.setPivotX(LocalizationUtils.isLayoutRtl() ? mWidthDp * mDpToPx - insetPx : insetPx);
return animator;
}
Aggregations