/** 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);
 }
 /**
  * Updates this floating toolbar to reflect recent position and view updates. NOTE: This method is
  * a no-op if the toolbar isn't showing.
  */
 public FloatingToolbar updateLayout() {
   if (mPopup.isShowing()) {
     // show() performs all the logic we need here.
     show();
   }
   return this;
 }
 /** Shows this floating toolbar. */
 public FloatingToolbar show() {
   List<MenuItem> menuItems = getVisibleAndEnabledMenuItems(mMenu);
   if (!isCurrentlyShowing(menuItems) || mWidthChanged) {
     mPopup.dismiss();
     mPopup.layoutMenuItems(menuItems, mMenuItemClickListener, mSuggestedWidth);
     mShowingTitles = getMenuItemTitles(menuItems);
   }
   refreshCoordinates();
   mPopup.setOverflowDirection(mOverflowDirection);
   mPopup.updateCoordinates(mCoordinates.x, mCoordinates.y);
   if (!mPopup.isShowing()) {
     mPopup.show(mCoordinates.x, mCoordinates.y);
   }
   mWidthChanged = false;
   return this;
 }
 /** Returns {@code true} if this toolbar is currently hidden. {@code false} otherwise. */
 public boolean isHidden() {
   return mPopup.isHidden();
 }
 /** Returns {@code true} if this toolbar is currently showing. {@code false} otherwise. */
 public boolean isShowing() {
   return mPopup.isShowing();
 }
 /**
  * Hides this floating toolbar. This is a no-op if the toolbar is not showing. Use {@link
  * #isHidden()} to distinguish between a hidden and a dismissed toolbar.
  */
 public void hide() {
   mPopup.hide();
 }
 /** Dismisses this floating toolbar. */
 public void dismiss() {
   mPopup.dismiss();
 }