Java Code Examples for org.chromium.chrome.browser.util.ViewUtils#getRelativeLayoutPosition()
The following examples show how to use
org.chromium.chrome.browser.util.ViewUtils#getRelativeLayoutPosition() .
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: ChromeFullscreenManager.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * @param e The dispatched motion event * @return Whether or not this motion event is in the top control container area and should be * consumed. */ public boolean onInterceptMotionEvent(MotionEvent e) { int bottomPosition; int topPosition = 0; float offset; if (mIsBottomControls) { int[] position = new int[2]; ViewUtils.getRelativeLayoutPosition(mControlContainer.getView().getRootView(), mControlContainer.getView(), position); topPosition = position[1]; bottomPosition = topPosition + getBottomControlsHeight(); offset = getBottomControlOffset(); } else { bottomPosition = getTopControlsHeight(); offset = getTopControlOffset(); } return e.getY() < topPosition + offset && e.getY() > bottomPosition + offset && !mBrowserControlsAndroidViewHidden; }
Example 2
Source File: SuggestionView.java From 365browser with Apache License 2.0 | 5 votes |
private int getUrlBarLeftOffset() { if (mLocationBar.mustQueryUrlBarLocationForSuggestions()) { View contentView = getRootView().findViewById(android.R.id.content); ViewUtils.getRelativeLayoutPosition(contentView, mUrlBar, mViewPositionHolder); return mViewPositionHolder[0]; } else { return ApiCompatibilityUtils.isLayoutRtl(this) ? mPhoneUrlBarLeftOffsetRtlPx : mPhoneUrlBarLeftOffsetPx; } }
Example 3
Source File: SuggestionView.java From 365browser with Apache License 2.0 | 5 votes |
/** * @return The left offset for the suggestion text. */ private int getSuggestionTextLeftPosition() { if (mLocationBar == null) return 0; int leftOffset = getUrlBarLeftOffset(); View contentView = getRootView().findViewById(android.R.id.content); ViewUtils.getRelativeLayoutPosition(contentView, this, mViewPositionHolder); return leftOffset + mUrlBar.getPaddingLeft() - mViewPositionHolder[0]; }
Example 4
Source File: SuggestionView.java From 365browser with Apache License 2.0 | 5 votes |
/** * @return The right offset for the suggestion text. */ private int getSuggestionTextRightPosition() { if (mLocationBar == null) return 0; int leftOffset = getUrlBarLeftOffset(); View contentView = getRootView().findViewById(android.R.id.content); ViewUtils.getRelativeLayoutPosition(contentView, this, mViewPositionHolder); return leftOffset + mUrlBar.getWidth() - mUrlBar.getPaddingRight() - mViewPositionHolder[0]; }
Example 5
Source File: LocationBarLayout.java From delion with Apache License 2.0 | 4 votes |
private void updateLayoutParams() { boolean updateLayout = false; FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) getLayoutParams(); if (layoutParams == null) { layoutParams = new FrameLayout.LayoutParams(0, 0); setLayoutParams(layoutParams); } // Compare the relative positions of the anchor view to the list parent view to // determine the offset to apply to the suggestions list. By using layout positioning, // this avoids issues where getLocationInWindow can be inaccurate on certain devices. View contentView = LocationBarLayout.this.getRootView().findViewById(android.R.id.content); ViewUtils.getRelativeLayoutPosition(contentView, mAnchorView, mTempPosition); int anchorX = mTempPosition[0]; int anchorY = mTempPosition[1]; ViewUtils.getRelativeLayoutPosition(contentView, (View) getParent(), mTempPosition); int parentY = mTempPosition[1]; int anchorBottomRelativeToContent = anchorY + mAnchorView.getMeasuredHeight(); int desiredTopMargin = anchorBottomRelativeToContent - parentY; if (layoutParams.topMargin != desiredTopMargin) { layoutParams.topMargin = desiredTopMargin; updateLayout = true; } int contentLeft = contentView.getLeft(); int anchorLeftRelativeToContent = anchorX - contentLeft; if (layoutParams.leftMargin != anchorLeftRelativeToContent) { layoutParams.leftMargin = anchorLeftRelativeToContent; updateLayout = true; } getWindowDelegate().getWindowVisibleDisplayFrame(mTempRect); int decorHeight = getWindowDelegate().getDecorViewHeight(); int availableViewportHeight = Math.min(mTempRect.height(), decorHeight); int availableListHeight = availableViewportHeight - anchorBottomRelativeToContent; int desiredHeight = Math.min(availableListHeight, getIdealHeight()); if (layoutParams.height != desiredHeight) { layoutParams.height = desiredHeight; updateLayout = true; } int desiredWidth = getDesiredWidth(); if (layoutParams.width != desiredWidth) { layoutParams.width = desiredWidth; updateLayout = true; } if (updateLayout) requestLayout(); }
Example 6
Source File: LocationBarLayout.java From AndroidChromium with Apache License 2.0 | 4 votes |
private void updateLayoutParams() { boolean updateLayout = false; FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) getLayoutParams(); if (layoutParams == null) { layoutParams = new FrameLayout.LayoutParams(0, 0); setLayoutParams(layoutParams); } // Compare the relative positions of the anchor view to the list parent view to // determine the offset to apply to the suggestions list. By using layout positioning, // this avoids issues where getLocationInWindow can be inaccurate on certain devices. View contentView = LocationBarLayout.this.getRootView().findViewById(android.R.id.content); ViewUtils.getRelativeLayoutPosition(contentView, mAnchorView, mTempPosition); int anchorX = mTempPosition[0]; int anchorY = mTempPosition[1]; ViewUtils.getRelativeLayoutPosition(contentView, (View) getParent(), mTempPosition); int parentY = mTempPosition[1]; int anchorBottomRelativeToContent = anchorY + mAnchorView.getMeasuredHeight(); int desiredTopMargin = anchorBottomRelativeToContent - parentY; if (layoutParams.topMargin != desiredTopMargin) { layoutParams.topMargin = desiredTopMargin; updateLayout = true; } int contentLeft = contentView.getLeft(); int anchorLeftRelativeToContent = anchorX - contentLeft; if (layoutParams.leftMargin != anchorLeftRelativeToContent) { layoutParams.leftMargin = anchorLeftRelativeToContent; updateLayout = true; } getWindowDelegate().getWindowVisibleDisplayFrame(mTempRect); int decorHeight = getWindowDelegate().getDecorViewHeight(); int availableViewportHeight = Math.min(mTempRect.height(), decorHeight); int availableListHeight = availableViewportHeight - anchorBottomRelativeToContent; int desiredHeight = Math.min(availableListHeight, getIdealHeight()); if (layoutParams.height != desiredHeight) { layoutParams.height = desiredHeight; updateLayout = true; } int desiredWidth = getDesiredWidth(); if (layoutParams.width != desiredWidth) { layoutParams.width = desiredWidth; updateLayout = true; } if (updateLayout) requestLayout(); }
Example 7
Source File: LocationBarLayout.java From 365browser with Apache License 2.0 | 4 votes |
private void updateLayoutParams() { boolean updateLayout = false; FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) getLayoutParams(); if (layoutParams == null) { layoutParams = new FrameLayout.LayoutParams(0, 0); setLayoutParams(layoutParams); } // Compare the relative positions of the anchor view to the list parent view to // determine the offset to apply to the suggestions list. By using layout positioning, // this avoids issues where getLocationInWindow can be inaccurate on certain devices. View contentView = LocationBarLayout.this.getRootView().findViewById(android.R.id.content); ViewUtils.getRelativeLayoutPosition(contentView, mAnchorView, mTempPosition); int anchorX = mTempPosition[0]; int anchorY = mTempPosition[1]; ViewUtils.getRelativeLayoutPosition(contentView, (View) getParent(), mTempPosition); int parentY = mTempPosition[1]; int anchorBottomRelativeToContent = anchorY + mAnchorView.getMeasuredHeight(); int desiredTopMargin = anchorBottomRelativeToContent - parentY; if (layoutParams.topMargin != desiredTopMargin) { layoutParams.topMargin = desiredTopMargin; updateLayout = true; } int contentLeft = contentView.getLeft(); int anchorLeftRelativeToContent = anchorX - contentLeft; if (layoutParams.leftMargin != anchorLeftRelativeToContent) { layoutParams.leftMargin = anchorLeftRelativeToContent; updateLayout = true; } getWindowDelegate().getWindowVisibleDisplayFrame(mTempRect); int decorHeight = getWindowDelegate().getDecorViewHeight(); int availableViewportHeight = Math.min(mTempRect.height(), decorHeight); int availableListHeight = availableViewportHeight - anchorBottomRelativeToContent; // If the bottom sheet is used, the suggestions should consume all available space. int desiredHeight = mBottomSheet != null ? availableListHeight : Math.min(availableListHeight, getIdealHeight()); if (layoutParams.height != desiredHeight) { layoutParams.height = desiredHeight; updateLayout = true; } int desiredWidth = getDesiredWidth(); if (layoutParams.width != desiredWidth) { layoutParams.width = desiredWidth; updateLayout = true; } if (updateLayout) requestLayout(); }