/** Refreshes {@link #mCoordinates} with values based on {@link #mContentRect}. */ private void refreshCoordinates() { int x = mContentRect.centerX() - mPopup.getWidth() / 2; int y; if (mContentRect.top > mPopup.getHeight()) { y = mContentRect.top - mPopup.getHeight(); mOverflowDirection = FloatingToolbarPopup.OVERFLOW_DIRECTION_UP; } else if (mContentRect.top > mPopup.getToolbarHeightWithVerticalMargin()) { y = mContentRect.top - mPopup.getToolbarHeightWithVerticalMargin(); mOverflowDirection = FloatingToolbarPopup.OVERFLOW_DIRECTION_DOWN; } else { y = mContentRect.bottom; mOverflowDirection = FloatingToolbarPopup.OVERFLOW_DIRECTION_DOWN; } mCoordinates.set(x, y); }