@Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (!isVisible() || isDetached()) return;
    super.onCreateOptionsMenu(menu, inflater);
    if (mPath == null || !mPath.isFile() || !IntentManager.isIntentAvailable(mPath, getExplorer()))
      MenuUtils.setMenuVisible(menu, false, R.id.menu_context_edit, R.id.menu_context_view);
    Logger.LogVerbose("ContentFragment.onCreateOptionsMenu");
    if (!menu.hasVisibleItems()) inflater.inflate(R.menu.content, menu);
    MenuUtils.setMenuVisible(menu, OpenExplorer.IS_DEBUG_BUILD, R.id.menu_debug);
    if (!OpenExplorer.BEFORE_HONEYCOMB && OpenExplorer.USE_ACTION_BAR) {
      MenuUtils.setMenuVisible(menu, false, R.id.menu_more);
      try {
        final SearchView mSearchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
        if (mSearchView != null)
          mSearchView.setOnQueryTextListener(
              new SearchView.OnQueryTextListener() {
                @TargetApi(11)
                public boolean onQueryTextSubmit(String query) {
                  mSearchView.clearFocus();
                  Intent intent = getExplorer().getIntent();
                  if (intent == null) intent = new Intent();
                  intent.setAction(Intent.ACTION_SEARCH);
                  Bundle appData = new Bundle();
                  appData.putString(
                      "path", getExplorer().getDirContentFragment(false).getPath().getPath());
                  intent.putExtra(SearchManager.APP_DATA, appData);
                  intent.putExtra(SearchManager.QUERY, query);
                  getExplorer().handleIntent(intent);
                  return true;
                }

                public boolean onQueryTextChange(String newText) {
                  return false;
                }
              });
      } catch (NullPointerException e) {
        Logger.LogError("Couldn't set up Search ActionView", e);
      }
    }
  }
  @Override
  public void onPrepareOptionsMenu(Menu menu) {
    // Logger.LogVerbose("ContentFragment.onPrepareOptionsMenu");
    if (getActivity() == null) return;
    if (menu == null) return;
    if (!isAdded() || isDetached() || !isVisible()) return;
    super.onPrepareOptionsMenu(menu);
    if (OpenExplorer.BEFORE_HONEYCOMB)
      MenuUtils.setMenuVisible(menu, false, R.id.menu_view_carousel);

    switch (getSorting().getType()) {
      case ALPHA:
        MenuUtils.setMenuChecked(menu, true, R.id.menu_sort_name_asc);
        break;
      case ALPHA_DESC:
        MenuUtils.setMenuChecked(menu, true, R.id.menu_sort_name_desc);
        break;
      case DATE:
        MenuUtils.setMenuChecked(menu, true, R.id.menu_sort_date_asc);
        break;
      case DATE_DESC:
        MenuUtils.setMenuChecked(menu, true, R.id.menu_sort_date_desc);
        break;
      case SIZE:
        MenuUtils.setMenuChecked(menu, true, R.id.menu_sort_size_asc);
        break;
      case SIZE_DESC:
        MenuUtils.setMenuChecked(menu, true, R.id.menu_sort_size_desc);
        break;
      case TYPE:
        MenuUtils.setMenuChecked(menu, true, R.id.menu_sort_type);
        break;
    }

    MenuUtils.setMenuChecked(menu, mFoldersFirst, R.id.menu_sort_folders_first);

    if (OpenExplorer.BEFORE_HONEYCOMB && menu.findItem(R.id.menu_multi) != null)
      menu.findItem(R.id.menu_multi).setIcon(null);

    // if(menu.findItem(R.id.menu_context_unzip) != null && getClipboard().getCount() == 0)
    //	menu.findItem(R.id.menu_context_unzip).setVisible(false);

    if (getClipboard() == null || getClipboard().size() == 0) {
      MenuUtils.setMenuVisible(menu, false, R.id.content_paste);
    } else {
      MenuItem mPaste = menu.findItem(R.id.content_paste);
      if (mPaste != null && getClipboard() != null && !isDetached())
        mPaste.setTitle(getString(R.string.s_menu_paste) + " (" + getClipboard().size() + ")");
      if (getClipboard().isMultiselect()) {
        LayerDrawable d =
            (LayerDrawable) getResources().getDrawable(R.drawable.ic_menu_paste_multi);
        d.getDrawable(1).setAlpha(127);
        if (menu.findItem(R.id.content_paste) != null) menu.findItem(R.id.content_paste).setIcon(d);
      }
      if (mPaste != null) mPaste.setVisible(true);
    }

    MenuUtils.setMenuChecked(
        menu, true, R.id.menu_view_carousel, R.id.menu_view_grid, R.id.menu_view_list);

    MenuUtils.setMenuChecked(menu, getShowHiddenFiles(), R.id.menu_view_hidden);
    MenuUtils.setMenuVisible(menu, false, R.id.menu_view_thumbs);
    MenuUtils.setMenuVisible(menu, !OpenExplorer.BEFORE_HONEYCOMB, R.id.menu_view_carousel);

    // if(RootManager.Default.isRoot()) MenuUtils.setMenuChecked(menu, true, R.id.menu_root);
  }