Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a3998ba authored by Hyunyoung Song's avatar Hyunyoung Song
Browse files

separate enforceContainerWithinScreen logic to a private method am: 27790352 am: 6dc62fb2

Change-Id: I1e1aff4cc6ebbe8c7ef8d262cd377bfae320e51d
parents 1b169920 6dc62fb2
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -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;
        }