本文整理汇总了Java中org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState类的典型用法代码示例。如果您正苦于以下问题:Java PanelState类的具体用法?Java PanelState怎么用?Java PanelState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PanelState类属于org.chromium.chrome.browser.compositor.bottombar.OverlayPanel包,在下文中一共展示了PanelState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLayoutChanged
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; //导入依赖的package包/类
/**
* Called when the layout has changed.
*
* @param width The new width in dp.
* @param height The new height in dp.
* @param visibleViewportOffsetY The Y offset of the content in dp.
*/
public void onLayoutChanged(float width, float height, float visibleViewportOffsetY) {
if (width == mLayoutWidth && height == mLayoutHeight
&& visibleViewportOffsetY == mLayoutYOffset) {
return;
}
float previousLayoutWidth = mLayoutWidth;
mLayoutWidth = width;
mLayoutHeight = height;
mLayoutYOffset = visibleViewportOffsetY;
mMaximumWidth = calculateOverlayPanelWidth();
mMaximumHeight = getPanelHeightFromState(PanelState.MAXIMIZED);
handleSizeChanged(width, height, previousLayoutWidth);
}
示例2: updatePanelForHeight
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; //导入依赖的package包/类
/**
* Updates the UI state for a given |height|.
*
* @param height The Overlay Panel height.
*/
private void updatePanelForHeight(float height) {
PanelState endState = findLargestPanelStateFromHeight(height);
PanelState startState = getPreviousPanelState(endState);
float percentage = getStateCompletion(height, startState, endState);
updatePanelSize(height);
if (endState == PanelState.CLOSED || endState == PanelState.PEEKED) {
updatePanelForCloseOrPeek(percentage);
} else if (endState == PanelState.EXPANDED) {
updatePanelForExpansion(percentage);
} else if (endState == PanelState.MAXIMIZED) {
updatePanelForMaximization(percentage);
}
}
示例3: findLargestPanelStateFromHeight
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; //导入依赖的package包/类
/**
* Finds the largest Panel state which is being transitioned to/from.
* Whenever the Panel is in between states, let's say, when resizing the
* Panel from its peeked to expanded state, we need to know those two states
* in order to calculate how closely we are from one of them. This method
* will always return the nearest state with the largest height, and
* together with the state preceding it, it's possible to calculate how far
* the Panel is from them.
*
* @param panelHeight The height to compare to.
* @return The panel state which is being transitioned to/from.
*/
private PanelState findLargestPanelStateFromHeight(float panelHeight) {
PanelState stateFound = PanelState.CLOSED;
// Iterate over all states and find the largest one which is being
// transitioned to/from.
for (PanelState state : PanelState.values()) {
if (!isValidUiState(state)) {
continue;
}
if (panelHeight <= getPanelHeightFromState(state)) {
stateFound = state;
break;
}
}
return stateFound;
}
示例4: onAnimationFinished
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; //导入依赖的package包/类
/**
* Called when layout-specific actions are needed after the animation finishes.
*/
protected void onAnimationFinished() {
// If animating to a particular PanelState, and after completing
// resizing the Panel to its desired state, then the Panel's state
// should be updated. This method also is called when an animation
// is cancelled (which can happen by a subsequent gesture while
// an animation is happening). That's why the actual height should
// be checked.
// TODO(mdjones): Move animations not directly related to the panel's state into their
// own animation handler (i.e. peek promo, G sprite, etc.). See https://crbug.com/617307.
if (mAnimatingState != null && mAnimatingState != PanelState.UNDEFINED
&& getHeight() == getPanelHeightFromState(mAnimatingState)) {
setPanelState(mAnimatingState, mAnimatingStateReason);
}
mAnimatingState = PanelState.UNDEFINED;
mAnimatingStateReason = StateChangeReason.UNKNOWN;
}
示例5: onClosed
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; //导入依赖的package包/类
@Override
public void onClosed(StateChangeReason reason) {
if (mReaderModePanel == null || mTabModelSelector == null) return;
restoreInfobars();
// Only dismiss the panel if the close was a result of user interaction.
if (reason != StateChangeReason.FLING && reason != StateChangeReason.SWIPE
&& reason != StateChangeReason.CLOSE_BUTTON) {
return;
}
// Record close button usage.
if (reason == StateChangeReason.CLOSE_BUTTON) {
RecordHistogram.recordBooleanHistogram("DomDistiller.BarCloseButtonUsage",
mReaderModePanel.getPanelState() == PanelState.EXPANDED
|| mReaderModePanel.getPanelState() == PanelState.MAXIMIZED);
}
int currentTabId = mTabModelSelector.getCurrentTabId();
if (!mTabStatusMap.containsKey(currentTabId)) return;
mTabStatusMap.get(currentTabId).setIsDismissed(true);
}
示例6: handleScroll
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; //导入依赖的package包/类
/**
* Handles the scroll event, determining the gesture orientation and event target,
* when appropriate.
* @param e1 The first down {@link MotionEvent} that started the scrolling.
* @param e2 The move {@link MotionEvent} that triggered the current scroll.
* @param distanceY The distance along the Y axis that has been scrolled since the last call
* to handleScroll.
* @return Whether the event has been consumed.
*/
protected boolean handleScroll(MotionEvent e1, MotionEvent e2, float distanceY) {
// If the panel is peeking then the swipe recognizer will handle the scroll event.
if (mPanel.getPanelState() == PanelState.PEEKED) return false;
// Only determines the gesture orientation if it hasn't been determined yet,
// affectively "locking" the orientation once the gesture has started.
if (!mHasDeterminedGestureOrientation && isDistanceGreaterThanTouchSlop(e1, e2)) {
determineGestureOrientation(e1, e2);
}
// Only determines the event target after determining the gesture orientation and
// if it hasn't been determined yet or if changing the event target during the
// middle of the gesture is supported. This will allow a smooth transition from
// swiping the Panel and scrolling the Content View.
final boolean mayChangeEventTarget = mMayChangeEventTarget && e2.getPointerCount() == 1;
if (mHasDeterminedGestureOrientation
&& (!mHasDeterminedEventTarget || mayChangeEventTarget)) {
determineEventTarget(distanceY);
}
return false;
}
示例7: handleSingleTapUp
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; //导入依赖的package包/类
/**
* Handles the tap event, determining the event target.
* @param e The tap {@link MotionEvent}.
* @return Whether the event has been consumed.
*/
protected boolean handleSingleTapUp(MotionEvent e) {
// If the panel is peeking then the panel was already notified in #onTouchEventInternal().
if (mPanel.getPanelState() == PanelState.PEEKED) return false;
setEventTarget(mPanel.isCoordinateInsideContent(
e.getX() * mPxToDp, e.getY() * mPxToDp)
? EventTarget.CONTENT_VIEW : EventTarget.PANEL);
return false;
}
示例8: handleScroll
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; //导入依赖的package包/类
/**
* Handles the scroll event, determining the gesture orientation and event target,
* when appropriate.
* @param e1 The first down {@link MotionEvent} that started the scrolling.
* @param e2 The move {@link MotionEvent} that triggered the current scroll.
* @param distanceY The distance along the Y axis that has been scrolled since the last call
* to handleScroll.
* @return Whether the event has been consumed.
*/
protected boolean handleScroll(MotionEvent e1, MotionEvent e2, float distanceY) {
// TODO(mdjones): It seems impossible that either of the two MotionEvents passed into this
// function would be null provided the InternalGestureDetector checks them. However, it
// still seems to be possible...
if (e1 == null || e2 == null) return false;
// If the panel is peeking then the swipe recognizer will handle the scroll event.
if (mPanel.getPanelState() == PanelState.PEEKED) return false;
// Only determines the gesture orientation if it hasn't been determined yet,
// affectively "locking" the orientation once the gesture has started.
if (!mHasDeterminedGestureOrientation && isDistanceGreaterThanTouchSlop(e1, e2)) {
determineGestureOrientation(e1, e2);
}
// Only determines the event target after determining the gesture orientation and
// if it hasn't been determined yet or if changing the event target during the
// middle of the gesture is supported. This will allow a smooth transition from
// swiping the Panel and scrolling the Content View.
final boolean mayChangeEventTarget = mMayChangeEventTarget && e2.getPointerCount() == 1;
if (mHasDeterminedGestureOrientation
&& (!mHasDeterminedEventTarget || mayChangeEventTarget)) {
determineEventTarget(distanceY);
}
return false;
}
示例9: setPanelState
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; //导入依赖的package包/类
/**
* Sets the panel's state.
* @param state The panel state to transition to.
* @param reason The reason for a change in the panel's state.
*/
protected void setPanelState(PanelState state, StateChangeReason reason) {
if (state == PanelState.CLOSED) {
mHeight = 0;
onClosed(reason);
}
// We should only set the state at the end of this method, in oder to make sure that
// all callbacks will be fired before changing the state of the Panel. This prevents
// some flakiness on tests since they rely on changes of state to determine when a
// particular action has been completed.
mPanelState = state;
}
示例10: getMaximumSupportedState
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; //导入依赖的package包/类
/**
* @return The maximum state supported by the panel.
*/
private PanelState getMaximumSupportedState() {
if (isSupportedState(PanelState.MAXIMIZED)) {
return PanelState.MAXIMIZED;
} else if (isSupportedState(PanelState.EXPANDED)) {
return PanelState.EXPANDED;
} else {
return PanelState.PEEKED;
}
}
示例11: getPreviousPanelState
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; //导入依赖的package包/类
/**
* @return The {@code PanelState} that is before the |state| in the order of states.
*/
private PanelState getPreviousPanelState(PanelState state) {
PanelState prevState = PREVIOUS_STATES.get(state);
if (!isSupportedState(PanelState.EXPANDED)) {
prevState = PREVIOUS_STATES.get(prevState);
}
return prevState != null ? prevState : PanelState.UNDEFINED;
}
示例12: getPanelHeightFromState
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; //导入依赖的package包/类
/**
* Gets the height of the Overlay Panel in dps for a given |state|.
*
* @param state The state whose height will be calculated.
* @return The height of the Overlay Panel in dps for a given |state|.
*/
public float getPanelHeightFromState(PanelState state) {
if (state == PanelState.PEEKED) {
return getPeekedHeight();
} else if (state == PanelState.EXPANDED) {
return getExpandedHeight();
} else if (state == PanelState.MAXIMIZED) {
return getMaximizedHeight();
}
return 0;
}
示例13: findNearestPanelStateFromHeight
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; //导入依赖的package包/类
/**
* Finds the state which has the nearest height compared to a given
* |desiredPanelHeight|.
*
* @param desiredPanelHeight The height to compare to.
* @param velocity The velocity of the swipe if applicable. The swipe is upward if less than 0.
* @return The nearest panel state.
*/
protected PanelState findNearestPanelStateFromHeight(float desiredPanelHeight, float velocity) {
// If the panel was flung hard enough to make the desired height negative, it's closed.
if (desiredPanelHeight < 0) return PanelState.CLOSED;
// First, find the two states that the desired panel height is between.
PanelState nextState = PanelState.values()[0];
PanelState prevState = nextState;
for (PanelState state : PanelState.values()) {
if (!isValidUiState(state)) {
continue;
}
prevState = nextState;
nextState = state;
// The values in PanelState are ascending, they should be kept that way in order for
// this to work.
if (desiredPanelHeight >= getPanelHeightFromState(prevState)
&& desiredPanelHeight < getPanelHeightFromState(nextState)) {
break;
}
}
// If the desired height is close enough to a certain state, depending on the direction of
// the velocity, move to that state.
float lowerBound = getPanelHeightFromState(prevState);
float distance = getPanelHeightFromState(nextState) - lowerBound;
float thresholdToNextState = velocity < 0.0f
? getThresholdToNextState() : 1.0f - getThresholdToNextState();
if ((desiredPanelHeight - lowerBound) / distance > thresholdToNextState) {
return nextState;
} else {
return prevState;
}
}
示例14: setClampedPanelHeight
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; //导入依赖的package包/类
/**
* Sets the last panel height within the limits allowable by our UI.
*
* @param height The height of the panel in dps.
*/
protected void setClampedPanelHeight(float height) {
final float clampedHeight = MathUtils.clamp(height,
getPanelHeightFromState(getMaximumSupportedState()),
getPanelHeightFromState(PanelState.PEEKED));
setPanelHeight(clampedHeight);
}
示例15: updatePanelSize
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; //导入依赖的package包/类
/**
* Updates the Panel size information.
*
* @param height The Overlay Panel height.
*/
private void updatePanelSize(float height) {
mHeight = height;
mOffsetX = calculateOverlayPanelX();
mOffsetY = calculateOverlayPanelY();
mIsMaximized = height == getPanelHeightFromState(PanelState.MAXIMIZED);
}