public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    this.menu = menu;
    MenuInflater inflater = getMenuInflater();
    if (mode != PRESENT_VIDEOS_MODE && findViewById(R.id.videoitem_detail_container) == null) {
      inflater.inflate(R.menu.videoitem_list, menu);
      MenuItem searchItem = menu.findItem(R.id.action_search);
      SearchView searchView = (SearchView) searchItem.getActionView();
      searchView.setFocusable(false);
      searchView.setOnQueryTextListener(new SearchVideoQueryListener());
      suggestionListAdapter = new SuggestionListAdapter(this);
      searchView.setSuggestionsAdapter(suggestionListAdapter);
      searchView.setOnSuggestionListener(new SearchSuggestionListener(searchView));
      if (!searchQuery.isEmpty()) {
        searchView.setQuery(searchQuery, false);
        searchView.setIconifiedByDefault(false);
      }
    } else if (videoFragment != null) {
      videoFragment.onCreateOptionsMenu(menu, inflater);
    } else {
      inflater.inflate(R.menu.videoitem_two_pannel, menu);
    }

    return true;
  }
 /**
  * Callback method from {@link VideoItemListFragment.Callbacks} indicating that the item with the
  * given ID was selected.
  */
 @Override
 public void onItemSelected(String id) {
   VideoListAdapter listAdapter =
       (VideoListAdapter)
           ((VideoItemListFragment)
                   getSupportFragmentManager().findFragmentById(R.id.videoitem_list))
               .getListAdapter();
   String webpageUrl = listAdapter.getVideoList().get((int) Long.parseLong(id)).webpage_url;
   if (mTwoPane) {
     // In two-pane mode, show the detail view in this activity by
     // adding or replacing the detail fragment using a
     // fragment transaction.
     Bundle arguments = new Bundle();
     // arguments.putString(VideoItemDetailFragment.ARG_ITEM_ID, id);
     arguments.putString(VideoItemDetailFragment.VIDEO_URL, webpageUrl);
     arguments.putInt(VideoItemDetailFragment.STREAMING_SERVICE, currentStreamingServiceId);
     videoFragment = new VideoItemDetailFragment();
     videoFragment.setArguments(arguments);
     videoFragment.setOnInvokeCreateOptionsMenuListener(
         new VideoItemDetailFragment.OnInvokeCreateOptionsMenuListener() {
           @Override
           public void createOptionsMenu() {
             menu.clear();
             onCreateOptionsMenu(menu);
           }
         });
     getSupportFragmentManager()
         .beginTransaction()
         .replace(R.id.videoitem_detail_container, videoFragment)
         .commit();
   } else {
     // In single-pane mode, simply start the detail activity
     // for the selected item ID.
     Intent detailIntent = new Intent(this, VideoItemDetailActivity.class);
     // detailIntent.putExtra(VideoItemDetailFragment.ARG_ITEM_ID, id);
     detailIntent.putExtra(VideoItemDetailFragment.VIDEO_URL, webpageUrl);
     detailIntent.putExtra(VideoItemDetailFragment.STREAMING_SERVICE, currentStreamingServiceId);
     startActivity(detailIntent);
   }
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    switch (id) {
      case android.R.id.home:
        {
          Intent intent = new Intent(this, VideoItemListActivity.class);
          intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
          NavUtils.navigateUpTo(this, intent);
          return true;
        }
      case R.id.action_settings:
        {
          Intent intent = new Intent(this, SettingsActivity.class);
          startActivity(intent);
          return true;
        }
      case R.id.action_report_error:
        {
          ErrorActivity.reportError(
              VideoItemListActivity.this,
              new Vector<Exception>(),
              null,
              null,
              ErrorActivity.ErrorInfo.make(
                  ErrorActivity.USER_REPORT,
                  ServiceList.getNameOfService(currentStreamingServiceId),
                  "user_report",
                  R.string.user_report));
          return true;
        }
      case R.id.action_show_downloads:
        {
          Intent intent = new Intent(this, org.schabi.newpipe.download.MainActivity.class);
          startActivity(intent);
          return true;
        }
      default:
        return videoFragment.onOptionsItemSelected(item) || super.onOptionsItemSelected(item);
    }
  }