Esempio n. 1
0
  @Override
  protected void onRestart() {
    super.onRestart();
    new Thread() {
      @Override
      public void run() {

        if (selectedCategory != null) {
          if (selectedCategory.equalsIgnoreCase("all notes")) {
            mNoteList = mDbHelper.queryAll();
          } else {
            mNoteList = mDbHelper.queryNoteByCategory(selectedCategory);
          }
        } else {
          mNoteList = mDbHelper.queryAll();
        }

        sortOrder();

        mCategoryList = mDbHelper.queryAllCategory();
        Collections.sort(mCategoryList, String.CASE_INSENSITIVE_ORDER);
        runOnUiThread(
            new Runnable() {
              @Override
              public void run() {
                mAdapter.notifyDataSetChanged();
                mCategoryAdapter.notifyDataSetChanged();
              }
            });
      }
    }.start();

    mSearchView.setQuery("", true);
  }
Esempio n. 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();
  }
Esempio n. 3
0
 /**
  * 展开SearchView进行查询
  *
  * @param key
  */
 private void search(String key) {
   if (!TextUtils.isEmpty(key)) {
     MenuItemCompat.expandActionView(searchMenuItem);
     searchView.setQuery(key, true);
     saveSearchHistory(key);
   }
 }
  /**
   * *********************************************************************************************
   */
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_search, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    searchView.setSubmitButtonEnabled(true);
    searchView.setQuery(searchText, true);
    searchView.setIconifiedByDefault(false);
    searchView.setQueryHint("Search Images ..");

    SearchView.OnQueryTextListener textChangeListener =
        new SearchView.OnQueryTextListener() {
          @Override
          public boolean onQueryTextChange(String newText) {

            return true;
          }

          @Override
          public boolean onQueryTextSubmit(String queryValue) {
            searchText = queryValue;
            currentPage = 1;
            imageItemList.clear();
            imageItemAdapter.notifyDataSetChanged();
            refreshItems(currentPage);
            return true;
          }
        };
    searchView.setOnQueryTextListener(textChangeListener);
    return true;
  }
  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;
  }
  /**
   * Use this in method onPrepareOptionsMenu
   *
   * @param searchView SearchView to return state
   */
  public void setPreviousState(SearchView searchView) {
    if (hasFocus) {
      searchView.setQuery(searchQuery, false);
      searchView.setIconified(false);

      searchQuery = "";
      hasFocus = false;
    }
    this.searchView = searchView;
  }
 @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
 @Override
 public boolean onQueryTextSubmit(String query) {
   InputMethodManager imm =
       (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
   imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0);
   searchView.setQuery("", false);
   searchView.setIconified(false);
   Toast.makeText(getApplicationContext(), "search 결과", Toast.LENGTH_LONG).show();
   return false;
 }
Esempio n. 8
0
  private void performSearch(String query) {
    if (searchMenuItem == null) {
      // Store this for later when we do actually have a search menu ready to use.
      pendingSearchQuery = query;
      return;
    }

    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
    MenuItemCompat.expandActionView(searchMenuItem);
    searchView.setQuery(query, true);
  }
Esempio n. 9
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.carte, menu);
    final SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setQuery(currentSearch, false);
    final SearchInMarkers search = new SearchInMarkers(this.markersQueryResources);
    searchView.setOnQueryTextListener(
        new OnQueryTextListener() {

          @Override
          public boolean onQueryTextSubmit(String arg0) {
            return false;
          }

          @Override
          public boolean onQueryTextChange(String arg0) {
            suggestions = search.contains(arg0);
            markerSearchResultsList.setVisibility(View.VISIBLE);
            currentResults = new ArrayList<MarkerOptions>();
            for (int i = 0; i < markersOptions.size(); i++) {
              if (suggestions.contains(i)) {
                MarkerOptions m = markersOptions.get(i);
                currentResults.add(m);
              }
            }
            if (suggestions.isEmpty()) {
              emptyList.setVisibility(View.VISIBLE);
            }
            markerSearchResultsList.setAdapter(
                new MarkerSearchListAdapter(
                    Carte.this, R.layout.marker_search_item, currentResults));
            return true;
          }
        });
    searchView.setOnCloseListener(
        new OnCloseListener() {
          @Override
          public boolean onClose() {
            markerSearchResultsList.setVisibility(View.GONE);
            emptyList.setVisibility(View.GONE);
            return false;
          }
        });
    return super.onCreateOptionsMenu(menu);
  }
Esempio n. 10
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();
  }
 public void search(String query) {
   if (mSearchView != null && mSearchItem != null) {
     MenuItemCompat.expandActionView(mSearchItem);
     mSearchView.setQuery(query, true);
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_videoitem_list);
    StreamingService streamingService = null;

    View bg = findViewById(R.id.mainBG);
    bg.setVisibility(View.VISIBLE);

    try {
      // ------ todo: remove this line when multiservice support is implemented ------
      currentStreamingServiceId = ServiceList.getIdOfService("Youtube");
      streamingService = ServiceList.getService(currentStreamingServiceId);
    } catch (Exception e) {
      e.printStackTrace();
      ErrorActivity.reportError(
          VideoItemListActivity.this,
          e,
          null,
          findViewById(R.id.videoitem_list),
          ErrorActivity.ErrorInfo.make(
              ErrorActivity.SEARCHED,
              ServiceList.getNameOfService(currentStreamingServiceId),
              "",
              R.string.general_error));
    }
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    listFragment =
        (VideoItemListFragment) getSupportFragmentManager().findFragmentById(R.id.videoitem_list);
    listFragment.setStreamingService(streamingService);

    if (savedInstanceState != null && mode != PRESENT_VIDEOS_MODE) {
      searchQuery = savedInstanceState.getString(QUERY);
      currentStreamingServiceId = savedInstanceState.getInt(STREAMING_SERVICE);
      if (!searchQuery.isEmpty()) {
        listFragment.search(searchQuery);
      }
    }

    if (findViewById(R.id.videoitem_detail_container) != null) {
      // The detail container view will be present only in the
      // large-screen layouts (res/values-large and
      // res/values-sw600dp). If this view is present, then the
      // activity should be in two-pane mode.
      mTwoPane = true;

      // In two-pane mode, list items should be given the
      // 'activated' state when touched.

      ((VideoItemListFragment) getSupportFragmentManager().findFragmentById(R.id.videoitem_list))
          .setActivateOnItemClick(true);

      SearchView searchView = (SearchView) findViewById(R.id.searchViewTablet);
      if (mode != PRESENT_VIDEOS_MODE) {
        // Somehow the seticonifiedbydefault property set by the layout xml is not working on
        // the support version on SearchView, so it needs to be set programmatically.
        searchView.setIconifiedByDefault(false);
        searchView.setIconified(false);
        if (!searchQuery.isEmpty()) {
          searchView.setQuery(searchQuery, false);
        }
        searchView.setOnQueryTextListener(new SearchVideoQueryListener());
        suggestionListAdapter = new SuggestionListAdapter(this);
        searchView.setSuggestionsAdapter(suggestionListAdapter);
        searchView.setOnSuggestionListener(new SearchSuggestionListener(searchView));
      } else {
        searchView.setVisibility(View.GONE);
      }
    }

    PreferenceManager.setDefaultValues(this, R.xml.settings, false);
  }
 @Override
 public boolean onSuggestionClick(int position) {
   String suggestion = suggestionListAdapter.getSuggestion(position);
   searchView.setQuery(suggestion, true);
   return false;
 }