From 27790352a3eaa64fef2ca0087526f17947fdca6e Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Thu, 20 Jul 2017 13:57:23 -0700 Subject: separate enforceContainerWithinScreen logic to a private method Change-Id: Ifcf8c6a79286269646a845b5be6cfa92b64fcbcc --- src/com/android/launcher3/popup/PopupContainerWithArrow.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/com/android/launcher3/popup/PopupContainerWithArrow.java') diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index f5f7ddb31..c3e2d8b89 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -402,9 +402,14 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); + enforceContainedWithinScreen(l, r); + + } + + private void enforceContainedWithinScreen(int left, int right) { DragLayer dragLayer = mLauncher.getDragLayer(); - if (getTranslationX() + l < 0 || - getTranslationX() + l + getMeasuredWidth() > dragLayer.getWidth()) { + if (getTranslationX() + left < 0 || + getTranslationX() + right > dragLayer.getWidth()) { // If we are still off screen, center horizontally too. mGravity |= Gravity.CENTER_HORIZONTAL; } -- cgit v1.2.3