Program: 162497
Project: 162497
Buggy source:
/** 
 * the following method is called each time the action mode is shown. Always called after onCreateActionMode, but may be called multiple times if the mode is invalidated.
 */
public boolean onPrepareActionMode(ActionMode mode,Menu menu){
  ArrayList<LayoutElementParcelable> positions=adapter.getCheckedItems();
  TextView textView1=(TextView)actionModeView.findViewById(R.id.item_count);
  textView1.setText(String.valueOf(positions.size()));
  textView1.setOnClickListener(null);
  mode.setTitle(positions.size() + "String_Node_Str");
  hideOption(R.id.openmulti,menu);
  if (openMode != OpenMode.FILE) {
    hideOption(R.id.addshortcut,menu);
    hideOption(R.id.compress,menu);
    return true;
  }
  if (getMainActivity().mReturnIntent)   if (Build.VERSION.SDK_INT >= 16)   showOption(R.id.openmulti,menu);
  if (!results) {
    hideOption(R.id.openparent,menu);
    if (positions.size() == 1) {
      showOption(R.id.addshortcut,menu);
      showOption(R.id.openwith,menu);
      showOption(R.id.share,menu);
      File x=new File(adapter.getCheckedItems().get(0).desc);
      if (x.isDirectory()) {
        hideOption(R.id.openwith,menu);
        hideOption(R.id.share,menu);
        hideOption(R.id.openmulti,menu);
      }
      if (getMainActivity().mReturnIntent)       if (Build.VERSION.SDK_INT >= 16)       showOption(R.id.openmulti,menu);
    }
 else {
      try {
        showOption(R.id.share,menu);
        if (getMainActivity().mReturnIntent)         if (Build.VERSION.SDK_INT >= 16)         showOption(R.id.openmulti,menu);
        for (        LayoutElementParcelable e : adapter.getCheckedItems()) {
          File x=new File(e.desc);
          if (x.isDirectory()) {
            hideOption(R.id.share,menu);
            hideOption(R.id.openmulti,menu);
          }
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      hideOption(R.id.openwith,menu);
      hideOption(R.id.addshortcut,menu);
    }
  }
 else {
    if (positions.size() == 1) {
      showOption(R.id.addshortcut,menu);
      showOption(R.id.openparent,menu);
      showOption(R.id.openwith,menu);
      showOption(R.id.share,menu);
      File x=new File(adapter.getCheckedItems().get(0).desc);
      if (x.isDirectory()) {
        hideOption(R.id.openwith,menu);
        hideOption(R.id.share,menu);
        hideOption(R.id.openmulti,menu);
      }
      if (getMainActivity().mReturnIntent)       if (Build.VERSION.SDK_INT >= 16)       showOption(R.id.openmulti,menu);
    }
 else {
      hideOption(R.id.openparent,menu);
      hideOption(R.id.addshortcut,menu);
      if (getMainActivity().mReturnIntent)       if (Build.VERSION.SDK_INT >= 16)       showOption(R.id.openmulti,menu);
      try {
        for (        LayoutElementParcelable e : adapter.getCheckedItems()) {
          File x=new File(e.desc);
          if (x.isDirectory()) {
            hideOption(R.id.share,menu);
            hideOption(R.id.openmulti,menu);
          }
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      hideOption(R.id.openwith,menu);
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * the following method is called each time the action mode is shown. Always called after onCreateActionMode, but may be called multiple times if the mode is invalidated.
 */
public boolean onPrepareActionMode(ActionMode mode,Menu menu){
  ArrayList<LayoutElementParcelable> positions=adapter.getCheckedItems();
  TextView textView1=(TextView)actionModeView.findViewById(R.id.item_count);
  textView1.setText(String.valueOf(positions.size()));
  textView1.setOnClickListener(null);
  mode.setTitle(positions.size() + "String_Node_Str");
  hideOption(R.id.openmulti,menu);
  menu.findItem(R.id.all).setTitle(positions.size() == folder_count + file_count ? R.string.deselect_all : R.string.selectall);
  if (openMode != OpenMode.FILE) {
    hideOption(R.id.addshortcut,menu);
    hideOption(R.id.compress,menu);
    return true;
  }
  if (getMainActivity().mReturnIntent)   if (Build.VERSION.SDK_INT >= 16)   showOption(R.id.openmulti,menu);
  if (!results) {
    hideOption(R.id.openparent,menu);
    if (positions.size() == 1) {
      showOption(R.id.addshortcut,menu);
      showOption(R.id.openwith,menu);
      showOption(R.id.share,menu);
      File x=new File(adapter.getCheckedItems().get(0).desc);
      if (x.isDirectory()) {
        hideOption(R.id.openwith,menu);
        hideOption(R.id.share,menu);
        hideOption(R.id.openmulti,menu);
      }
      if (getMainActivity().mReturnIntent)       if (Build.VERSION.SDK_INT >= 16)       showOption(R.id.openmulti,menu);
    }
 else {
      try {
        showOption(R.id.share,menu);
        if (getMainActivity().mReturnIntent)         if (Build.VERSION.SDK_INT >= 16)         showOption(R.id.openmulti,menu);
        for (        LayoutElementParcelable e : adapter.getCheckedItems()) {
          File x=new File(e.desc);
          if (x.isDirectory()) {
            hideOption(R.id.share,menu);
            hideOption(R.id.openmulti,menu);
          }
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      hideOption(R.id.openwith,menu);
      hideOption(R.id.addshortcut,menu);
    }
  }
 else {
    if (positions.size() == 1) {
      showOption(R.id.addshortcut,menu);
      showOption(R.id.openparent,menu);
      showOption(R.id.openwith,menu);
      showOption(R.id.share,menu);
      File x=new File(adapter.getCheckedItems().get(0).desc);
      if (x.isDirectory()) {
        hideOption(R.id.openwith,menu);
        hideOption(R.id.share,menu);
        hideOption(R.id.openmulti,menu);
      }
      if (getMainActivity().mReturnIntent)       if (Build.VERSION.SDK_INT >= 16)       showOption(R.id.openmulti,menu);
    }
 else {
      hideOption(R.id.openparent,menu);
      hideOption(R.id.addshortcut,menu);
      if (getMainActivity().mReturnIntent)       if (Build.VERSION.SDK_INT >= 16)       showOption(R.id.openmulti,menu);
      try {
        for (        LayoutElementParcelable e : adapter.getCheckedItems()) {
          File x=new File(e.desc);
          if (x.isDirectory()) {
            hideOption(R.id.share,menu);
            hideOption(R.id.openmulti,menu);
          }
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      hideOption(R.id.openwith,menu);
    }
  }
  return true;
}