Java Code Examples for org.chromium.chrome.browser.compositor.layouts.phone.stack.StackAnimation.OverviewAnimationType#DISCARD
The following examples show how to use
org.chromium.chrome.browser.compositor.layouts.phone.stack.StackAnimation.OverviewAnimationType#DISCARD .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Stack.java From delion with Apache License 2.0 | 5 votes |
/** * Decide if the animation can be started without cleaning up the current animation. * @param time The current time of the app in ms. * @param type The type of the animation to start. * @param sourceIndex The source index needed by some animation types. * @param finishImmediately Whether the animation jumps straight to the end. * @return true, if we can start the animation without cleaning up the current * animation. */ private boolean canUpdateAnimation( long time, OverviewAnimationType type, int sourceIndex, boolean finishImmediately) { if (mAnimationFactory != null) { if ((mOverviewAnimationType == OverviewAnimationType.DISCARD || mOverviewAnimationType == OverviewAnimationType.UNDISCARD || mOverviewAnimationType == OverviewAnimationType.DISCARD_ALL) && (type == OverviewAnimationType.DISCARD || type == OverviewAnimationType.UNDISCARD || type == OverviewAnimationType.DISCARD_ALL)) { return true; } } return false; }
Example 2
Source File: Stack.java From delion with Apache License 2.0 | 5 votes |
/** * Cancel scrolling animation which is a part of discarding animation. * @return true if the animation is canceled, false, if there is nothing to cancel. */ private boolean cancelDiscardScrollingAnimation() { if (mOverviewAnimationType == OverviewAnimationType.DISCARD || mOverviewAnimationType == OverviewAnimationType.UNDISCARD || mOverviewAnimationType == OverviewAnimationType.DISCARD_ALL) { mTabAnimations.cancel(null, StackTab.Property.SCROLL_OFFSET); return true; } return false; }
Example 3
Source File: Stack.java From delion with Apache License 2.0 | 5 votes |
/** * Called on touch click event. * * @param time The current time of the app in ms. * @param x The x coordinate in pixel inside the stack view. * @param y The y coordinate in pixel inside the stack view. */ public void click(long time, float x, float y) { if (mOverviewAnimationType != OverviewAnimationType.NONE && mOverviewAnimationType != OverviewAnimationType.DISCARD && mOverviewAnimationType != OverviewAnimationType.UNDISCARD && mOverviewAnimationType != OverviewAnimationType.DISCARD_ALL) { return; } int clicked = getTabIndexAtPositon(x, y, LayoutTab.getTouchSlop()); if (clicked >= 0) { // Check if the click was within the boundaries of the close button defined by its // visible coordinates. boolean isRtl = !((mCurrentMode == Orientation.PORTRAIT) ^ LocalizationUtils.isLayoutRtl()); if (mStackTabs[clicked].getLayoutTab().checkCloseHitTest(x, y, isRtl)) { // Tell the model to close the tab because the close button was pressed. The model // will then trigger a notification which will start the actual close process here // if necessary. StackTab tab = mStackTabs[clicked]; final float halfCloseBtnWidth = LayoutTab.CLOSE_BUTTON_WIDTH_DP / 2.f; final float halfCloseBtnHeight = mBorderTopPadding / 2.f; final float contentWidth = tab.getLayoutTab().getOriginalContentWidth(); tab.setDiscardOriginY(halfCloseBtnHeight); tab.setDiscardOriginX(isRtl ? halfCloseBtnWidth : contentWidth - halfCloseBtnWidth); tab.setDiscardFromClick(true); mLayout.uiRequestingCloseTab(time, tab.getId()); RecordUserAction.record("MobileStackViewCloseTab"); RecordUserAction.record("MobileTabClosed"); } else { // Let the model know that a new {@link LayoutTab} was selected. The model will // notify us if we need to do anything visual. setIndex() will possibly switch the // models and broadcast the event. mLayout.uiSelectingTab(time, mStackTabs[clicked].getId()); } } }
Example 4
Source File: Stack.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Decide if the animation can be started without cleaning up the current animation. * @param time The current time of the app in ms. * @param type The type of the animation to start. * @param sourceIndex The source index needed by some animation types. * @param finishImmediately Whether the animation jumps straight to the end. * @return true, if we can start the animation without cleaning up the current * animation. */ private boolean canUpdateAnimation( long time, OverviewAnimationType type, int sourceIndex, boolean finishImmediately) { if (mAnimationFactory != null) { if ((mOverviewAnimationType == OverviewAnimationType.DISCARD || mOverviewAnimationType == OverviewAnimationType.UNDISCARD || mOverviewAnimationType == OverviewAnimationType.DISCARD_ALL) && (type == OverviewAnimationType.DISCARD || type == OverviewAnimationType.UNDISCARD || type == OverviewAnimationType.DISCARD_ALL)) { return true; } } return false; }
Example 5
Source File: Stack.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Cancel scrolling animation which is a part of discarding animation. * @return true if the animation is canceled, false, if there is nothing to cancel. */ private boolean cancelDiscardScrollingAnimation() { if (mOverviewAnimationType == OverviewAnimationType.DISCARD || mOverviewAnimationType == OverviewAnimationType.UNDISCARD || mOverviewAnimationType == OverviewAnimationType.DISCARD_ALL) { mTabAnimations.cancel(null, StackTab.Property.SCROLL_OFFSET); return true; } return false; }
Example 6
Source File: Stack.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Called on touch click event. * * @param time The current time of the app in ms. * @param x The x coordinate in pixel inside the stack view. * @param y The y coordinate in pixel inside the stack view. */ public void click(long time, float x, float y) { if (mOverviewAnimationType != OverviewAnimationType.NONE && mOverviewAnimationType != OverviewAnimationType.DISCARD && mOverviewAnimationType != OverviewAnimationType.UNDISCARD && mOverviewAnimationType != OverviewAnimationType.DISCARD_ALL) { return; } int clicked = getTabIndexAtPositon(x, y, LayoutTab.getTouchSlop()); if (clicked >= 0) { // Check if the click was within the boundaries of the close button defined by its // visible coordinates. boolean isRtl = !((mCurrentMode == Orientation.PORTRAIT) ^ LocalizationUtils.isLayoutRtl()); if (mStackTabs[clicked].getLayoutTab().checkCloseHitTest(x, y, isRtl)) { // Tell the model to close the tab because the close button was pressed. The model // will then trigger a notification which will start the actual close process here // if necessary. StackTab tab = mStackTabs[clicked]; final float halfCloseBtnWidth = LayoutTab.CLOSE_BUTTON_WIDTH_DP / 2.f; final float halfCloseBtnHeight = mBorderTopPadding / 2.f; final float contentWidth = tab.getLayoutTab().getOriginalContentWidth(); tab.setDiscardOriginY(halfCloseBtnHeight); tab.setDiscardOriginX(isRtl ? halfCloseBtnWidth : contentWidth - halfCloseBtnWidth); tab.setDiscardFromClick(true); mLayout.uiRequestingCloseTab(time, tab.getId()); RecordUserAction.record("MobileStackViewCloseTab"); RecordUserAction.record("MobileTabClosed"); } else { // Let the model know that a new {@link LayoutTab} was selected. The model will // notify us if we need to do anything visual. setIndex() will possibly switch the // models and broadcast the event. mLayout.uiSelectingTab(time, mStackTabs[clicked].getId()); } } }
Example 7
Source File: Stack.java From 365browser with Apache License 2.0 | 5 votes |
/** * Decide if the animation can be started without cleaning up the current animation. * @param time The current time of the app in ms. * @param type The type of the animation to start. * @param sourceIndex The source index needed by some animation types. * @param finishImmediately Whether the animation jumps straight to the end. * @return true, if we can start the animation without cleaning up the current * animation. */ private boolean canUpdateAnimation( long time, OverviewAnimationType type, int sourceIndex, boolean finishImmediately) { if (mAnimationFactory != null) { if ((mOverviewAnimationType == OverviewAnimationType.DISCARD || mOverviewAnimationType == OverviewAnimationType.UNDISCARD || mOverviewAnimationType == OverviewAnimationType.DISCARD_ALL) && (type == OverviewAnimationType.DISCARD || type == OverviewAnimationType.UNDISCARD || type == OverviewAnimationType.DISCARD_ALL)) { return true; } } return false; }
Example 8
Source File: Stack.java From 365browser with Apache License 2.0 | 5 votes |
/** * Cancel scrolling animation which is a part of discarding animation. * @return true if the animation is canceled, false, if there is nothing to cancel. */ private boolean cancelDiscardScrollingAnimation() { if (mOverviewAnimationType == OverviewAnimationType.DISCARD || mOverviewAnimationType == OverviewAnimationType.UNDISCARD || mOverviewAnimationType == OverviewAnimationType.DISCARD_ALL) { mTabAnimations.cancel(null, StackTab.Property.SCROLL_OFFSET); return true; } return false; }
Example 9
Source File: Stack.java From 365browser with Apache License 2.0 | 5 votes |
/** * Called on touch click event. * * @param time The current time of the app in ms. * @param x The x coordinate in pixel inside the stack view. * @param y The y coordinate in pixel inside the stack view. */ public void click(long time, float x, float y) { if (mOverviewAnimationType != OverviewAnimationType.NONE && mOverviewAnimationType != OverviewAnimationType.DISCARD && mOverviewAnimationType != OverviewAnimationType.UNDISCARD && mOverviewAnimationType != OverviewAnimationType.DISCARD_ALL) { return; } int clicked = getTabIndexAtPositon(x, y, LayoutTab.getTouchSlop()); if (clicked >= 0) { // Check if the click was within the boundaries of the close button defined by its // visible coordinates. boolean isRtl = !((mCurrentMode == Orientation.PORTRAIT) ^ LocalizationUtils.isLayoutRtl()); if (mStackTabs[clicked].getLayoutTab().checkCloseHitTest(x, y, isRtl)) { // Tell the model to close the tab because the close button was pressed. The model // will then trigger a notification which will start the actual close process here // if necessary. StackTab tab = mStackTabs[clicked]; final float halfCloseBtnWidth = LayoutTab.CLOSE_BUTTON_WIDTH_DP / 2.f; final float halfCloseBtnHeight = mBorderTopPadding / 2.f; final float contentWidth = tab.getLayoutTab().getOriginalContentWidth(); tab.setDiscardOriginY(halfCloseBtnHeight); tab.setDiscardOriginX(isRtl ? halfCloseBtnWidth : contentWidth - halfCloseBtnWidth); tab.setDiscardFromClick(true); mLayout.uiRequestingCloseTab(time, tab.getId()); RecordUserAction.record("MobileStackViewCloseTab"); RecordUserAction.record("MobileTabClosed"); } else { // Let the model know that a new {@link LayoutTab} was selected. The model will // notify us if we need to do anything visual. setIndex() will possibly switch the // models and broadcast the event. mLayout.uiSelectingTab(time, mStackTabs[clicked].getId()); } } }
Example 10
Source File: Stack.java From delion with Apache License 2.0 | 4 votes |
/** * Discards and updates the position based on the input event values. * * @param x The x coordinate of the end of the drag event. * @param y The y coordinate of the end of the drag event. * @param amountX The number of pixels dragged in the x direction since the last event. * @param amountY The number of pixels dragged in the y direction since the last event. */ private void discard(float x, float y, float amountX, float amountY) { if (mStackTabs == null || (mOverviewAnimationType != OverviewAnimationType.NONE && mOverviewAnimationType != OverviewAnimationType.DISCARD && mOverviewAnimationType != OverviewAnimationType.DISCARD_ALL && mOverviewAnimationType != OverviewAnimationType.UNDISCARD)) { return; } if (mDiscardingTab == null) { if (!mInSwipe) { mDiscardingTab = getTabAtPositon(x, y); } else { if (mTabModel.index() < 0) return; mDiscardingTab = mStackTabs[mTabModel.index()]; } if (mDiscardingTab != null) { cancelDiscardScrollingAnimation(); // Make sure we are well within the tab in the discard direction. RectF target = mDiscardingTab.getLayoutTab().getClickTargetBounds(); float distanceToEdge; float edgeToEdge; if (mCurrentMode == Orientation.PORTRAIT) { mDiscardDirection = 1.0f; distanceToEdge = Math.max(target.left - x, x - target.right); edgeToEdge = target.width(); } else { mDiscardDirection = 2.0f - 4.0f * (x / mLayout.getWidth()); mDiscardDirection = MathUtils.clamp(mDiscardDirection, -1.0f, 1.0f); distanceToEdge = Math.max(target.top - y, y - target.bottom); edgeToEdge = target.height(); } float scaledDiscardX = x - mDiscardingTab.getLayoutTab().getX(); float scaledDiscardY = y - mDiscardingTab.getLayoutTab().getY(); mDiscardingTab.setDiscardOriginX(scaledDiscardX / mDiscardingTab.getScale()); mDiscardingTab.setDiscardOriginY(scaledDiscardY / mDiscardingTab.getScale()); mDiscardingTab.setDiscardFromClick(false); if (Math.abs(distanceToEdge) < DISCARD_SAFE_SELECTION_PCTG * edgeToEdge) { mDiscardingTab = null; } } } if (mDiscardingTab != null) { float deltaAmount = mCurrentMode == Orientation.PORTRAIT ? amountX : amountY; mDiscardingTab.addToDiscardAmount(deltaAmount); } }
Example 11
Source File: Stack.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * Discards and updates the position based on the input event values. * * @param x The x coordinate of the end of the drag event. * @param y The y coordinate of the end of the drag event. * @param amountX The number of pixels dragged in the x direction since the last event. * @param amountY The number of pixels dragged in the y direction since the last event. */ private void discard(float x, float y, float amountX, float amountY) { if (mStackTabs == null || (mOverviewAnimationType != OverviewAnimationType.NONE && mOverviewAnimationType != OverviewAnimationType.DISCARD && mOverviewAnimationType != OverviewAnimationType.DISCARD_ALL && mOverviewAnimationType != OverviewAnimationType.UNDISCARD)) { return; } if (mDiscardingTab == null) { if (!mInSwipe) { mDiscardingTab = getTabAtPositon(x, y); } else { if (mTabModel.index() < 0) return; mDiscardingTab = mStackTabs[mTabModel.index()]; } if (mDiscardingTab != null) { cancelDiscardScrollingAnimation(); // Make sure we are well within the tab in the discard direction. RectF target = mDiscardingTab.getLayoutTab().getClickTargetBounds(); float distanceToEdge; float edgeToEdge; if (mCurrentMode == Orientation.PORTRAIT) { mDiscardDirection = 1.0f; distanceToEdge = Math.max(target.left - x, x - target.right); edgeToEdge = target.width(); } else { mDiscardDirection = 2.0f - 4.0f * (x / mLayout.getWidth()); mDiscardDirection = MathUtils.clamp(mDiscardDirection, -1.0f, 1.0f); distanceToEdge = Math.max(target.top - y, y - target.bottom); edgeToEdge = target.height(); } float scaledDiscardX = x - mDiscardingTab.getLayoutTab().getX(); float scaledDiscardY = y - mDiscardingTab.getLayoutTab().getY(); mDiscardingTab.setDiscardOriginX(scaledDiscardX / mDiscardingTab.getScale()); mDiscardingTab.setDiscardOriginY(scaledDiscardY / mDiscardingTab.getScale()); mDiscardingTab.setDiscardFromClick(false); if (Math.abs(distanceToEdge) < DISCARD_SAFE_SELECTION_PCTG * edgeToEdge) { mDiscardingTab = null; } } } if (mDiscardingTab != null) { float deltaAmount = mCurrentMode == Orientation.PORTRAIT ? amountX : amountY; mDiscardingTab.addToDiscardAmount(deltaAmount); } }
Example 12
Source File: Stack.java From 365browser with Apache License 2.0 | 4 votes |
/** * Discards and updates the position based on the input event values. * * @param x The x coordinate of the end of the drag event. * @param y The y coordinate of the end of the drag event. * @param amountX The number of pixels dragged in the x direction since the last event. * @param amountY The number of pixels dragged in the y direction since the last event. */ private void discard(float x, float y, float amountX, float amountY) { if (mStackTabs == null || (mOverviewAnimationType != OverviewAnimationType.NONE && mOverviewAnimationType != OverviewAnimationType.DISCARD && mOverviewAnimationType != OverviewAnimationType.DISCARD_ALL && mOverviewAnimationType != OverviewAnimationType.UNDISCARD)) { return; } if (mDiscardingTab == null) { if (!mInSwipe) { mDiscardingTab = getTabAtPositon(x, y); } else { if (mTabModel.index() < 0) return; mDiscardingTab = mStackTabs[mTabModel.index()]; } if (mDiscardingTab != null) { cancelDiscardScrollingAnimation(); // Make sure we are well within the tab in the discard direction. RectF target = mDiscardingTab.getLayoutTab().getClickTargetBounds(); float distanceToEdge; float edgeToEdge; if (mCurrentMode == Orientation.PORTRAIT) { mDiscardDirection = 1.0f; distanceToEdge = Math.max(target.left - x, x - target.right); edgeToEdge = target.width(); } else { mDiscardDirection = 2.0f - 4.0f * (x / mLayout.getWidth()); mDiscardDirection = MathUtils.clamp(mDiscardDirection, -1.0f, 1.0f); distanceToEdge = Math.max(target.top - y, y - target.bottom); edgeToEdge = target.height(); } float scaledDiscardX = x - mDiscardingTab.getLayoutTab().getX(); float scaledDiscardY = y - mDiscardingTab.getLayoutTab().getY(); mDiscardingTab.setDiscardOriginX(scaledDiscardX / mDiscardingTab.getScale()); mDiscardingTab.setDiscardOriginY(scaledDiscardY / mDiscardingTab.getScale()); mDiscardingTab.setDiscardFromClick(false); if (Math.abs(distanceToEdge) < DISCARD_SAFE_SELECTION_PCTG * edgeToEdge) { mDiscardingTab = null; } } } if (mDiscardingTab != null) { float deltaAmount = mCurrentMode == Orientation.PORTRAIT ? amountX : amountY; mDiscardingTab.addToDiscardAmount(deltaAmount); } }