List of usage examples for android.animation PropertyValuesHolder ofFloat
public static PropertyValuesHolder ofFloat(Property<?, Float> property, float... values)
From source file:com.phonemetra.turbo.launcher.Folder.java
public void animateOpen() { positionAndSizeAsIcon();//from ww w. ja va2 s. co m 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 = 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); setFocusOnFirstChild(); } }); oa.setDuration(mExpandDuration); setLayerType(LAYER_TYPE_HARDWARE, null); oa.start(); // Make sure the folder picks up the last drag move even if the finger doesn't move. if (mDragController.isDragging()) { mDragController.forceTouchMove(); } }
From source file:android.support.graphics.drawable.AnimatorInflaterCompat.java
private static void setupPathMotion(Path path, ObjectAnimator oa, float precision, String propertyXName, String propertyYName) {//from w w w. ja v a 2 s .c o m // Measure the total length the whole path. final PathMeasure measureForTotalLength = new PathMeasure(path, false); float totalLength = 0; // The sum of the previous contour plus the current one. Using the sum here b/c we want to // directly substract from it later. ArrayList<Float> contourLengths = new ArrayList<>(); contourLengths.add(0f); do { final float pathLength = measureForTotalLength.getLength(); totalLength += pathLength; contourLengths.add(totalLength); } while (measureForTotalLength.nextContour()); // Now determine how many sample points we need, and the step for next sample. final PathMeasure pathMeasure = new PathMeasure(path, false); final int numPoints = min(MAX_NUM_POINTS, (int) (totalLength / precision) + 1); float[] mX = new float[numPoints]; float[] mY = new float[numPoints]; final float[] position = new float[2]; int contourIndex = 0; float step = totalLength / (numPoints - 1); float currentDistance = 0; // For each sample point, determine whether we need to move on to next contour. // After we find the right contour, then sample it using the current distance value minus // the previously sampled contours' total length. for (int i = 0; i < numPoints; ++i) { pathMeasure.getPosTan(currentDistance, position, null); pathMeasure.getPosTan(currentDistance, position, null); mX[i] = position[0]; mY[i] = position[1]; currentDistance += step; if ((contourIndex + 1) < contourLengths.size() && currentDistance > contourLengths.get(contourIndex + 1)) { currentDistance -= contourLengths.get(contourIndex + 1); contourIndex++; pathMeasure.nextContour(); } } // Given the x and y value of the sample points, setup the ObjectAnimator properly. PropertyValuesHolder x = null; PropertyValuesHolder y = null; if (propertyXName != null) { x = PropertyValuesHolder.ofFloat(propertyXName, mX); } if (propertyYName != null) { y = PropertyValuesHolder.ofFloat(propertyYName, mY); } if (x == null) { oa.setValues(y); } else if (y == null) { oa.setValues(x); } else { oa.setValues(x, y); } }
From source file:com.fairphone.fplauncher3.Folder.java
public void animateClosed() { if (!(getParent() instanceof DragLayer)) { return;//from ww w. j a v a 2 s .c o m } PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.9f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.9f); /*final ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);*/ setLayerType(LAYER_TYPE_HARDWARE, null); float animatorDurationScale = Settings.Global.getFloat(getContext().getContentResolver(), Settings.Global.ANIMATOR_DURATION_SCALE, 1); ObjectAnimator oa; if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && mPowerManager.isPowerSaveMode()) || animatorDurationScale < 0.01f) { // power save mode is no fun - skip alpha animation and just set it to 0 // otherwise the icons will stay around until the duration of the animation oa = LauncherAnimUtils.ofPropertyValuesHolder(this, scaleX, scaleY); setAlpha(0f); } else { oa = 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); oa.start(); }
From source file:com.klinker.android.launcher.launcher3.Workspace.java
private void fadeAndRemoveEmptyScreen(int delay, int duration, final Runnable onComplete, final boolean stripEmptyScreens) { // XXX: Do we need to update LM workspace screens below? PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f); PropertyValuesHolder bgAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", 0f); final CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_ID); mRemoveEmptyScreenRunnable = new Runnable() { @Override//from w ww . j a v a 2 s.com public void run() { if (hasExtraEmptyScreen()) { mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_ID); mScreenOrder.remove(EXTRA_EMPTY_SCREEN_ID); removeView(cl); if (stripEmptyScreens) { stripEmptyScreens(); } } } }; ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(cl, alpha, bgAlpha); oa.setDuration(duration); oa.setStartDelay(delay); oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mRemoveEmptyScreenRunnable != null) { mRemoveEmptyScreenRunnable.run(); } if (onComplete != null) { onComplete.run(); } } }); oa.start(); }
From source file:com.android.calculator2.Calculator.java
private void onResult(boolean animate) { // Calculate the textSize that would be used to display the result in the formula. // For scrollable results just use the minimum textSize to maximize the number of digits // that are visible on screen. float textSize = mFormulaText.getMinimumTextSize(); if (!mResultText.isScrollable()) { textSize = mFormulaText.getVariableTextSize(mResultText.getText().toString()); }//from w ww. j av a 2 s . c o m // Scale the result to match the calculated textSize, minimizing the jump-cut transition // when a result is reused in a subsequent expression. final float resultScale = textSize / mResultText.getTextSize(); // Set the result's pivot to match its gravity. mResultText.setPivotX(mResultText.getWidth() - mResultText.getPaddingRight()); mResultText.setPivotY(mResultText.getHeight() - mResultText.getPaddingBottom()); // Calculate the necessary translations so the result takes the place of the formula and // the formula moves off the top of the screen. final float resultTranslationY = (mFormulaText.getBottom() - mResultText.getBottom()) - (mFormulaText.getPaddingBottom() - mResultText.getPaddingBottom()); final float formulaTranslationY = -mFormulaText.getBottom(); // Change the result's textColor to match the formula. final int formulaTextColor = mFormulaText.getCurrentTextColor(); if (animate) { mResultText.announceForAccessibility(getResources().getString(R.string.desc_eq)); mResultText.announceForAccessibility(mResultText.getText()); setState(CalculatorState.ANIMATE); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofPropertyValuesHolder(mResultText, PropertyValuesHolder.ofFloat(View.SCALE_X, resultScale), PropertyValuesHolder.ofFloat(View.SCALE_Y, resultScale), PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, resultTranslationY)), ObjectAnimator.ofArgb(mResultText, TEXT_COLOR, formulaTextColor), ObjectAnimator.ofFloat(mFormulaText, View.TRANSLATION_Y, formulaTranslationY)); animatorSet.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime)); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setState(CalculatorState.RESULT); mCurrentAnimator = null; } }); mCurrentAnimator = animatorSet; animatorSet.start(); } else /* No animation desired; get there fast, e.g. when restarting */ { mResultText.setScaleX(resultScale); mResultText.setScaleY(resultScale); mResultText.setTranslationY(resultTranslationY); mResultText.setTextColor(formulaTextColor); mFormulaText.setTranslationY(formulaTranslationY); setState(CalculatorState.RESULT); } }
From source file:com.phonemetra.turbo.launcher.Workspace.java
private void fadeAndRemoveEmptyScreen(int delay, int duration, final Runnable onComplete, final boolean stripEmptyScreens) { PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f); PropertyValuesHolder bgAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", 0f); final CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_ID); mRemoveEmptyScreenRunnable = new Runnable() { @Override/*from w w w . jav a 2s. c om*/ public void run() { if (hasExtraEmptyScreen()) { mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_ID); mScreenOrder.remove(EXTRA_EMPTY_SCREEN_ID); removeView(cl); if (stripEmptyScreens) { stripEmptyScreens(); } } } }; ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(cl, alpha, bgAlpha); oa.setDuration(duration); oa.setStartDelay(delay); oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mRemoveEmptyScreenRunnable != null) { mRemoveEmptyScreenRunnable.run(); } if (onComplete != null) { onComplete.run(); } } }); oa.start(); }
From source file:com.android.launcher3.Workspace.java
private void fadeAndRemoveEmptyScreen(int delay, int duration, final Runnable onComplete, final boolean stripEmptyScreens) { // Log to disk // XXX: Do we need to update LM workspace screens below? Launcher.addDumpLog(TAG, "11683562 - fadeAndRemoveEmptyScreen()", true); PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f); PropertyValuesHolder bgAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", 0f); final CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_ID); mRemoveEmptyScreenRunnable = new Runnable() { @Override//from w w w . ja v a 2 s .c o m public void run() { if (hasExtraEmptyScreen()) { mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_ID); mScreenOrder.remove(EXTRA_EMPTY_SCREEN_ID); removeView(cl); if (stripEmptyScreens) { stripEmptyScreens(); } } } }; ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(cl, alpha, bgAlpha); oa.setDuration(duration); oa.setStartDelay(delay); oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mRemoveEmptyScreenRunnable != null) { mRemoveEmptyScreenRunnable.run(); } if (onComplete != null) { onComplete.run(); } } }); oa.start(); }
From source file:com.aliyun.homeshell.Folder.java
public void animateOpen() { positionAndSizeAsIcon();//from w w w. j a v a 2 s . c o m 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 = 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); /* YUNOS BEGIN */ // ##date:2013/11/27 ##author:zhangqiang.zq // remove cling /* * Cling cling = mLauncher.showFirstRunFoldersCling(); if (cling * != null) { cling.bringToFront(); } */ /* YUNOS END */ setFocusOnFirstChild(); setAlpha(1); setScaleX(1); setScaleY(1); /*YUNOS BEGIN*/ //##date:2014/06/10 ##author:guoshuai.lgs ##BugID: //support the folder feature in mainmenu if (mInfo.isMainmenuFolder() && (LauncherApplication.isMainmenuMode())) { mLauncher.getAppsCustomizeTabHost().setVisibility(View.INVISIBLE); } /*YUNOS END*/ } }); oa.setDuration(mExpandDuration); setLayerType(LAYER_TYPE_HARDWARE, null); oa.start(); }
From source file:com.stanleyidesis.quotograph.ui.activity.LWQSettingsActivity.java
Animator generateAnimator(View target, boolean dismiss, long startDelay) { float[] fadeIn = new float[] { 0f, 1f }; float[] fadeOut = new float[] { 1f, 0f }; final ObjectAnimator propAnimator = ObjectAnimator.ofPropertyValuesHolder(target, PropertyValuesHolder.ofFloat(View.ALPHA, dismiss ? fadeOut : fadeIn), PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, dismiss ? (target.getHeight() * 2f) : 0f)); propAnimator.setStartDelay(startDelay); propAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); propAnimator.setDuration(240);/* w ww . ja v a2 s .c om*/ return propAnimator; }
From source file:com.stanleyidesis.quotograph.ui.activity.LWQSettingsActivity.java
Animator animateFAB(final View fabToAnimate, final boolean dismiss) { fabToAnimate.setVisibility(View.VISIBLE); float[] toFrom = dismiss ? new float[] { 1f, .2f } : new float[] { .2f, 1f }; AnimatorSet animatorSet = new AnimatorSet(); animatorSet.addListener(new AnimatorListenerAdapter() { @Override//from www . j a v a 2 s.c o m public void onAnimationEnd(Animator animation) { fabToAnimate.setVisibility(dismiss ? View.GONE : View.VISIBLE); } }); ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(fabToAnimate, "alpha", toFrom); alphaAnimator.setDuration(200); alphaAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); // Create a scale + fade animation ObjectAnimator scaleDown = ObjectAnimator.ofPropertyValuesHolder(fabToAnimate, PropertyValuesHolder.ofFloat("scaleX", toFrom), PropertyValuesHolder.ofFloat("scaleY", toFrom)); scaleDown.setDuration(200); scaleDown.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.playTogether(scaleDown, alphaAnimator); return animatorSet; }