@Override
 public boolean onQueryTextSubmit(String query) {
   if (mSearch != null) {
     mSearch.collapseActionView();
     mSearchWidget.setQuery("", false);
   }
   mController.executeSearch(query.trim());
   return true;
 }
 private void showMenuItems(boolean visible) {
   mSearchMenuItem.setVisible(visible);
   mContributorInfoMenuItem.setVisible(mSelectedContributor != -1 && visible);
   mContributionsInfoMenuItem.setVisible(visible);
   if (!visible) {
     mSearchView.setQuery("", false);
     mSearchMenuItem.collapseActionView();
   }
 }
Пример #3
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    productsListFragment =
        (ProductsListFragment) getFragmentManager().findFragmentById(R.id.ProductsListFragment);

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.actionbar, menu);

    itemAdd = menu.findItem(R.id.ItemAdd);
    itemEdit = menu.findItem(R.id.ItemEdit);
    itemDelete = menu.findItem(R.id.ItemDelete);
    itemSearch = menu.findItem(R.id.ItemSearch);
    itemAccept = menu.findItem(R.id.ItemAccept);
    itemCancel = menu.findItem(R.id.ItemCancel);
    searchView = (SearchView) menu.findItem(R.id.ItemSearch).getActionView();
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);

    if (stateEdit) actionbarSetEdit();
    else actionbarSetView();

    if (searchView != null) {

      if (searchState) {
        searchView.setQuery(search, true);
        searchView.setFocusable(true);
        searchView.setIconified(false);
        searchView.requestFocusFromTouch();
        // productsListFragment.showList(true, search);

        itemSearch.collapseActionView();
      }
      searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    }

    SearchView.OnQueryTextListener queryTextListener =
        new SearchView.OnQueryTextListener() {
          public boolean onQueryTextChange(String newText) {
            searchState = true;
            search = newText.trim();
            productsListFragment.showList(true, search);
            return true;
          }

          public boolean onQueryTextSubmit(String query) {
            searchState = true;
            search = query.trim();
            productsListFragment.showList(true, search);
            return true;
          }
        };

    searchView.setOnQueryTextListener(queryTextListener);
    return super.onCreateOptionsMenu(menu);
    //    return true;
  }
Пример #4
0
 @Override
 public boolean onQueryTextSubmit(String newQuery) {
   newQuery = newQuery.trim();
   GameCache newCache =
       new GameCache(newQuery + " Search Result Cache"); // clear cache, new search
   RetrieveSearchResultsTask newTask =
       new RetrieveSearchResultsTask(this, list, newCache, newQuery);
   newTask.execute();
   searchItem.collapseActionView();
   return true;
 }
Пример #5
0
 @Override
 public void onLoadFinished(Loader<List<OrgInfoModel>> loader, List<OrgInfoModel> data) {
   mProgressDialog.dismiss();
   mData = data;
   mAdapter.setData(mData);
   mSwipeLayout.setRefreshing(false);
   if (searchItem.isActionViewExpanded()) {
     searchItem.collapseActionView();
   }
   Log.d(Constants.TAG, "MainActivity onLoadFinished");
 }
 @Override
 public void onBackPressed() {
   if (actionModeEnabled) {
     actionMode.finish();
   } else if (menu != null) {
     MenuItem searchItem = menu.findItem(R.id.search_button);
     SearchView searchView = (SearchView) searchItem.getActionView();
     if (!searchView.isIconified()) {
       searchItem.collapseActionView();
     } else {
       super.onBackPressed();
     }
   }
 }
Пример #7
0
  private void closeSearchBar() {

    // Remove custom view.
    getActionBar().setDisplayShowCustomEnabled(false);

    // close the soft keyboard
    mSearchEt.clearFocus();
    mSearchAction.collapseActionView();
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(mSearchEt.getWindowToken(), 0);
    mSearchEt.setText("");

    // Change search icon accordingly.
    mSearchAction.setIcon(mIconOpenSearch);
    mSearchOpened = false;
  }
