@Override
  public void onCheckedChange() {
    if (!inContextMode) {
      return;
    }

    updateActionModeTitle();
    Utils.setSelectAllActionModeButtonVisibility(
        selectAllActionModeButton,
        adapter.getCount() > 0 && adapter.getAmountOfCheckedItems() != adapter.getCount());
  }
  private void addSelectAllActionModeButton(ActionMode mode, Menu menu) {
    selectAllActionModeButton =
        Utils.addSelectAllActionModeButton(getLayoutInflater(null), mode, menu);
    selectAllActionModeButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View view) {
            for (int position = 0; position < adapter.getCount(); position++) {
              adapter.addCheckedItem(position);
            }
            adapter.notifyDataSetChanged();
            onCheckedChange();
          }
        });
  }