List of usage examples for android.animation ObjectAnimator ofFloat
public static <T> ObjectAnimator ofFloat(T target, Property<T, Float> property, float... values)
From source file:com.example.launcher3.Workspace.java
Animator getChangeStateAnimation(final State state, boolean animated, int delay, int snapPage) { if (mState == state) { return null; }// w ww . j av a 2 s . co 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 oldStateIsSpringLoaded = (oldState == State.SPRING_LOADED); final boolean oldStateIsSmall = (oldState == State.SMALL); final boolean oldStateIsOverview = (oldState == State.OVERVIEW); setState(state); final boolean stateIsNormal = (state == State.NORMAL); final boolean stateIsSpringLoaded = (state == State.SPRING_LOADED); final boolean stateIsSmall = (state == State.SMALL); final boolean stateIsOverview = (state == State.OVERVIEW); float finalBackgroundAlpha = (stateIsSpringLoaded || stateIsOverview) ? 1.0f : 0f; float finalHotseatAndPageIndicatorAlpha = (stateIsOverview || stateIsSmall) ? 0f : 1f; float finalOverviewPanelAlpha = stateIsOverview ? 1f : 0f; float finalSearchBarAlpha = !stateIsNormal ? 0f : 1f; float finalWorkspaceTranslationY = stateIsOverview ? getOverviewModeTranslationY() : 0; boolean workspaceToAllApps = (oldStateIsNormal && stateIsSmall); boolean allAppsToWorkspace = (oldStateIsSmall && stateIsNormal); boolean workspaceToOverview = (oldStateIsNormal && stateIsOverview); boolean overviewToWorkspace = (oldStateIsOverview && stateIsNormal); mNewScale = 1.0f; if (oldStateIsOverview) { disableFreeScroll(snapPage); } else if (stateIsOverview) { enableFreeScroll(); } if (state != State.NORMAL) { if (stateIsSpringLoaded) { mNewScale = mSpringLoadedShrinkFactor; } else if (stateIsOverview) { mNewScale = mOverviewModeShrinkFactor; } else if (stateIsSmall) { mNewScale = mOverviewModeShrinkFactor - 0.3f; } if (workspaceToAllApps) { updateChildrenLayersEnabled(false); } } final int duration; if (workspaceToAllApps) { duration = getResources().getInteger(R.integer.config_workspaceUnshrinkTime); } else if (workspaceToOverview || overviewToWorkspace) { duration = getResources().getInteger(R.integer.config_overviewTransitionTime); } else { duration = getResources().getInteger(R.integer.config_appsCustomizeWorkspaceShrinkTime); } for (int i = 0; i < getChildCount(); i++) { final CellLayout cl = (CellLayout) getChildAt(i); boolean isCurrentPage = (i == getNextPage()); float initialAlpha = cl.getShortcutsAndWidgets().getAlpha(); float finalAlpha = stateIsSmall ? 0f : 1f; // If we are animating to/from the small state, then hide the side // pages and fade the // current page in if (!mIsSwitchingState) { if (workspaceToAllApps || allAppsToWorkspace) { if (allAppsToWorkspace && isCurrentPage) { initialAlpha = 0f; } else if (!isCurrentPage) { initialAlpha = finalAlpha = 0f; } cl.setShortcutAndWidgetAlpha(initialAlpha); } } mOldAlphas[i] = initialAlpha; mNewAlphas[i] = finalAlpha; if (animated) { mOldBackgroundAlphas[i] = cl.getBackgroundAlpha(); mNewBackgroundAlphas[i] = finalBackgroundAlpha; } else { cl.setBackgroundAlpha(finalBackgroundAlpha); cl.setShortcutAndWidgetAlpha(finalAlpha); } } final View searchBar = mLauncher.getQsbBar(); final View overviewPanel = mLauncher.getOverviewPanel(); final View hotseat = mLauncher.getHotseat(); if (animated) { anim.setDuration(duration); LauncherViewPropertyAnimator scale = new LauncherViewPropertyAnimator(this); scale.scaleX(mNewScale).scaleY(mNewScale).translationY(finalWorkspaceTranslationY) .setInterpolator(mZoomInInterpolator); anim.play(scale); for (int index = 0; index < getChildCount(); index++) { final int i = index; final CellLayout cl = (CellLayout) getChildAt(i); float currentAlpha = cl.getShortcutsAndWidgets().getAlpha(); if (mOldAlphas[i] == 0 && mNewAlphas[i] == 0) { cl.setBackgroundAlpha(mNewBackgroundAlphas[i]); cl.setShortcutAndWidgetAlpha(mNewAlphas[i]); } else { if (mOldAlphas[i] != mNewAlphas[i] || currentAlpha != mNewAlphas[i]) { LauncherViewPropertyAnimator alphaAnim = new LauncherViewPropertyAnimator( cl.getShortcutsAndWidgets()); alphaAnim.alpha(mNewAlphas[i]).setInterpolator(mZoomInInterpolator); anim.play(alphaAnim); } 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); } } } ObjectAnimator pageIndicatorAlpha = null; if (getPageIndicator() != null) { pageIndicatorAlpha = ObjectAnimator.ofFloat(getPageIndicator(), "alpha", finalHotseatAndPageIndicatorAlpha); } ObjectAnimator hotseatAlpha = ObjectAnimator.ofFloat(hotseat, "alpha", finalHotseatAndPageIndicatorAlpha); ObjectAnimator searchBarAlpha = ObjectAnimator.ofFloat(searchBar, "alpha", finalSearchBarAlpha); ObjectAnimator overviewPanelAlpha = ObjectAnimator.ofFloat(overviewPanel, "alpha", finalOverviewPanelAlpha); overviewPanelAlpha.addListener(new AlphaUpdateListener(overviewPanel)); hotseatAlpha.addListener(new AlphaUpdateListener(hotseat)); searchBarAlpha.addListener(new AlphaUpdateListener(searchBar)); if (workspaceToOverview) { hotseatAlpha.setInterpolator(new DecelerateInterpolator(2)); } else if (overviewToWorkspace) { overviewPanelAlpha.setInterpolator(new DecelerateInterpolator(2)); } if (getPageIndicator() != null) { pageIndicatorAlpha.addListener(new AlphaUpdateListener(getPageIndicator())); } anim.play(overviewPanelAlpha); anim.play(hotseatAlpha); anim.play(searchBarAlpha); anim.play(pageIndicatorAlpha); anim.setStartDelay(delay); } else { overviewPanel.setAlpha(finalOverviewPanelAlpha); AlphaUpdateListener.updateVisibility(overviewPanel); hotseat.setAlpha(finalHotseatAndPageIndicatorAlpha); AlphaUpdateListener.updateVisibility(hotseat); if (getPageIndicator() != null) { getPageIndicator().setAlpha(finalHotseatAndPageIndicatorAlpha); AlphaUpdateListener.updateVisibility(getPageIndicator()); } searchBar.setAlpha(finalSearchBarAlpha); AlphaUpdateListener.updateVisibility(searchBar); updateCustomContentVisibility(); setScaleX(mNewScale); setScaleY(mNewScale); setTranslationY(finalWorkspaceTranslationY); } mLauncher.updateVoiceButtonProxyVisible(false); if (stateIsSpringLoaded) { // Right now we're covered by Apps Customize // Show the background gradient immediately, so the gradient will // be showing once AppsCustomize disappears animateBackgroundGradient( getResources().getInteger(R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f, false); } else if (stateIsOverview) { animateBackgroundGradient( getResources().getInteger(R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f, true); } else { // Fade the background gradient away animateBackgroundGradient(0f, animated); } return anim; }
From source file:com.aidy.launcher3.ui.workspace.Workspace.java
public Animator getChangeStateAnimation(final State state, boolean animated, int delay, int snapPage) { if (mState == state) { return null; }/*from ww w .j a v 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 oldStateIsSpringLoaded = (oldState == State.SPRING_LOADED); final boolean oldStateIsSmall = (oldState == State.SMALL); final boolean oldStateIsOverview = (oldState == State.OVERVIEW); setState(state); final boolean stateIsNormal = (state == State.NORMAL); final boolean stateIsSpringLoaded = (state == State.SPRING_LOADED); final boolean stateIsSmall = (state == State.SMALL); final boolean stateIsOverview = (state == State.OVERVIEW); float finalBackgroundAlpha = (stateIsSpringLoaded || stateIsOverview) ? 1.0f : 0f; float finalHotseatAndPageIndicatorAlpha = (stateIsOverview || stateIsSmall) ? 0f : 1f; float finalOverviewPanelAlpha = stateIsOverview ? 1f : 0f; float finalSearchBarAlpha = !stateIsNormal ? 0f : 1f; float finalWorkspaceTranslationY = stateIsOverview ? getOverviewModeTranslationY() : 0; boolean workspaceToAllApps = (oldStateIsNormal && stateIsSmall); boolean allAppsToWorkspace = (oldStateIsSmall && stateIsNormal); boolean workspaceToOverview = (oldStateIsNormal && stateIsOverview); boolean overviewToWorkspace = (oldStateIsOverview && stateIsNormal); mNewScale = 1.0f; if (oldStateIsOverview) { disableFreeScroll(snapPage); } else if (stateIsOverview) { enableFreeScroll(); } if (state != State.NORMAL) { if (stateIsSpringLoaded) { mNewScale = mSpringLoadedShrinkFactor; } else if (stateIsOverview) { mNewScale = mOverviewModeShrinkFactor; } else if (stateIsSmall) { mNewScale = mOverviewModeShrinkFactor - 0.3f; } if (workspaceToAllApps) { updateChildrenLayersEnabled(false); } } final int duration; if (workspaceToAllApps) { duration = getResources().getInteger(R.integer.config_workspaceUnshrinkTime); } else if (workspaceToOverview || overviewToWorkspace) { duration = getResources().getInteger(R.integer.config_overviewTransitionTime); } else { duration = getResources().getInteger(R.integer.config_appsCustomizeWorkspaceShrinkTime); } for (int i = 0; i < getChildCount(); i++) { final CellLayout cl = (CellLayout) getChildAt(i); boolean isCurrentPage = (i == getNextPage()); float initialAlpha = cl.getShortcutsAndWidgets().getAlpha(); float finalAlpha = stateIsSmall ? 0f : 1f; // If we are animating to/from the small state, then hide the side // pages and fade the // current page in if (!mIsSwitchingState) { if (workspaceToAllApps || allAppsToWorkspace) { if (allAppsToWorkspace && isCurrentPage) { initialAlpha = 0f; } else if (!isCurrentPage) { initialAlpha = finalAlpha = 0f; } cl.setShortcutAndWidgetAlpha(initialAlpha); } } mOldAlphas[i] = initialAlpha; mNewAlphas[i] = finalAlpha; if (animated) { mOldBackgroundAlphas[i] = cl.getBackgroundAlpha(); mNewBackgroundAlphas[i] = finalBackgroundAlpha; } else { cl.setBackgroundAlpha(finalBackgroundAlpha); cl.setShortcutAndWidgetAlpha(finalAlpha); } } final View searchBar = mLauncher.getQsbBar(); final View overviewPanel = mLauncher.getOverviewPanel(); final View hotseat = mLauncher.getHotseat(); if (animated) { anim.setDuration(duration); LauncherViewPropertyAnimator scale = new LauncherViewPropertyAnimator(this); scale.scaleX(mNewScale).scaleY(mNewScale).translationY(finalWorkspaceTranslationY) .setInterpolator(mZoomInInterpolator); anim.play(scale); for (int index = 0; index < getChildCount(); index++) { final int i = index; final CellLayout cl = (CellLayout) getChildAt(i); float currentAlpha = cl.getShortcutsAndWidgets().getAlpha(); if (mOldAlphas[i] == 0 && mNewAlphas[i] == 0) { cl.setBackgroundAlpha(mNewBackgroundAlphas[i]); cl.setShortcutAndWidgetAlpha(mNewAlphas[i]); } else { if (mOldAlphas[i] != mNewAlphas[i] || currentAlpha != mNewAlphas[i]) { LauncherViewPropertyAnimator alphaAnim = new LauncherViewPropertyAnimator( cl.getShortcutsAndWidgets()); alphaAnim.alpha(mNewAlphas[i]).setInterpolator(mZoomInInterpolator); anim.play(alphaAnim); } 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); } } } ObjectAnimator pageIndicatorAlpha = null; if (getPageIndicator() != null) { pageIndicatorAlpha = ObjectAnimator.ofFloat(getPageIndicator(), "alpha", finalHotseatAndPageIndicatorAlpha); } ObjectAnimator hotseatAlpha = ObjectAnimator.ofFloat(hotseat, "alpha", finalHotseatAndPageIndicatorAlpha); ObjectAnimator searchBarAlpha = ObjectAnimator.ofFloat(searchBar, "alpha", finalSearchBarAlpha); ObjectAnimator overviewPanelAlpha = ObjectAnimator.ofFloat(overviewPanel, "alpha", finalOverviewPanelAlpha); overviewPanelAlpha.addListener(new AlphaUpdateListener(overviewPanel)); hotseatAlpha.addListener(new AlphaUpdateListener(hotseat)); searchBarAlpha.addListener(new AlphaUpdateListener(searchBar)); if (workspaceToOverview) { hotseatAlpha.setInterpolator(new DecelerateInterpolator(2)); } else if (overviewToWorkspace) { overviewPanelAlpha.setInterpolator(new DecelerateInterpolator(2)); } if (getPageIndicator() != null) { pageIndicatorAlpha.addListener(new AlphaUpdateListener(getPageIndicator())); } anim.play(overviewPanelAlpha); anim.play(hotseatAlpha); anim.play(searchBarAlpha); anim.play(pageIndicatorAlpha); anim.setStartDelay(delay); } else { overviewPanel.setAlpha(finalOverviewPanelAlpha); AlphaUpdateListener.updateVisibility(overviewPanel); hotseat.setAlpha(finalHotseatAndPageIndicatorAlpha); AlphaUpdateListener.updateVisibility(hotseat); if (getPageIndicator() != null) { getPageIndicator().setAlpha(finalHotseatAndPageIndicatorAlpha); AlphaUpdateListener.updateVisibility(getPageIndicator()); } searchBar.setAlpha(finalSearchBarAlpha); AlphaUpdateListener.updateVisibility(searchBar); updateCustomContentVisibility(); setScaleX(mNewScale); setScaleY(mNewScale); setTranslationY(finalWorkspaceTranslationY); } mLauncher.updateVoiceButtonProxyVisible(false); if (stateIsSpringLoaded) { // Right now we're covered by Apps Customize // Show the background gradient immediately, so the gradient will // be showing once AppsCustomize disappears animateBackgroundGradient( getResources().getInteger(R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f, false); } else if (stateIsOverview) { animateBackgroundGradient( getResources().getInteger(R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f, true); } else { // Fade the background gradient away animateBackgroundGradient(0f, animated); } return anim; }
From source file:com.wb.launcher3.Workspace.java
Animator getChangeStateAnimation(final State state, boolean animated, int delay, int snapPage) { if (mState == state) { return null; }// w w w . ja v a 2 s . c om // 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 oldStateIsSpringLoaded = (oldState == State.SPRING_LOADED); final boolean oldStateIsSmall = (oldState == State.SMALL); final boolean oldStateIsOverview = (oldState == State.OVERVIEW); setState(state); final boolean stateIsNormal = (state == State.NORMAL); final boolean stateIsSpringLoaded = (state == State.SPRING_LOADED); final boolean stateIsSmall = (state == State.SMALL); final boolean stateIsOverview = (state == State.OVERVIEW); float finalBackgroundAlpha = (stateIsSpringLoaded || stateIsOverview) ? 1.0f : 0f; float finalHotseatAndPageIndicatorAlpha = (stateIsOverview || stateIsSmall) ? 0f : 1f; float finalOverviewPanelAlpha = stateIsOverview ? 1f : 0f; float finalSearchBarAlpha = !stateIsNormal ? 0f : 1f; float finalWorkspaceTranslationY = stateIsOverview ? getOverviewModeTranslationY() : 0; boolean workspaceToAllApps = (oldStateIsNormal && stateIsSmall); boolean allAppsToWorkspace = (oldStateIsSmall && stateIsNormal); boolean workspaceToOverview = (oldStateIsNormal && stateIsOverview); boolean overviewToWorkspace = (oldStateIsOverview && stateIsNormal); mNewScale = 1.0f; if (oldStateIsOverview) { disableFreeScroll(snapPage); } else if (stateIsOverview) { enableFreeScroll(); } if (state != State.NORMAL) { if (stateIsSpringLoaded) { mNewScale = mSpringLoadedShrinkFactor; } else if (stateIsOverview) { mNewScale = mOverviewModeShrinkFactor; } else if (stateIsSmall) { mNewScale = mOverviewModeShrinkFactor - 0.3f; } if (workspaceToAllApps) { updateChildrenLayersEnabled(false); } } final int duration; if (workspaceToAllApps) { duration = getResources().getInteger(R.integer.config_workspaceUnshrinkTime); } else if (workspaceToOverview || overviewToWorkspace) { duration = getResources().getInteger(R.integer.config_overviewTransitionTime); } else { duration = getResources().getInteger(R.integer.config_appsCustomizeWorkspaceShrinkTime); } for (int i = 0; i < getChildCount(); i++) { final CellLayout cl = (CellLayout) getChildAt(i); boolean isCurrentPage = (i == getNextPage()); float initialAlpha = cl.getShortcutsAndWidgets().getAlpha(); float finalAlpha = stateIsSmall ? 0f : 1f; // If we are animating to/from the small state, then hide the side pages and fade the // current page in if (!mIsSwitchingState) { if (workspaceToAllApps || allAppsToWorkspace) { if (allAppsToWorkspace && isCurrentPage) { initialAlpha = 0f; } else if (!isCurrentPage) { initialAlpha = finalAlpha = 0f; } cl.setShortcutAndWidgetAlpha(initialAlpha); } } mOldAlphas[i] = initialAlpha; mNewAlphas[i] = finalAlpha; if (animated) { mOldBackgroundAlphas[i] = cl.getBackgroundAlpha(); mNewBackgroundAlphas[i] = finalBackgroundAlpha; } else { cl.setBackgroundAlpha(finalBackgroundAlpha); cl.setShortcutAndWidgetAlpha(finalAlpha); } } final View searchBar = mLauncher.getQsbBar(); final View overviewPanel = mLauncher.getOverviewPanel(); final View hotseat = mLauncher.getHotseat(); if (animated) { anim.setDuration(duration); LauncherViewPropertyAnimator scale = new LauncherViewPropertyAnimator(this); scale.scaleX(mNewScale).scaleY(mNewScale).translationY(finalWorkspaceTranslationY) .setInterpolator(mZoomInInterpolator); anim.play(scale); for (int index = 0; index < getChildCount(); index++) { final int i = index; final CellLayout cl = (CellLayout) getChildAt(i); float currentAlpha = cl.getShortcutsAndWidgets().getAlpha(); if (mOldAlphas[i] == 0 && mNewAlphas[i] == 0) { cl.setBackgroundAlpha(mNewBackgroundAlphas[i]); cl.setShortcutAndWidgetAlpha(mNewAlphas[i]); } else { if (mOldAlphas[i] != mNewAlphas[i] || currentAlpha != mNewAlphas[i]) { LauncherViewPropertyAnimator alphaAnim = new LauncherViewPropertyAnimator( cl.getShortcutsAndWidgets()); alphaAnim.alpha(mNewAlphas[i]).setInterpolator(mZoomInInterpolator); anim.play(alphaAnim); } 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); } } } ObjectAnimator pageIndicatorAlpha = null; if (getPageIndicator() != null) { pageIndicatorAlpha = ObjectAnimator.ofFloat(getPageIndicator(), "alpha", finalHotseatAndPageIndicatorAlpha); } ObjectAnimator hotseatAlpha = ObjectAnimator.ofFloat(hotseat, "alpha", finalHotseatAndPageIndicatorAlpha); ObjectAnimator searchBarAlpha = ObjectAnimator.ofFloat(searchBar, "alpha", finalSearchBarAlpha); ObjectAnimator overviewPanelAlpha = ObjectAnimator.ofFloat(overviewPanel, "alpha", finalOverviewPanelAlpha); overviewPanelAlpha.addListener(new AlphaUpdateListener(overviewPanel)); hotseatAlpha.addListener(new AlphaUpdateListener(hotseat)); searchBarAlpha.addListener(new AlphaUpdateListener(searchBar)); if (workspaceToOverview) { hotseatAlpha.setInterpolator(new DecelerateInterpolator(2)); } else if (overviewToWorkspace) { overviewPanelAlpha.setInterpolator(new DecelerateInterpolator(2)); } if (getPageIndicator() != null) { pageIndicatorAlpha.addListener(new AlphaUpdateListener(getPageIndicator())); } anim.play(overviewPanelAlpha); anim.play(hotseatAlpha); ///added by zxa for uninstall app if (!TydtechConfig.TYDTECH_UNINSTALL_MIUI_FLAG) { anim.play(searchBarAlpha); } /// anim.play(pageIndicatorAlpha); anim.setStartDelay(delay); } else { overviewPanel.setAlpha(finalOverviewPanelAlpha); AlphaUpdateListener.updateVisibility(overviewPanel); hotseat.setAlpha(finalHotseatAndPageIndicatorAlpha); AlphaUpdateListener.updateVisibility(hotseat); if (getPageIndicator() != null) { getPageIndicator().setAlpha(finalHotseatAndPageIndicatorAlpha); AlphaUpdateListener.updateVisibility(getPageIndicator()); } //*/added by zxa for uninstall app if (!TydtechConfig.TYDTECH_UNINSTALL_MIUI_FLAG) { searchBar.setAlpha(finalSearchBarAlpha); AlphaUpdateListener.updateVisibility(searchBar); } //*/ updateCustomContentVisibility(); setScaleX(mNewScale); setScaleY(mNewScale); setTranslationY(finalWorkspaceTranslationY); } mLauncher.updateVoiceButtonProxyVisible(false); if (stateIsSpringLoaded) { // Right now we're covered by Apps Customize // Show the background gradient immediately, so the gradient will // be showing once AppsCustomize disappears animateBackgroundGradient( getResources().getInteger(R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f, false); } else if (stateIsOverview) { animateBackgroundGradient( getResources().getInteger(R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f, true); } else { // Fade the background gradient away animateBackgroundGradient(0f, animated); } return anim; }
From source file:cc.flydev.launcher.Page.java
void animateDragViewToOriginalPosition() { if (mDragView != null) { AnimatorSet anim = new AnimatorSet(); anim.setDuration(REORDERING_DROP_REPOSITION_DURATION); anim.playTogether(ObjectAnimator.ofFloat(mDragView, "translationX", 0f), ObjectAnimator.ofFloat(mDragView, "translationY", 0f), ObjectAnimator.ofFloat(mDragView, "scaleX", 1f), ObjectAnimator.ofFloat(mDragView, "scaleY", 1f)); anim.addListener(new AnimatorListenerAdapter() { @Override/*from ww w. ja v a2 s. c om*/ public void onAnimationEnd(Animator animation) { onPostReorderingAnimationCompleted(); } }); anim.start(); } }
From source file:cc.flydev.launcher.Page.java
private Runnable createPostDeleteAnimationRunnable(final View dragView) { return new Runnable() { @Override/* w w w .ja v a 2 s . c o m*/ public void run() { int dragViewIndex = indexOfChild(dragView); // For each of the pages around the drag view, animate them from the previous // position to the new position in the layout (as a result of the drag view moving // in the layout) // NOTE: We can make an assumption here because we have side-bound pages that we // will always have pages to animate in from the left getOverviewModePages(mTempVisiblePagesRange); boolean isLastWidgetPage = (mTempVisiblePagesRange[0] == mTempVisiblePagesRange[1]); boolean slideFromLeft = (isLastWidgetPage || dragViewIndex > mTempVisiblePagesRange[0]); // Setup the scroll to the correct page before we swap the views if (slideFromLeft) { snapToPageImmediately(dragViewIndex - 1); } int firstIndex = (isLastWidgetPage ? 0 : mTempVisiblePagesRange[0]); int lastIndex = Math.min(mTempVisiblePagesRange[1], getPageCount() - 1); int lowerIndex = (slideFromLeft ? firstIndex : dragViewIndex + 1); int upperIndex = (slideFromLeft ? dragViewIndex - 1 : lastIndex); ArrayList<Animator> animations = new ArrayList<Animator>(); for (int i = lowerIndex; i <= upperIndex; ++i) { View v = getChildAt(i); // dragViewIndex < pageUnderPointIndex, so after we remove the // drag view all subsequent views to pageUnderPointIndex will // shift down. int oldX = 0; int newX = 0; if (slideFromLeft) { if (i == 0) { // Simulate the page being offscreen with the page spacing oldX = getViewportOffsetX() + getChildOffset(i) - getChildWidth(i) - mPageSpacing; } else { oldX = getViewportOffsetX() + getChildOffset(i - 1); } newX = getViewportOffsetX() + getChildOffset(i); } else { oldX = getChildOffset(i) - getChildOffset(i - 1); newX = 0; } // Animate the view translation from its old position to its new // position AnimatorSet anim = (AnimatorSet) v.getTag(); if (anim != null) { anim.cancel(); } // Note: Hacky, but we want to skip any optimizations to not draw completely // hidden views v.setAlpha(Math.max(v.getAlpha(), 0.01f)); v.setTranslationX(oldX - newX); anim = new AnimatorSet(); anim.playTogether(ObjectAnimator.ofFloat(v, "translationX", 0f), ObjectAnimator.ofFloat(v, "alpha", 1f)); animations.add(anim); v.setTag(ANIM_TAG_KEY, anim); } AnimatorSet slideAnimations = new AnimatorSet(); slideAnimations.playTogether(animations); slideAnimations.setDuration(DELETE_SLIDE_IN_SIDE_PAGE_DURATION); slideAnimations.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mDeferringForDelete = false; onEndReordering(); onRemoveViewAnimationCompleted(); } }); slideAnimations.start(); removeView(dragView); onRemoveView(dragView, true); } }; }
From source file:com.n2hsu.launcher.Page.java
private Runnable createPostDeleteAnimationRunnable(final View dragView) { return new Runnable() { @Override/*from w w w . j a v a 2 s . c o m*/ public void run() { int dragViewIndex = indexOfChild(dragView); // For each of the pages around the drag view, animate them from // the previous // position to the new position in the layout (as a result of // the drag view moving // in the layout) // NOTE: We can make an assumption here because we have // side-bound pages that we // will always have pages to animate in from the left getOverviewModePages(mTempVisiblePagesRange); boolean isLastWidgetPage = (mTempVisiblePagesRange[0] == mTempVisiblePagesRange[1]); boolean slideFromLeft = (isLastWidgetPage || dragViewIndex > mTempVisiblePagesRange[0]); // Setup the scroll to the correct page before we swap the views if (slideFromLeft) { snapToPageImmediately(dragViewIndex - 1); } int firstIndex = (isLastWidgetPage ? 0 : mTempVisiblePagesRange[0]); int lastIndex = Math.min(mTempVisiblePagesRange[1], getPageCount() - 1); int lowerIndex = (slideFromLeft ? firstIndex : dragViewIndex + 1); int upperIndex = (slideFromLeft ? dragViewIndex - 1 : lastIndex); ArrayList<Animator> animations = new ArrayList<Animator>(); for (int i = lowerIndex; i <= upperIndex; ++i) { View v = getChildAt(i); // dragViewIndex < pageUnderPointIndex, so after we remove // the // drag view all subsequent views to pageUnderPointIndex // will // shift down. int oldX = 0; int newX = 0; if (slideFromLeft) { if (i == 0) { // Simulate the page being offscreen with the page // spacing oldX = getViewportOffsetX() + getChildOffset(i) - getChildWidth(i) - mPageSpacing; } else { oldX = getViewportOffsetX() + getChildOffset(i - 1); } newX = getViewportOffsetX() + getChildOffset(i); } else { oldX = getChildOffset(i) - getChildOffset(i - 1); newX = 0; } // Animate the view translation from its old position to its // new // position AnimatorSet anim = (AnimatorSet) v.getTag(); if (anim != null) { anim.cancel(); } // Note: Hacky, but we want to skip any optimizations to not // draw completely // hidden views v.setAlpha(Math.max(v.getAlpha(), 0.01f)); v.setTranslationX(oldX - newX); anim = new AnimatorSet(); anim.playTogether(ObjectAnimator.ofFloat(v, "translationX", 0f), ObjectAnimator.ofFloat(v, "alpha", 1f)); animations.add(anim); v.setTag(ANIM_TAG_KEY, anim); } AnimatorSet slideAnimations = new AnimatorSet(); slideAnimations.playTogether(animations); slideAnimations.setDuration(DELETE_SLIDE_IN_SIDE_PAGE_DURATION); slideAnimations.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mDeferringForDelete = false; onEndReordering(); onRemoveViewAnimationCompleted(); } }); slideAnimations.start(); removeView(dragView); onRemoveView(dragView, true); } }; }
From source file:cc.flydev.launcher.Page.java
private void onDropToDelete() { final View dragView = mDragView; final float toScale = 0f; final float toAlpha = 0f; // Create and start the complex animation ArrayList<Animator> animations = new ArrayList<Animator>(); AnimatorSet motionAnim = new AnimatorSet(); motionAnim.setInterpolator(new DecelerateInterpolator(2)); motionAnim.playTogether(ObjectAnimator.ofFloat(dragView, "scaleX", toScale), ObjectAnimator.ofFloat(dragView, "scaleY", toScale)); animations.add(motionAnim);// w w w . j a v a 2s . c o m AnimatorSet alphaAnim = new AnimatorSet(); alphaAnim.setInterpolator(new LinearInterpolator()); alphaAnim.playTogether(ObjectAnimator.ofFloat(dragView, "alpha", toAlpha)); animations.add(alphaAnim); final Runnable onAnimationEndRunnable = createPostDeleteAnimationRunnable(dragView); AnimatorSet anim = new AnimatorSet(); anim.playTogether(animations); anim.setDuration(DRAG_TO_DELETE_FADE_OUT_DURATION); anim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animation) { onAnimationEndRunnable.run(); } }); anim.start(); mDeferringForDelete = true; }
From source file:com.aliyun.homeshell.Folder.java
private void autoMoveIconByScroll(int srcPageIndex, int desPageIndex) { mScrolling = true;/* w w w .ja v a 2s. co m*/ cancelMoveAnimation(); final CellLayout srcPage = mContentList.get(srcPageIndex); final CellLayout desPage = mContentList.get(desPageIndex); View movedView = null; // scroll left if (srcPageIndex > desPageIndex) { for (int j = desPage.getCountY() - 1; j >= 0; j--) { for (int i = desPage.getCountX() - 1; i >= 0; i--) { if ((movedView = desPage.getChildAt(i, j)) != null) { moveAnim = ObjectAnimator.ofFloat(movedView, TRANSLATION_X, LauncherApplication.getScreenWidth() - movedView.getX() + 100); break; } } if (movedView != null) { break; } } } else { // scroll right for (int j = 0; j < desPage.getCountY(); j++) { for (int i = 0; i < desPage.getCountX(); i++) { if ((movedView = desPage.getChildAt(i, j)) != null) { moveAnim = ObjectAnimator.ofFloat(movedView, TRANSLATION_X, -300); break; } } if (movedView != null) { break; } } } if (movedView == null) return; final ItemInfo movedInfo = (ItemInfo) movedView.getTag(); final View view = movedView; mReorderAlarm.cancelAlarm(); moveAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setTranslationX(0); desPage.removeView(view); ViewParent parent = (view.getParent()); if (parent != null) { String title = ""; if (movedInfo != null) { title = movedInfo.title.toString(); } Log.e(HOR_LOG_TAG, "The icon:" + title + ",has the parent when end on autoScroll,remove"); return; } CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams(); int movedFromX = movedInfo.cellX; int movedFromY = movedInfo.cellY; lp.cellX = movedInfo.cellX = mEmptyCell[0]; lp.cellY = movedInfo.cellY = mEmptyCell[1]; mEmptyCell[0] = movedFromX; mEmptyCell[1] = movedFromY; boolean insert = false; srcPage.addViewToCellLayout(view, insert ? 0 : -1, (int) movedInfo.id, lp, true); // force to reorder // mReorderAlarm.cancelAlarm(); // mReorderAlarm.setOnAlarmListener(mReorderAlarmListener); // mReorderAlarm.setAlarm(150); } }); moveAnim.setDuration(300); moveAnim.start(); }