Program: 20434
Project: 20434
Buggy source:
public void show(){
  popupWindow=new ListPopupWindow(context);
  popupWindow.setAnchorView(anchor);
  popupWindow.setModal(true);
  popupWindow.setDropDownGravity(anchorGravity);
  popupWindow.setVerticalOffset(-anchor.getHeight() + anchorOffsetY);
  popupWindow.setHorizontalOffset(anchorOffsetX);
  if (popupWidth == POPUP_WIDTH_ANCHOR) {
    popupWindow.setContentWidth(Math.min(dp(4 * 56),anchor.getWidth()));
  }
 else   if (popupWidth == POPUP_WIDTH_AUTO) {
    popupWindow.setContentWidth(dp(3 * 56));
  }
 else {
    popupWindow.setContentWidth(popupWidth);
  }
  List<String> stringItems=new ArrayList<>(items.size());
  int selectedPosition=0;
  for (int i=0; i < items.size(); i++) {
    stringItems.add(items.get(i).getText());
    if (items.get(i) == selectedItem) {
      selectedPosition=i;
    }
  }
  if (adapter != null) {
    popupWindow.setAdapter(adapter);
  }
 else {
    popupWindow.setAdapter(new FloatingMenuArrayAdapter(context,R.layout.toolbar_menu_item,stringItems));
  }
  popupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      if (position >= 0 && position < items.size()) {
        callback.onFloatingMenuItemClicked(FloatingMenu.this,items.get(position));
        popupWindow.dismiss();
      }
 else {
        callback.onFloatingMenuItemClicked(FloatingMenu.this,null);
      }
    }
  }
);
  globalLayoutListener=new ViewTreeObserver.OnGlobalLayoutListener(){
    @Override public void onGlobalLayout(){
      if (popupWindow == null) {
        Logger.w("String_Node_Str","String_Node_Str");
      }
 else {
        if (popupWindow.isShowing()) {
          popupWindow.show();
        }
      }
    }
  }
;
  anchor.getViewTreeObserver().addOnGlobalLayoutListener(globalLayoutListener);
  popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener(){
    @Override public void onDismiss(){
      if (anchor.getViewTreeObserver().isAlive()) {
        anchor.getViewTreeObserver().removeGlobalOnLayoutListener(globalLayoutListener);
      }
      globalLayoutListener=null;
      popupWindow=null;
      callback.onFloatingMenuDismissed(FloatingMenu.this);
    }
  }
);
  popupWindow.show();
  popupWindow.setSelection(selectedPosition);
}

Fixed version (ground truth):
public void show(){
  popupWindow=new ListPopupWindow(context);
  popupWindow.setAnchorView(anchor);
  popupWindow.setModal(true);
  popupWindow.setDropDownGravity(anchorGravity);
  popupWindow.setVerticalOffset(-anchor.getHeight() + anchorOffsetY);
  popupWindow.setHorizontalOffset(anchorOffsetX);
  if (popupWidth == POPUP_WIDTH_ANCHOR) {
    popupWindow.setContentWidth(Math.min(dp(8 * 56),Math.max(dp(4 * 56),anchor.getWidth())));
  }
 else   if (popupWidth == POPUP_WIDTH_AUTO) {
    popupWindow.setContentWidth(dp(3 * 56));
  }
 else {
    popupWindow.setContentWidth(popupWidth);
  }
  List<String> stringItems=new ArrayList<>(items.size());
  int selectedPosition=0;
  for (int i=0; i < items.size(); i++) {
    stringItems.add(items.get(i).getText());
    if (items.get(i) == selectedItem) {
      selectedPosition=i;
    }
  }
  if (adapter != null) {
    popupWindow.setAdapter(adapter);
  }
 else {
    popupWindow.setAdapter(new FloatingMenuArrayAdapter(context,R.layout.toolbar_menu_item,stringItems));
  }
  popupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      if (position >= 0 && position < items.size()) {
        callback.onFloatingMenuItemClicked(FloatingMenu.this,items.get(position));
        popupWindow.dismiss();
      }
 else {
        callback.onFloatingMenuItemClicked(FloatingMenu.this,null);
      }
    }
  }
);
  globalLayoutListener=new ViewTreeObserver.OnGlobalLayoutListener(){
    @Override public void onGlobalLayout(){
      if (popupWindow == null) {
        Logger.w("String_Node_Str","String_Node_Str");
      }
 else {
        if (popupWindow.isShowing()) {
          popupWindow.show();
        }
      }
    }
  }
;
  anchor.getViewTreeObserver().addOnGlobalLayoutListener(globalLayoutListener);
  popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener(){
    @Override public void onDismiss(){
      if (anchor.getViewTreeObserver().isAlive()) {
        anchor.getViewTreeObserver().removeGlobalOnLayoutListener(globalLayoutListener);
      }
      globalLayoutListener=null;
      popupWindow=null;
      callback.onFloatingMenuDismissed(FloatingMenu.this);
    }
  }
);
  popupWindow.show();
  popupWindow.setSelection(selectedPosition);
}