Merge "Use adjusted popup window position when calculating best-fit" into nyc-dev
am: 0529197
* commit '0529197e9df8837ac63b011937391ff29426e6b5':
Use adjusted popup window position when calculating best-fit
Change-Id: I92ffd7cd81e20ff97fc44ed98fba3a00a446d558
This commit is contained in:
@@ -1529,7 +1529,6 @@ public class PopupWindow {
|
|||||||
height = displayFrame.bottom - displayFrame.top;
|
height = displayFrame.bottom - displayFrame.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If we need to adjust for gravity RIGHT, align to the bottom-right
|
// If we need to adjust for gravity RIGHT, align to the bottom-right
|
||||||
// corner of the anchor (still accounting for offsets).
|
// corner of the anchor (still accounting for offsets).
|
||||||
final int hgrav = Gravity.getAbsoluteGravity(gravity, anchor.getLayoutDirection())
|
final int hgrav = Gravity.getAbsoluteGravity(gravity, anchor.getLayoutDirection())
|
||||||
@@ -1583,9 +1582,10 @@ public class PopupWindow {
|
|||||||
private boolean tryFitVertical(@NonNull LayoutParams outParams, int yOffset, int height,
|
private boolean tryFitVertical(@NonNull LayoutParams outParams, int yOffset, int height,
|
||||||
int anchorHeight, int drawingLocationY, int screenLocationY, int displayFrameTop,
|
int anchorHeight, int drawingLocationY, int screenLocationY, int displayFrameTop,
|
||||||
int displayFrameBottom, boolean allowResize) {
|
int displayFrameBottom, boolean allowResize) {
|
||||||
final int anchorTopInScreen = screenLocationY + anchorHeight + yOffset;
|
final int winOffsetY = screenLocationY - drawingLocationY;
|
||||||
|
final int anchorTopInScreen = outParams.y + winOffsetY;
|
||||||
final int spaceBelow = displayFrameBottom - anchorTopInScreen;
|
final int spaceBelow = displayFrameBottom - anchorTopInScreen;
|
||||||
if (height <= spaceBelow) {
|
if (anchorTopInScreen >= 0 && height <= spaceBelow) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1644,9 +1644,10 @@ public class PopupWindow {
|
|||||||
private boolean tryFitHorizontal(@NonNull LayoutParams outParams, int xOffset, int width,
|
private boolean tryFitHorizontal(@NonNull LayoutParams outParams, int xOffset, int width,
|
||||||
int anchorWidth, int drawingLocationX, int screenLocationX, int displayFrameLeft,
|
int anchorWidth, int drawingLocationX, int screenLocationX, int displayFrameLeft,
|
||||||
int displayFrameRight, boolean allowResize) {
|
int displayFrameRight, boolean allowResize) {
|
||||||
final int anchorLeftInScreen = screenLocationX + xOffset;
|
final int winOffsetX = screenLocationX - drawingLocationX;
|
||||||
|
final int anchorLeftInScreen = outParams.x + winOffsetX;
|
||||||
final int spaceRight = displayFrameRight - anchorLeftInScreen;
|
final int spaceRight = displayFrameRight - anchorLeftInScreen;
|
||||||
if (width <= spaceRight) {
|
if (anchorLeftInScreen >= 0 && width <= spaceRight) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user