Пример #1
0
 public boolean onKeyPreIme(int i1, KeyEvent keyevent)
 {
     if (i1 == 4)
     {
         if (keyevent.getAction() == 0 && keyevent.getRepeatCount() == 0)
         {
             android.view.KeyEvent.DispatcherState dispatcherstate = getKeyDispatcherState();
             if (dispatcherstate != null)
             {
                 dispatcherstate.startTracking(keyevent, this);
             }
             return true;
         }
         if (keyevent.getAction() == 1)
         {
             android.view.KeyEvent.DispatcherState dispatcherstate1 = getKeyDispatcherState();
             if (dispatcherstate1 != null)
             {
                 dispatcherstate1.handleUpEvent(keyevent);
             }
             if (keyevent.isTracking() && !keyevent.isCanceled())
             {
                 b.clearFocus();
                 android.support.v7.widget.SearchView.a(b, false);
                 return true;
             }
         }
     }
     return super.onKeyPreIme(i1, keyevent);
 }
Пример #2
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_words, menu);

    MenuItem searchMenuItem = menu.findItem(R.id.action_search);
    MenuItemCompat.setOnActionExpandListener(
        searchMenuItem,
        new MenuItemCompat.OnActionExpandListener() {
          @Override
          public boolean onMenuItemActionExpand(MenuItem item) {
            return true;
          }

          @Override
          public boolean onMenuItemActionCollapse(MenuItem item) {
            updateData();
            return true;
          }
        });

    mSearchView = (SearchView) searchMenuItem.getActionView();
    mSearchView.setQueryHint(getString(R.string.search_hint));

    if (mFilterText != null) {
      String query = mFilterText;
      searchMenuItem.expandActionView();
      mSearchView.setQuery(query, true);
      mSearchView.clearFocus();
    }
    setSearchViewTextChangeListener();
  }
Пример #3
0
  /** Called by {@link #searchView} when text is changing */
  @Override
  public boolean onQueryTextSubmit(String query) {

    if (!isSearchRequestApplicable(query)) return true;
    showSubmitButton(false);
    searchView.clearFocus();
    // create new fragment and add it to this Activity
    replaceFragment(PhotoListFragment.newInstance(query), true);
    return true;
  }
Пример #4
0
  public void hideInputManager() {
    if (mSearchView != null) {
      if (mImm != null) {
        mImm.hideSoftInputFromWindow(mSearchView.getWindowToken(), 0);
      }
      mSearchView.clearFocus();

      SearchHistory.getInstance(this).addSearchString(queryString);
    }
  }
Пример #5
0
  @Override
  protected void onResume() {

    // clear initial focus on searchView
    searchView.post(
        () -> {
          if (searchView != null) {
            searchView.clearFocus();
          }
        });
    super.onResume();
  }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    // Setup search button
    mSearchItem = menu.findItem(R.id.m_search);
    mSearchView = (SearchView) mSearchItem.getActionView();
    mSearchView.setIconifiedByDefault(true);

    mSearchView.setOnQueryTextListener(
        new SearchView.OnQueryTextListener() {
          @Override
          public boolean onQueryTextSubmit(String query) {
            filter(query);
            mSearchView.clearFocus();
            return true;
          }

          @Override
          public boolean onQueryTextChange(String newText) {
            mFilterText = newText;
            filter(newText);
            return true;
          }
        });
    MenuItemCompat.setOnActionExpandListener(
        mSearchItem,
        new MenuItemCompat.OnActionExpandListener() {
          @Override
          public boolean onMenuItemActionCollapse(MenuItem item) {
            filter(null);
            return true; // Return true to collapse action view
          }

          @Override
          public boolean onMenuItemActionExpand(MenuItem item) {
            return true; // Return true to expand action view
          }
        });
    if (mPreviousQuery != null && !mPreviousQuery.isEmpty()) {
      search(mPreviousQuery);
      filter(mPreviousQuery);
      mSearchView.clearFocus();
    }
  }
Пример #7
0
 @Override
 public void onBackPressed() {
   Log.d(TAG, "onBackPressed()");
   if (!searchView.isIconified()) {
     Log.d(TAG, "Search view is active");
     searchView.setIconified(true);
     searchView.clearFocus();
     return;
   }
   getMainActivity().closeCurrentFragment();
   //        ProgressDialogFragment progressDialog = ProgressDialogFragment.newInstance(
   //                getResources().getString(R.string.dialog_wait_title),
   //                getResources().getString(R.string.remove_album_wait_message,
   // createdAlbum.getTitle())
   //        );
   //        progressDialog.show(getFragmentManager(), ProgressDialogFragment.TAG);
   //        DataManager.removeAlbumFromNet(createdAlbum, new VKRequest.VKRequestListener() {
   //            @Override
   //            public void onComplete(VKResponse response) {
   //                Otto.post(new AlbumDeletedEvent(createdAlbum));
   //                getFragmentManager().beginTransaction()
   //
   // .remove(getFragmentManager().findFragmentByTag(ProgressDialogFragment.TAG))
   //                        .commit();
   //                getMainActivity().closeCurrentFragment();
   //            }
   //
   //            @Override
   //            public void onError(VKError error) {
   //                getFragmentManager().beginTransaction()
   //
   // .remove(getFragmentManager().findFragmentByTag(ProgressDialogFragment.TAG))
   //                        .commit();
   //                getMainActivity().closeCurrentFragment();
   //            }
   //        });
 }
Пример #8
0
  /**
   * Update text at searchView
   *
   * @param request - string that should replace the current one
   */
  public void setSearchRequest(String request) {

    if (searchView == null) return;
    searchView.setQuery(request, false);
    searchView.clearFocus();
  }
 @Override
 public void doThis() {
   searchView.clearFocus();
 }