List of usage examples for android.animation ObjectAnimator addListener
public void addListener(AnimatorListener listener)
From source file:com.fairphone.fplauncher3.Folder.java
public void animateClosed() { if (!(getParent() instanceof DragLayer)) { return;/*w w w . j a va 2 s . com*/ } 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:android.support.transition.ChangeTransform.java
private ObjectAnimator createTransformAnimator(TransitionValues startValues, TransitionValues endValues, final boolean handleParentChange) { Matrix startMatrix = (Matrix) startValues.values.get(PROPNAME_MATRIX); Matrix endMatrix = (Matrix) endValues.values.get(PROPNAME_MATRIX); if (startMatrix == null) { startMatrix = MatrixUtils.IDENTITY_MATRIX; }//from w ww .j a va 2s. c o m if (endMatrix == null) { endMatrix = MatrixUtils.IDENTITY_MATRIX; } if (startMatrix.equals(endMatrix)) { return null; } final Transforms transforms = (Transforms) endValues.values.get(PROPNAME_TRANSFORMS); // clear the transform properties so that we can use the animation matrix instead final View view = endValues.view; setIdentityTransforms(view); final float[] startMatrixValues = new float[9]; startMatrix.getValues(startMatrixValues); final float[] endMatrixValues = new float[9]; endMatrix.getValues(endMatrixValues); final PathAnimatorMatrix pathAnimatorMatrix = new PathAnimatorMatrix(view, startMatrixValues); PropertyValuesHolder valuesProperty = PropertyValuesHolder.ofObject(NON_TRANSLATIONS_PROPERTY, new FloatArrayEvaluator(new float[9]), startMatrixValues, endMatrixValues); Path path = getPathMotion().getPath(startMatrixValues[Matrix.MTRANS_X], startMatrixValues[Matrix.MTRANS_Y], endMatrixValues[Matrix.MTRANS_X], endMatrixValues[Matrix.MTRANS_Y]); PropertyValuesHolder translationProperty = PropertyValuesHolderUtils.ofPointF(TRANSLATIONS_PROPERTY, path); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(pathAnimatorMatrix, valuesProperty, translationProperty); final Matrix finalEndMatrix = endMatrix; AnimatorListenerAdapter listener = new AnimatorListenerAdapter() { private boolean mIsCanceled; private Matrix mTempMatrix = new Matrix(); @Override public void onAnimationCancel(Animator animation) { mIsCanceled = true; } @Override public void onAnimationEnd(Animator animation) { if (!mIsCanceled) { if (handleParentChange && mUseOverlay) { setCurrentMatrix(finalEndMatrix); } else { view.setTag(R.id.transition_transform, null); view.setTag(R.id.parent_matrix, null); } } ViewUtils.setAnimationMatrix(view, null); transforms.restore(view); } @Override public void onAnimationPause(Animator animation) { Matrix currentMatrix = pathAnimatorMatrix.getMatrix(); setCurrentMatrix(currentMatrix); } @Override public void onAnimationResume(Animator animation) { setIdentityTransforms(view); } private void setCurrentMatrix(Matrix currentMatrix) { mTempMatrix.set(currentMatrix); view.setTag(R.id.transition_transform, mTempMatrix); transforms.restore(view); } }; animator.addListener(listener); AnimatorUtils.addPauseListener(animator, listener); return animator; }
From source file:com.phonemetra.turbo.launcher.AsyncTaskCallback.java
Animator getChangeStateAnimation(final State state, boolean animated, int delay, int snapPage) { if (mState == state) { return null; }/* w w w.j av a 2 s.c o m*/ // Initialize animation arrays for the first time if necessary initAnimationArrays(); AnimatorSet anim = animated ? LauncherAnimUtils.createAnimatorSet() : null; final State oldState = mState; final boolean oldStateIsNormal = (oldState == State.NORMAL); final boolean oldStateIsOverview = (oldState == State.OVERVIEW); setState(state); final boolean stateIsNormal = (state == State.NORMAL); final boolean stateIsOverview = (state == State.OVERVIEW); float finalBackgroundAlpha = stateIsOverview ? 1.0f : 0f; float finalPageIndicatorAlpha = stateIsOverview ? 0f : 1f; float finalOverviewPanelAlpha = stateIsOverview ? 1f : 0f; float finalWorkspaceTranslationY = stateIsOverview ? getOverviewModeTranslationY() : 0; boolean workspaceToOverview = (oldStateIsNormal && stateIsOverview); boolean overviewToWorkspace = (oldStateIsOverview && stateIsNormal); mNewScale = 1.0f; if (state != State.NORMAL) { if (stateIsOverview) { mNewScale = mOverviewModeShrinkFactor; } } final int duration = getResources().getInteger(R.integer.config_overviewTransitionTime); for (int i = 0; i < getChildCount(); i++) { final CellLayout cl = (CellLayout) getChildAt(i); float finalAlpha = 1f; if (stateIsOverview) { cl.setVisibility(VISIBLE); cl.setTranslationX(0f); cl.setTranslationY(0f); cl.setPivotX(cl.getMeasuredWidth() * 0.5f); cl.setPivotY(cl.getMeasuredHeight() * 0.5f); cl.setRotation(0f); cl.setRotationY(0f); cl.setRotationX(0f); cl.setScaleX(1f); cl.setScaleY(1f); cl.setShortcutAndWidgetAlpha(1f); } mOldAlphas[i] = cl.getShortcutsAndWidgets().getAlpha(); mNewAlphas[i] = finalAlpha; if (animated) { mOldBackgroundAlphas[i] = cl.getBackgroundAlpha(); mNewBackgroundAlphas[i] = finalBackgroundAlpha; } else { cl.setBackgroundAlpha(finalBackgroundAlpha); cl.setShortcutAndWidgetAlpha(finalAlpha); } } final View overviewPanel = mLauncher.getOverviewPanel(); if (animated) { anim.setDuration(duration); LauncherViewPropertyAnimator scale = new LauncherViewPropertyAnimator(this); scale.scaleX(mNewScale).scaleY(mNewScale).translationY(finalWorkspaceTranslationY) .setInterpolator(mZoomInInterpolator); anim.play(scale); ValueAnimator invalidate = ValueAnimator.ofFloat(0f, 1f); invalidate.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { invalidate(); } }); anim.play(invalidate); ObjectAnimator pageIndicatorAlpha = null; if (getPageIndicator() != null) { pageIndicatorAlpha = ObjectAnimator.ofFloat(getPageIndicator(), "alpha", finalPageIndicatorAlpha); } ObjectAnimator overviewPanelAlpha = ObjectAnimator.ofFloat(overviewPanel, "alpha", finalOverviewPanelAlpha); overviewPanelAlpha.addListener(new AlphaUpdateListener(overviewPanel)); if (overviewToWorkspace) { overviewPanelAlpha.setInterpolator(new DecelerateInterpolator(2)); } if (getPageIndicator() != null) { pageIndicatorAlpha.addListener(new AlphaUpdateListener(getPageIndicator())); } anim.play(overviewPanelAlpha); anim.play(pageIndicatorAlpha); for (int index = 0; index < getChildCount(); index++) { final int i = index; final CellLayout cl = (CellLayout) getChildAt(i); if (mOldAlphas[i] == 0 && mNewAlphas[i] == 0) { cl.setBackgroundAlpha(mNewBackgroundAlphas[i]); cl.getShortcutsAndWidgets().setAlpha(mNewAlphas[i]); } else { LauncherViewPropertyAnimator a = new LauncherViewPropertyAnimator(cl.getShortcutsAndWidgets()); a.alpha(mNewAlphas[i]).setDuration(duration).setInterpolator(mZoomInInterpolator); anim.play(a); if (mOldBackgroundAlphas[i] != 0 || mNewBackgroundAlphas[i] != 0) { ValueAnimator bgAnim = LauncherAnimUtils.ofFloat(cl, 0f, 1f); bgAnim.setInterpolator(mZoomInInterpolator); bgAnim.addUpdateListener(new LauncherAnimatorUpdateListener() { public void onAnimationUpdate(float a, float b) { cl.setBackgroundAlpha(a * mOldBackgroundAlphas[i] + b * mNewBackgroundAlphas[i]); } }); anim.play(bgAnim); } } } anim.setStartDelay(delay); } else { overviewPanel.setAlpha(finalOverviewPanelAlpha); AlphaUpdateListener.updateVisibility(overviewPanel); if (getPageIndicator() != null) { getPageIndicator().setAlpha(finalPageIndicatorAlpha); AlphaUpdateListener.updateVisibility(getPageIndicator()); } setScaleX(mNewScale); setScaleY(mNewScale); setTranslationY(finalWorkspaceTranslationY); } return anim; }
From source file:org.chromium.chrome.browser.toolbar.ToolbarPhone.java
private ObjectAnimator createEnterTabSwitcherModeAnimation() { ObjectAnimator enterAnimation = ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 1.f); enterAnimation.setDuration(TAB_SWITCHER_MODE_ENTER_ANIMATION_DURATION_MS); enterAnimation.setInterpolator(new LinearInterpolator()); enterAnimation.addListener(new AnimatorListenerAdapter() { @Override/*from w ww. j a v a 2 s . c o m*/ public void onAnimationEnd(Animator animation) { // This is to deal with the view going invisible when resuming the activity and // running this animation. The view is still there and clickable but does not // render and only a layout triggers a refresh. See crbug.com/306890. if (!mToggleTabStackButton.isEnabled()) requestLayout(); } }); return enterAnimation; }
From source file:org.chromium.chrome.browser.toolbar.ToolbarPhone.java
private ObjectAnimator createPostExitTabSwitcherAnimation() { ObjectAnimator exitAnimation = ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, -getHeight(), 0.f); exitAnimation.setDuration(TAB_SWITCHER_MODE_POST_EXIT_ANIMATION_DURATION_MS); exitAnimation.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); exitAnimation.addListener(new AnimatorListenerAdapter() { @Override/*from www. ja v a2s . c om*/ public void onAnimationStart(Animator animation) { updateViewsForTabSwitcherMode(); // On older builds, force an update to ensure the new visuals are used // when bringing in the toolbar. crbug.com/404571 if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN) { requestLayout(); } } @Override public void onAnimationEnd(Animator animation) { mDelayedTabSwitcherModeAnimation = null; updateShadowVisibility(); updateViewsForTabSwitcherMode(); } }); return exitAnimation; }
From source file:org.chromium.chrome.browser.toolbar.ToolbarPhone.java
private ObjectAnimator createExitTabSwitcherAnimation(final boolean animateNormalToolbar) { ObjectAnimator exitAnimation = ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 0.f); exitAnimation.setDuration(animateNormalToolbar ? TAB_SWITCHER_MODE_EXIT_NORMAL_ANIMATION_DURATION_MS : TAB_SWITCHER_MODE_EXIT_FADE_ANIMATION_DURATION_MS); exitAnimation.setInterpolator(new LinearInterpolator()); exitAnimation.addListener(new AnimatorListenerAdapter() { @Override/*from www . j a v a 2s .c om*/ public void onAnimationEnd(Animator animation) { updateViewsForTabSwitcherMode(); } }); return exitAnimation; }
From source file:com.arlib.floatingsearchview.FloatingSearchView.java
private void transitionOutLeftSection(boolean withAnim) { switch (mLeftActionMode) { case LEFT_ACTION_MODE_SHOW_HAMBURGER: closeMenuDrawable(mMenuBtnDrawable, withAnim); break;/*from ww w .j a v a 2 s . c o m*/ case LEFT_ACTION_MODE_SHOW_SEARCH: changeIcon(mLeftAction, mIconSearch, withAnim); break; case LEFT_ACTION_MODE_SHOW_HOME: //do nothing break; case LEFT_ACTION_MODE_NO_LEFT_ACTION: mLeftAction.setImageDrawable(mIconBackArrow); if (withAnim) { ObjectAnimator searchInputTransXAnim = ViewPropertyObjectAnimator.animate(mSearchInputParent) .translationX(-Util.dpToPx(LEFT_MENU_WIDTH_AND_MARGIN_START_DP)).get(); ObjectAnimator scaleXArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).scaleX(0.5f).get(); ObjectAnimator scaleYArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).scaleY(0.5f).get(); ObjectAnimator fadeArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).alpha(0.5f).get(); scaleXArrowAnim.setDuration(300); scaleYArrowAnim.setDuration(300); fadeArrowAnim.setDuration(300); scaleXArrowAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { //restore normal state mLeftAction.setScaleX(1.0f); mLeftAction.setScaleY(1.0f); mLeftAction.setAlpha(1.0f); mLeftAction.setVisibility(View.INVISIBLE); } }); AnimatorSet animSet = new AnimatorSet(); animSet.setDuration(350); animSet.playTogether(scaleXArrowAnim, scaleYArrowAnim, fadeArrowAnim, searchInputTransXAnim); animSet.start(); } else { mLeftAction.setVisibility(View.INVISIBLE); } break; } }
From source file:com.gigabytedevelopersinc.app.calculator.Calculator.java
private void dismissCling(final Cling cling, final String flag, int duration) { setPagingEnabled(true);/*from w w w .j av a2 s. c o m*/ clingActive = false; if (cling != null) { cling.dismiss(); if (getActionBar() != null) { getActionBar().show(); } getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#FFFFFF"))); ObjectAnimator anim = ObjectAnimator.ofFloat(cling, "alpha", 0f); anim.setDuration(duration); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { cling.setVisibility(View.GONE); cling.cleanup(); CalculatorSettings.saveKey(getContext(), flag, true); } }); anim.start(); } }
From source file:com.aliyun.homeshell.Folder.java
public void animateOpen() { positionAndSizeAsIcon();/* ww w . j ava 2s . c om*/ 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.amaze.filemanager.activities.MainActivity.java
void revealShow(final View view, boolean reveal) { if (reveal) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 0f, 1f); animator.setDuration(300); //ms animator.addListener(new AnimatorListenerAdapter() { @Override/*from w ww.j a v a 2s . co m*/ public void onAnimationStart(Animator animation) { view.setVisibility(View.VISIBLE); } }); animator.start(); } else { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 1f, 0f); animator.setDuration(300); //ms animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.GONE); } }); animator.start(); } }