Пример #8
0
 @Override
 public boolean collapseActionView() {
   return mNativeItem.collapseActionView();
 }
 private void onContributorSelected(ContributorsDataHolder contributor) {
   mSelectedContributor = contributor.mId;
   ContributorCloudLoaderTask task = new ContributorCloudLoaderTask(true, true);
   task.execute();
   mSearchMenuItem.collapseActionView();
 }
 public void collapseFilter() {
   if (miFilter != null) {
     miFilter.collapseActionView();
   }
 }
Пример #11
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    final FragmentManager fm = getFragmentManager();

    final RootInfo root = getCurrentRoot();
    final DocumentInfo cwd = getCurrentDirectory();

    final MenuItem createDir = menu.findItem(R.id.menu_create_dir);
    final MenuItem search = menu.findItem(R.id.menu_search);
    final MenuItem sort = menu.findItem(R.id.menu_sort);
    final MenuItem sortSize = menu.findItem(R.id.menu_sort_size);
    final MenuItem grid = menu.findItem(R.id.menu_grid);
    final MenuItem list = menu.findItem(R.id.menu_list);
    final MenuItem advanced = menu.findItem(R.id.menu_advanced);
    final MenuItem fileSize = menu.findItem(R.id.menu_file_size);

    sort.setVisible(cwd != null);
    grid.setVisible(mState.derivedMode != MODE_GRID);
    list.setVisible(mState.derivedMode != MODE_LIST);

    if (mState.currentSearch != null) {
      // Search uses backend ranking; no sorting
      sort.setVisible(false);

      search.expandActionView();

      mSearchView.setIconified(false);
      mSearchView.clearFocus();
      mSearchView.setQuery(mState.currentSearch, false);
    } else {
      mIgnoreNextClose = true;
      mSearchView.setIconified(true);
      mSearchView.clearFocus();

      mIgnoreNextCollapse = true;
      search.collapseActionView();
    }

    // Only sort by size when visible
    sortSize.setVisible(mState.showSize);

    final boolean searchVisible;
    if (mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE) {
      createDir.setVisible(cwd != null && cwd.isCreateSupported());
      searchVisible = false;

      // No display options in recent directories
      if (cwd == null) {
        grid.setVisible(false);
        list.setVisible(false);
      }

      if (mState.action == ACTION_CREATE) {
        /// M: add to avoid seldom NullPointerException
        SaveFragment saveFragment = SaveFragment.get(fm);
        if (null != saveFragment) {
          saveFragment.setSaveEnabled(cwd != null && cwd.isCreateSupported());
        } else {
          Log.e(TAG, "onPrepareOptionsMenu, SaveFragment is null");
        }
      }
    } else {
      createDir.setVisible(false);

      searchVisible = root != null && ((root.flags & Root.FLAG_SUPPORTS_SEARCH) != 0);
    }

    // TODO: close any search in-progress when hiding
    search.setVisible(searchVisible);

    advanced.setTitle(
        LocalPreferences.getDisplayAdvancedDevices(this)
            ? R.string.menu_advanced_hide
            : R.string.menu_advanced_show);
    fileSize.setTitle(
        LocalPreferences.getDisplayFileSize(this)
            ? R.string.menu_file_size_hide
            : R.string.menu_file_size_show);

    /// M: If in force show advance mode, need hide advance menu
    advanced.setVisible(mState.action != ACTION_MANAGE && !mState.forceAdvanced);
    /// M: If cmd == null and mState.action == ACTION_CREATE, it means show
    /// RecentsCreateFragment, we need hide file size menu to avoid exception
    fileSize.setVisible(
        mState.action != ACTION_MANAGE && !(cwd == null && mState.action == ACTION_CREATE));

    return true;
  }
 /**
  * Close the search query entry field to avoid keyboard events, and to restore the actionbar to
  * non-search mode.
  */
 private void closeSearchField() {
   if (mSearch == null) {
     return;
   }
   mSearch.collapseActionView();
 }
 /** Close the search view if it is expanded. */
 public void collapseSearch() {
   if (mSearch != null) {
     mSearch.collapseActionView();
   }
 }