List of usage examples for android.animation ObjectAnimator setInterpolator
@Override public void setInterpolator(TimeInterpolator value)
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 w w w .j a va 2 s .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 w w w . j av a 2 s . c o m public void onAnimationEnd(Animator animation) { updateViewsForTabSwitcherMode(); } }); return exitAnimation; }
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; }//from www. j a v a2s.com // 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:com.android.leanlauncher.LauncherTransitionable.java
private void showAppsCustomizeHelper(final boolean animated, final boolean springLoaded, final AppsCustomizePagedView.ContentType contentType) { if (mStateAnimation != null) { mStateAnimation.setDuration(0);/*from w w w . j a v a2 s .c o m*/ mStateAnimation.cancel(); mStateAnimation = null; } boolean material = Utilities.isLmpOrAbove(); final Resources res = getResources(); final int revealDuration = res.getInteger(R.integer.config_appsCustomizeRevealTime); final int itemsAlphaStagger = res.getInteger(R.integer.config_appsCustomizeItemsAlphaStagger); final View fromView = mWorkspace; final AppsCustomizeTabHost toView = mAppsCustomizeTabHost; final ArrayList<View> layerViews = new ArrayList<View>(); Workspace.State workspaceState = contentType == AppsCustomizePagedView.ContentType.Widgets ? Workspace.State.OVERVIEW_HIDDEN : Workspace.State.NORMAL_HIDDEN; Animator workspaceAnim = mWorkspace.getChangeStateAnimation(workspaceState, animated, layerViews); // Set the content type for the all apps/widgets space mAppsCustomizeTabHost.setContentTypeImmediate(contentType); // If for some reason our views aren't initialized, don't animate boolean initialized = getAllAppsButton() != null; if (animated && initialized) { mStateAnimation = LauncherAnimUtils.createAnimatorSet(); final AppsCustomizePagedView content = (AppsCustomizePagedView) toView .findViewById(R.id.apps_customize_pane_content); final View page = content.getPageAt(content.getCurrentPage()); final View revealView = toView.findViewById(R.id.fake_page); final boolean isWidgetTray = contentType == AppsCustomizePagedView.ContentType.Widgets; revealView.setBackgroundColor(getResources().getColor(R.color.widget_text_panel)); // Hide the real page background, and swap in the fake one content.setPageBackgroundsVisible(false); revealView.setVisibility(View.VISIBLE); // We need to hide this view as the animation start will be posted. revealView.setAlpha(0); int width = revealView.getMeasuredWidth(); int height = revealView.getMeasuredHeight(); float revealRadius = (float) Math.sqrt((width * width) / 4 + (height * height) / 4); revealView.setTranslationY(0); revealView.setTranslationX(0); // Get the y delta between the center of the page and the center of the all apps button int[] allAppsToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView, getAllAppsButton(), null); float alpha = 0; float xDrift = 0; float yDrift = 0; if (material) { alpha = isWidgetTray ? 0.3f : 1f; yDrift = isWidgetTray ? height / 2 : allAppsToPanelDelta[1]; xDrift = isWidgetTray ? 0 : allAppsToPanelDelta[0]; } else { yDrift = 2 * height / 3; xDrift = 0; } final float initAlpha = alpha; revealView.setLayerType(View.LAYER_TYPE_HARDWARE, null); layerViews.add(revealView); PropertyValuesHolder panelAlpha = PropertyValuesHolder.ofFloat("alpha", initAlpha, 1f); PropertyValuesHolder panelDriftY = PropertyValuesHolder.ofFloat("translationY", yDrift, 0); PropertyValuesHolder panelDriftX = PropertyValuesHolder.ofFloat("translationX", xDrift, 0); ObjectAnimator panelAlphaAndDrift = ObjectAnimator.ofPropertyValuesHolder(revealView, panelAlpha, panelDriftY, panelDriftX); panelAlphaAndDrift.setDuration(revealDuration); panelAlphaAndDrift.setInterpolator(new LogDecelerateInterpolator(100, 0)); mStateAnimation.play(panelAlphaAndDrift); if (page != null) { page.setVisibility(View.VISIBLE); page.setLayerType(View.LAYER_TYPE_HARDWARE, null); layerViews.add(page); ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, "translationY", yDrift, 0); page.setTranslationY(yDrift); pageDrift.setDuration(revealDuration); pageDrift.setInterpolator(new LogDecelerateInterpolator(100, 0)); pageDrift.setStartDelay(itemsAlphaStagger); mStateAnimation.play(pageDrift); page.setAlpha(0f); ObjectAnimator itemsAlpha = ObjectAnimator.ofFloat(page, "alpha", 0f, 1f); itemsAlpha.setDuration(revealDuration); itemsAlpha.setInterpolator(new AccelerateInterpolator(1.5f)); itemsAlpha.setStartDelay(itemsAlphaStagger); mStateAnimation.play(itemsAlpha); } View pageIndicators = toView.findViewById(R.id.apps_customize_page_indicator); pageIndicators.setAlpha(0.01f); ObjectAnimator indicatorsAlpha = ObjectAnimator.ofFloat(pageIndicators, "alpha", 1f); indicatorsAlpha.setDuration(revealDuration); mStateAnimation.play(indicatorsAlpha); if (material) { final View allApps = getAllAppsButton(); int allAppsButtonSize = LauncherAppState.getInstance().getDynamicGrid() .getDeviceProfile().allAppsButtonVisualSize; float startRadius = isWidgetTray ? 0 : allAppsButtonSize / 2; Animator reveal = ViewAnimationUtils.createCircularReveal(revealView, width / 2, height / 2, startRadius, revealRadius); reveal.setDuration(revealDuration); reveal.setInterpolator(new LogDecelerateInterpolator(100, 0)); reveal.addListener(new AnimatorListenerAdapter() { public void onAnimationStart(Animator animation) { if (!isWidgetTray) { allApps.setVisibility(View.INVISIBLE); } } public void onAnimationEnd(Animator animation) { if (!isWidgetTray) { allApps.setVisibility(View.VISIBLE); } } }); mStateAnimation.play(reveal); } mStateAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dispatchOnLauncherTransitionEnd(fromView, animated, false); dispatchOnLauncherTransitionEnd(toView, animated, false); revealView.setVisibility(View.INVISIBLE); revealView.setLayerType(View.LAYER_TYPE_NONE, null); if (page != null) { page.setLayerType(View.LAYER_TYPE_NONE, null); } content.setPageBackgroundsVisible(true); // This can hold unnecessary references to views. mStateAnimation = null; } }); if (workspaceAnim != null) { mStateAnimation.play(workspaceAnim); } dispatchOnLauncherTransitionPrepare(fromView, animated, false); dispatchOnLauncherTransitionPrepare(toView, animated, false); final AnimatorSet stateAnimation = mStateAnimation; final Runnable startAnimRunnable = new Runnable() { public void run() { // Check that mStateAnimation hasn't changed while // we waited for a layout/draw pass if (mStateAnimation != stateAnimation) return; dispatchOnLauncherTransitionStart(fromView, animated, false); dispatchOnLauncherTransitionStart(toView, animated, false); revealView.setAlpha(initAlpha); if (Utilities.isLmpOrAbove()) { for (int i = 0; i < layerViews.size(); i++) { View v = layerViews.get(i); if (v != null) { if (Utilities.isViewAttachedToWindow(v)) v.buildLayer(); } } } mStateAnimation.start(); } }; toView.bringToFront(); toView.setVisibility(View.VISIBLE); toView.post(startAnimRunnable); } else { toView.setTranslationX(0.0f); toView.setTranslationY(0.0f); toView.setScaleX(1.0f); toView.setScaleY(1.0f); toView.setVisibility(View.VISIBLE); toView.bringToFront(); dispatchOnLauncherTransitionPrepare(fromView, animated, false); dispatchOnLauncherTransitionStart(fromView, animated, false); dispatchOnLauncherTransitionEnd(fromView, animated, false); dispatchOnLauncherTransitionPrepare(toView, animated, false); dispatchOnLauncherTransitionStart(toView, animated, false); dispatchOnLauncherTransitionEnd(toView, animated, false); } }
From source file:com.android.leanlauncher.LauncherTransitionable.java
/** * Zoom the camera back into the workspace, hiding 'fromView'. * This is the opposite of showAppsCustomizeHelper. * * @param animated If true, the transition will be animated. *///w ww . j a va 2 s. c o m private void hideAppsCustomizeHelper(Workspace.State toState, final boolean animated, final boolean springLoaded, final Runnable onCompleteRunnable) { if (mStateAnimation != null) { mStateAnimation.setDuration(0); mStateAnimation.cancel(); mStateAnimation = null; } boolean material = Utilities.isLmpOrAbove(); Resources res = getResources(); final int revealDuration = res.getInteger(R.integer.config_appsCustomizeConcealTime); final int itemsAlphaStagger = res.getInteger(R.integer.config_appsCustomizeItemsAlphaStagger); final View fromView = mAppsCustomizeTabHost; final View toView = mWorkspace; Animator workspaceAnim = null; final ArrayList<View> layerViews = new ArrayList<View>(); if (toState == Workspace.State.NORMAL) { workspaceAnim = mWorkspace.getChangeStateAnimation(toState, animated, layerViews); } else if (toState == Workspace.State.SPRING_LOADED || toState == Workspace.State.OVERVIEW) { workspaceAnim = mWorkspace.getChangeStateAnimation(toState, animated, layerViews); } // If for some reason our views aren't initialized, don't animate boolean initialized = getAllAppsButton() != null; if (animated && initialized) { mStateAnimation = LauncherAnimUtils.createAnimatorSet(); if (workspaceAnim != null) { mStateAnimation.play(workspaceAnim); } final AppsCustomizePagedView content = (AppsCustomizePagedView) fromView .findViewById(R.id.apps_customize_pane_content); final View page = content.getPageAt(content.getNextPage()); // We need to hide side pages of the Apps / Widget tray to avoid some ugly edge cases int count = content.getChildCount(); for (int i = 0; i < count; i++) { View child = content.getChildAt(i); if (child != page) { child.setVisibility(View.INVISIBLE); } } final View revealView = fromView.findViewById(R.id.fake_page); // hideAppsCustomizeHelper is called in some cases when it is already hidden // don't perform all these no-op animations. In particularly, this was causing // the all-apps button to pop in and out. if (fromView.getVisibility() == View.VISIBLE) { AppsCustomizePagedView.ContentType contentType = content.getContentType(); final boolean isWidgetTray = contentType == AppsCustomizePagedView.ContentType.Widgets; revealView.setBackgroundColor(getResources().getColor(R.color.widget_text_panel)); int width = revealView.getMeasuredWidth(); int height = revealView.getMeasuredHeight(); float revealRadius = (float) Math.sqrt((width * width) / 4 + (height * height) / 4); // Hide the real page background, and swap in the fake one revealView.setVisibility(View.VISIBLE); content.setPageBackgroundsVisible(false); final View allAppsButton = getAllAppsButton(); revealView.setTranslationY(0); int[] allAppsToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView, allAppsButton, null); float xDrift = 0; float yDrift = 0; if (material) { yDrift = isWidgetTray ? height / 2 : allAppsToPanelDelta[1]; xDrift = isWidgetTray ? 0 : allAppsToPanelDelta[0]; } else { yDrift = 2 * height / 3; xDrift = 0; } revealView.setLayerType(View.LAYER_TYPE_HARDWARE, null); TimeInterpolator decelerateInterpolator = material ? new LogDecelerateInterpolator(100, 0) : new DecelerateInterpolator(1f); // The vertical motion of the apps panel should be delayed by one frame // from the conceal animation in order to give the right feel. We correpsondingly // shorten the duration so that the slide and conceal end at the same time. ObjectAnimator panelDriftY = LauncherAnimUtils.ofFloat(revealView, "translationY", 0, yDrift); panelDriftY.setDuration(revealDuration - SINGLE_FRAME_DELAY); panelDriftY.setStartDelay(itemsAlphaStagger + SINGLE_FRAME_DELAY); panelDriftY.setInterpolator(decelerateInterpolator); mStateAnimation.play(panelDriftY); ObjectAnimator panelDriftX = LauncherAnimUtils.ofFloat(revealView, "translationX", 0, xDrift); panelDriftX.setDuration(revealDuration - SINGLE_FRAME_DELAY); panelDriftX.setStartDelay(itemsAlphaStagger + SINGLE_FRAME_DELAY); panelDriftX.setInterpolator(decelerateInterpolator); mStateAnimation.play(panelDriftX); if (isWidgetTray || !material) { float finalAlpha = material ? 0.4f : 0f; revealView.setAlpha(1f); ObjectAnimator panelAlpha = LauncherAnimUtils.ofFloat(revealView, "alpha", 1f, finalAlpha); panelAlpha.setDuration(material ? revealDuration : 150); panelAlpha.setInterpolator(decelerateInterpolator); panelAlpha.setStartDelay(material ? 0 : itemsAlphaStagger + SINGLE_FRAME_DELAY); mStateAnimation.play(panelAlpha); } if (page != null) { page.setLayerType(View.LAYER_TYPE_HARDWARE, null); ObjectAnimator pageDrift = LauncherAnimUtils.ofFloat(page, "translationY", 0, yDrift); page.setTranslationY(0); pageDrift.setDuration(revealDuration - SINGLE_FRAME_DELAY); pageDrift.setInterpolator(decelerateInterpolator); pageDrift.setStartDelay(itemsAlphaStagger + SINGLE_FRAME_DELAY); mStateAnimation.play(pageDrift); page.setAlpha(1f); ObjectAnimator itemsAlpha = LauncherAnimUtils.ofFloat(page, "alpha", 1f, 0f); itemsAlpha.setDuration(100); itemsAlpha.setInterpolator(decelerateInterpolator); mStateAnimation.play(itemsAlpha); } View pageIndicators = fromView.findViewById(R.id.apps_customize_page_indicator); pageIndicators.setAlpha(1f); ObjectAnimator indicatorsAlpha = LauncherAnimUtils.ofFloat(pageIndicators, "alpha", 0f); indicatorsAlpha.setDuration(revealDuration); indicatorsAlpha.setInterpolator(new DecelerateInterpolator(1.5f)); mStateAnimation.play(indicatorsAlpha); width = revealView.getMeasuredWidth(); if (material) { if (!isWidgetTray) { allAppsButton.setVisibility(View.INVISIBLE); } int allAppsButtonSize = LauncherAppState.getInstance().getDynamicGrid() .getDeviceProfile().allAppsButtonVisualSize; float finalRadius = isWidgetTray ? 0 : allAppsButtonSize / 2; Animator reveal = LauncherAnimUtils.createCircularReveal(revealView, width / 2, height / 2, revealRadius, finalRadius); reveal.setInterpolator(new LogDecelerateInterpolator(100, 0)); reveal.setDuration(revealDuration); reveal.setStartDelay(itemsAlphaStagger); reveal.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animation) { revealView.setVisibility(View.INVISIBLE); if (!isWidgetTray) { allAppsButton.setVisibility(View.VISIBLE); } } }); mStateAnimation.play(reveal); } dispatchOnLauncherTransitionPrepare(fromView, animated, true); dispatchOnLauncherTransitionPrepare(toView, animated, true); mAppsCustomizeContent.stopScrolling(); } mStateAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { fromView.setVisibility(View.GONE); dispatchOnLauncherTransitionEnd(fromView, animated, true); dispatchOnLauncherTransitionEnd(toView, animated, true); if (onCompleteRunnable != null) { onCompleteRunnable.run(); } revealView.setLayerType(View.LAYER_TYPE_NONE, null); if (page != null) { page.setLayerType(View.LAYER_TYPE_NONE, null); } content.setPageBackgroundsVisible(true); // Unhide side pages int count = content.getChildCount(); for (int i = 0; i < count; i++) { View child = content.getChildAt(i); child.setVisibility(View.VISIBLE); } // Reset page transforms if (page != null) { page.setTranslationX(0); page.setTranslationY(0); page.setAlpha(1); } content.setCurrentPage(content.getNextPage()); mAppsCustomizeContent.updateCurrentPageScroll(); // This can hold unnecessary references to views. mStateAnimation = null; } }); final AnimatorSet stateAnimation = mStateAnimation; final Runnable startAnimRunnable = new Runnable() { public void run() { // Check that mStateAnimation hasn't changed while // we waited for a layout/draw pass if (mStateAnimation != stateAnimation) return; dispatchOnLauncherTransitionStart(fromView, animated, false); dispatchOnLauncherTransitionStart(toView, animated, false); if (Utilities.isLmpOrAbove()) { for (int i = 0; i < layerViews.size(); i++) { View v = layerViews.get(i); if (v != null) { if (Utilities.isViewAttachedToWindow(v)) v.buildLayer(); } } } mStateAnimation.start(); } }; fromView.post(startAnimRunnable); } else { fromView.setVisibility(View.GONE); dispatchOnLauncherTransitionPrepare(fromView, animated, true); dispatchOnLauncherTransitionStart(fromView, animated, true); dispatchOnLauncherTransitionEnd(fromView, animated, true); dispatchOnLauncherTransitionPrepare(toView, animated, true); dispatchOnLauncherTransitionStart(toView, animated, true); dispatchOnLauncherTransitionEnd(toView, animated, true); } }
From source file:com.android.launcher2.Launcher.java
/** * Zoom the camera back into the workspace, hiding 'fromView'. * This is the opposite of showAppsCustomizeHelper. * @param animated If true, the transition will be animated. *///from w ww. java 2 s .co m private void hideAppsCustomizeHelper(State toState, final boolean animated, final boolean springLoaded, final Runnable onCompleteRunnable) { if (mStateAnimation != null) { mStateAnimation.cancel(); mStateAnimation = null; } Resources res = getResources(); final int duration = res.getInteger(R.integer.config_appsCustomizeZoomOutTime); final int fadeOutDuration = res.getInteger(R.integer.config_appsCustomizeFadeOutTime); final float scaleFactor = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor); final View fromView = mAppsCustomizeTabHost; final View toView = mWorkspace; Animator workspaceAnim = null; if (toState == State.WORKSPACE) { int stagger = res.getInteger(R.integer.config_appsCustomizeWorkspaceAnimationStagger); workspaceAnim = mWorkspace.getChangeStateAnimation(Workspace.State.NORMAL, animated, stagger); } else if (toState == State.APPS_CUSTOMIZE_SPRING_LOADED) { workspaceAnim = mWorkspace.getChangeStateAnimation(Workspace.State.SPRING_LOADED, animated); } setPivotsForZoom(fromView, scaleFactor); updateWallpaperVisibility(true); showHotseat(animated); if (animated) { final LauncherViewPropertyAnimator scaleAnim = new LauncherViewPropertyAnimator(fromView); scaleAnim.scaleX(scaleFactor).scaleY(scaleFactor).setDuration(duration) .setInterpolator(new Workspace.ZoomInInterpolator()); final ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(fromView, "alpha", 1f, 0f) .setDuration(fadeOutDuration); alphaAnim.setInterpolator(new AccelerateDecelerateInterpolator()); alphaAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float t = 1f - (Float) animation.getAnimatedValue(); dispatchOnLauncherTransitionStep(fromView, t); dispatchOnLauncherTransitionStep(toView, t); } }); mStateAnimation = LauncherAnimUtils.createAnimatorSet(); dispatchOnLauncherTransitionPrepare(fromView, animated, true); dispatchOnLauncherTransitionPrepare(toView, animated, true); mAppsCustomizeContent.pauseScrolling(); mStateAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { updateWallpaperVisibility(true); fromView.setVisibility(View.GONE); dispatchOnLauncherTransitionEnd(fromView, animated, true); dispatchOnLauncherTransitionEnd(toView, animated, true); if (mWorkspace != null) { mWorkspace.hideScrollingIndicator(false); } if (onCompleteRunnable != null) { onCompleteRunnable.run(); } mAppsCustomizeContent.updateCurrentPageScroll(); mAppsCustomizeContent.resumeScrolling(); } }); mStateAnimation.playTogether(scaleAnim, alphaAnim); if (workspaceAnim != null) { mStateAnimation.play(workspaceAnim); } dispatchOnLauncherTransitionStart(fromView, animated, true); dispatchOnLauncherTransitionStart(toView, animated, true); final Animator stateAnimation = mStateAnimation; mWorkspace.post(new Runnable() { public void run() { if (stateAnimation != mStateAnimation) return; mStateAnimation.start(); } }); } else { fromView.setVisibility(View.GONE); dispatchOnLauncherTransitionPrepare(fromView, animated, true); dispatchOnLauncherTransitionStart(fromView, animated, true); dispatchOnLauncherTransitionEnd(fromView, animated, true); dispatchOnLauncherTransitionPrepare(toView, animated, true); dispatchOnLauncherTransitionStart(toView, animated, true); dispatchOnLauncherTransitionEnd(toView, animated, true); mWorkspace.hideScrollingIndicator(false); } }
From source file:com.android.launcher2.Launcher.java
/** * Zoom the camera out from the workspace to reveal 'toView'. * Assumes that the view to show is anchored at either the very top or very bottom * of the screen./*from w ww .ja v a2s .c o m*/ */ private void showAppsCustomizeHelper(final boolean animated, final boolean springLoaded) { if (mStateAnimation != null) { mStateAnimation.cancel(); mStateAnimation = null; } final Resources res = getResources(); final int duration = res.getInteger(R.integer.config_appsCustomizeZoomInTime); final int fadeDuration = res.getInteger(R.integer.config_appsCustomizeFadeInTime); final float scale = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor); final View fromView = mWorkspace; final AppsCustomizeTabHost toView = mAppsCustomizeTabHost; final int startDelay = res.getInteger(R.integer.config_workspaceAppsCustomizeAnimationStagger); setPivotsForZoom(toView, scale); // Shrink workspaces away if going to AppsCustomize from workspace Animator workspaceAnim = mWorkspace.getChangeStateAnimation(Workspace.State.SMALL, animated); if (animated) { toView.setScaleX(scale); toView.setScaleY(scale); final LauncherViewPropertyAnimator scaleAnim = new LauncherViewPropertyAnimator(toView); scaleAnim.scaleX(1f).scaleY(1f).setDuration(duration) .setInterpolator(new Workspace.ZoomOutInterpolator()); toView.setVisibility(View.VISIBLE); toView.setAlpha(0f); final ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(toView, "alpha", 0f, 1f) .setDuration(fadeDuration); alphaAnim.setInterpolator(new DecelerateInterpolator(1.5f)); alphaAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (animation == null) { throw new RuntimeException("animation is null"); } float t = (Float) animation.getAnimatedValue(); dispatchOnLauncherTransitionStep(fromView, t); dispatchOnLauncherTransitionStep(toView, t); } }); // toView should appear right at the end of the workspace shrink // animation mStateAnimation = LauncherAnimUtils.createAnimatorSet(); mStateAnimation.play(scaleAnim).after(startDelay); mStateAnimation.play(alphaAnim).after(startDelay); mStateAnimation.addListener(new AnimatorListenerAdapter() { boolean animationCancelled = false; @Override public void onAnimationStart(Animator animation) { updateWallpaperVisibility(true); // Prepare the position toView.setTranslationX(0.0f); toView.setTranslationY(0.0f); toView.setVisibility(View.VISIBLE); toView.bringToFront(); } @Override public void onAnimationEnd(Animator animation) { dispatchOnLauncherTransitionEnd(fromView, animated, false); dispatchOnLauncherTransitionEnd(toView, animated, false); if (mWorkspace != null && !springLoaded && !LauncherApplication.isScreenLarge()) { // Hide the workspace scrollbar mWorkspace.hideScrollingIndicator(true); hideDockDivider(); } if (!animationCancelled) { updateWallpaperVisibility(false); } // Hide the search bar if (mSearchDropTargetBar != null) { mSearchDropTargetBar.hideSearchBar(false); } } @Override public void onAnimationCancel(Animator animation) { animationCancelled = true; } }); if (workspaceAnim != null) { mStateAnimation.play(workspaceAnim); } boolean delayAnim = false; final ViewTreeObserver observer; dispatchOnLauncherTransitionPrepare(fromView, animated, false); dispatchOnLauncherTransitionPrepare(toView, animated, false); // If any of the objects being animated haven't been measured/laid out // yet, delay the animation until we get a layout pass if ((((LauncherTransitionable) toView).getContent().getMeasuredWidth() == 0) || (mWorkspace.getMeasuredWidth() == 0) || (toView.getMeasuredWidth() == 0)) { observer = mWorkspace.getViewTreeObserver(); delayAnim = true; } else { observer = null; } final AnimatorSet stateAnimation = mStateAnimation; final Runnable startAnimRunnable = new Runnable() { public void run() { // Check that mStateAnimation hasn't changed while // we waited for a layout/draw pass if (mStateAnimation != stateAnimation) return; setPivotsForZoom(toView, scale); dispatchOnLauncherTransitionStart(fromView, animated, false); dispatchOnLauncherTransitionStart(toView, animated, false); toView.post(new Runnable() { public void run() { // Check that mStateAnimation hasn't changed while // we waited for a layout/draw pass if (mStateAnimation != stateAnimation) return; mStateAnimation.start(); } }); } }; if (delayAnim) { final OnGlobalLayoutListener delayedStart = new OnGlobalLayoutListener() { public void onGlobalLayout() { toView.post(startAnimRunnable); ViewTreeObserverCompat.removeOnGlobalLayoutListener(observer, this); } }; observer.addOnGlobalLayoutListener(delayedStart); } else { startAnimRunnable.run(); } } else { toView.setTranslationX(0.0f); toView.setTranslationY(0.0f); toView.setScaleX(1.0f); toView.setScaleY(1.0f); toView.setVisibility(View.VISIBLE); toView.bringToFront(); if (!springLoaded && !LauncherApplication.isScreenLarge()) { // Hide the workspace scrollbar mWorkspace.hideScrollingIndicator(true); hideDockDivider(); // Hide the search bar if (mSearchDropTargetBar != null) { mSearchDropTargetBar.hideSearchBar(false); } } dispatchOnLauncherTransitionPrepare(fromView, animated, false); dispatchOnLauncherTransitionStart(fromView, animated, false); dispatchOnLauncherTransitionEnd(fromView, animated, false); dispatchOnLauncherTransitionPrepare(toView, animated, false); dispatchOnLauncherTransitionStart(toView, animated, false); dispatchOnLauncherTransitionEnd(toView, animated, false); updateWallpaperVisibility(false); } }
From source file:com.gxapplications.android.gxsuite.launcher.Launcher.java
/** * Zoom the camera out from the workspace to reveal 'toView'. * Assumes that the view to show is anchored at either the very top or very bottom * of the screen./* w w w.j a va 2 s .com*/ */ private void showAppsCustomizeHelper(final boolean animated, final boolean springLoaded) { if (mStateAnimation != null) { mStateAnimation.cancel(); mStateAnimation = null; } final Resources res = getResources(); final int duration = res.getInteger(R.integer.config_appsCustomizeZoomInTime); final int fadeDuration = res.getInteger(R.integer.config_appsCustomizeFadeInTime); final float scale = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor); final View fromView = mWorkspace; final AppsCustomizeTabHost toView = mAppsCustomizeTabHost; final int startDelay = res.getInteger(R.integer.config_workspaceAppsCustomizeAnimationStagger); setPivotsForZoom(toView, scale); // Shrink workspaces away if going to AppsCustomize from workspace Animator workspaceAnim = mWorkspace.getChangeStateAnimation(Workspace.State.SMALL, animated); if (animated) { toView.setScaleX(scale); toView.setScaleY(scale); final LauncherViewPropertyAnimator scaleAnim = new LauncherViewPropertyAnimator(toView); scaleAnim.scaleX(1f).scaleY(1f).setDuration(duration) .setInterpolator(new Workspace.ZoomOutInterpolator()); toView.setVisibility(View.VISIBLE); toView.setAlpha(0f); final ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(toView, "alpha", 0f, 1f) .setDuration(fadeDuration); alphaAnim.setInterpolator(new DecelerateInterpolator(1.5f)); alphaAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (animation == null) { throw new RuntimeException("animation is null"); } float t = (Float) animation.getAnimatedValue(); dispatchOnLauncherTransitionStep(fromView, t); dispatchOnLauncherTransitionStep(toView, t); } }); // toView should appear right at the end of the workspace shrink // animation mStateAnimation = LauncherAnimUtils.createAnimatorSet(); mStateAnimation.play(scaleAnim).after(startDelay); mStateAnimation.play(alphaAnim).after(startDelay); mStateAnimation.addListener(new AnimatorListenerAdapter() { boolean animationCancelled = false; @Override public void onAnimationStart(Animator animation) { updateWallpaperVisibility(true); // Prepare the position toView.setTranslationX(0.0f); toView.setTranslationY(0.0f); toView.setVisibility(View.VISIBLE); toView.bringToFront(); } @Override public void onAnimationEnd(Animator animation) { dispatchOnLauncherTransitionEnd(fromView, animated, false); dispatchOnLauncherTransitionEnd(toView, animated, false); if (mWorkspace != null && !springLoaded && !LauncherApplication.isScreenLarge()) { // Hide the workspace scrollbar mWorkspace.hideScrollingIndicator(true); hideDockDivider(); } if (!animationCancelled) { updateWallpaperVisibility(false); } // Hide the search bar if (mSearchDropTargetBar != null) { mSearchDropTargetBar.hideSearchBar(false); } } @Override public void onAnimationCancel(Animator animation) { animationCancelled = true; } }); if (workspaceAnim != null) { mStateAnimation.play(workspaceAnim); } boolean delayAnim = false; final ViewTreeObserver observer; dispatchOnLauncherTransitionPrepare(fromView, animated, false); dispatchOnLauncherTransitionPrepare(toView, animated, false); // If any of the objects being animated haven't been measured/laid out // yet, delay the animation until we get a layout pass if ((((LauncherTransitionable) toView).getContent().getMeasuredWidth() == 0) || (mWorkspace.getMeasuredWidth() == 0) || (toView.getMeasuredWidth() == 0)) { observer = mWorkspace.getViewTreeObserver(); delayAnim = true; } else { observer = null; } final AnimatorSet stateAnimation = mStateAnimation; final Runnable startAnimRunnable = new Runnable() { public void run() { // Check that mStateAnimation hasn't changed while // we waited for a layout/draw pass if (mStateAnimation != stateAnimation) return; setPivotsForZoom(toView, scale); dispatchOnLauncherTransitionStart(fromView, animated, false); dispatchOnLauncherTransitionStart(toView, animated, false); toView.post(new Runnable() { public void run() { // Check that mStateAnimation hasn't changed while // we waited for a layout/draw pass if (mStateAnimation != stateAnimation) return; mStateAnimation.start(); } }); } }; if (delayAnim) { final OnGlobalLayoutListener delayedStart = new OnGlobalLayoutListener() { public void onGlobalLayout() { toView.post(startAnimRunnable); observer.removeOnGlobalLayoutListener(this); } }; observer.addOnGlobalLayoutListener(delayedStart); } else { startAnimRunnable.run(); } } else { toView.setTranslationX(0.0f); toView.setTranslationY(0.0f); toView.setScaleX(1.0f); toView.setScaleY(1.0f); toView.setVisibility(View.VISIBLE); toView.bringToFront(); if (!springLoaded && !LauncherApplication.isScreenLarge()) { // Hide the workspace scrollbar mWorkspace.hideScrollingIndicator(true); hideDockDivider(); // Hide the search bar if (mSearchDropTargetBar != null) { mSearchDropTargetBar.hideSearchBar(false); } } dispatchOnLauncherTransitionPrepare(fromView, animated, false); dispatchOnLauncherTransitionStart(fromView, animated, false); dispatchOnLauncherTransitionEnd(fromView, animated, false); dispatchOnLauncherTransitionPrepare(toView, animated, false); dispatchOnLauncherTransitionStart(toView, animated, false); dispatchOnLauncherTransitionEnd(toView, animated, false); updateWallpaperVisibility(false); } }
From source file:com.android.launcher3.Launcher.java
private void growAndFadeOutFolderIcon(FolderIcon fi) { if (fi == null) return;/*from w w w . j av a2 s.c om*/ FolderInfo info = (FolderInfo) fi.getTag(); if (info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { CellLayout cl = (CellLayout) fi.getParent().getParent(); CellLayout.LayoutParams lp = (CellLayout.LayoutParams) fi.getLayoutParams(); cl.setFolderLeaveBehindCell(lp.cellX, lp.cellY); } // Push an ImageView copy of the FolderIcon into the DragLayer and hide the original copyFolderIconToImage(fi); fi.setVisibility(View.INVISIBLE); ObjectAnimator oa = LauncherAnimUtils.ofViewAlphaAndScale(mFolderIconImageView, 0, 1.5f, 1.5f); if (Utilities.ATLEAST_LOLLIPOP) { oa.setInterpolator(new LogDecelerateInterpolator(100, 0)); } oa.setDuration(getResources().getInteger(R.integer.config_folderExpandDuration)); oa.start(); }
From source file:com.klinker.android.launcher.launcher3.Launcher.java
private void growAndFadeOutFolderIcon(FolderIcon fi) { if (fi == null) return;/*from ww w .j a va 2 s . c o m*/ PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.5f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.5f); FolderInfo info = (FolderInfo) fi.getTag(); if (info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { CellLayout cl = (CellLayout) fi.getParent().getParent(); CellLayout.LayoutParams lp = (CellLayout.LayoutParams) fi.getLayoutParams(); cl.setFolderLeaveBehindCell(lp.cellX, lp.cellY); } // Push an ImageView copy of the FolderIcon into the DragLayer and hide the original copyFolderIconToImage(fi); fi.setVisibility(View.INVISIBLE); ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(mFolderIconImageView, alpha, scaleX, scaleY); if (Utilities.isLmpOrAbove()) { oa.setInterpolator(new LogDecelerateInterpolator(100, 0)); } oa.setDuration(getResources().getInteger(R.integer.config_folderExpandDuration)); oa.start(); }