List of usage examples for android.app SearchManager SUGGEST_COLUMN_TEXT_1
String SUGGEST_COLUMN_TEXT_1
To view the source code for android.app SearchManager SUGGEST_COLUMN_TEXT_1.
Click Source Link
From source file:fr.eoidb.activity.MarketGroupItemListActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (id == LOADER_ID) { return new CursorLoader(this, getIntent().getData(), new String[] { Item._ID, Item.COLUMN_NAME_NAME }, null, null, null);//from ww w. j av a 2 s .c o m } else if (id == SEARCH_LOADER_ID) { return new CursorLoader(this, Item.CONTENT_URI_SEARCH, new String[] { Item._ID, SearchManager.SUGGEST_COLUMN_TEXT_1 }, null, new String[] { query }, SearchManager.SUGGEST_COLUMN_TEXT_1); } else { return null; } }
From source file:fr.eoidb.activity.ItemAttributesListActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (id == LOADER_ID) { return new CursorLoader(this, getIntent().getData(), new String[] { ColumnsNames.AttibuteType._ID, ColumnsNames.AttibuteType.COLUMN_NAME_NAME, ColumnsNames.AttibuteType.COLUMN_NAME_ICON_ID, ColumnsNames.TypeAttibutes.COLUMN_NAME_VALUE_FLOAT, ColumnsNames.TypeAttibutes.COLUMN_NAME_VALUE_FLOAT, "eu." + ColumnsNames.EveUnits.COLUMN_NAME_NAME + " AS " + ColumnsNames.EveUnits.NAME_ALIAS }, null, null, null);//from w w w . j a v a 2s .com } else if (id == SEARCH_LOADER_ID) { return new CursorLoader(this, Item.CONTENT_URI_SEARCH, new String[] { Item._ID, SearchManager.SUGGEST_COLUMN_TEXT_1 }, null, new String[] { query }, SearchManager.SUGGEST_COLUMN_TEXT_1); } else { return null; } }
From source file:com.ibm.commerce.worklight.android.search.SearchSuggestionsProvider.java
/** * Performs the search by projections and selection arguments * @param uri The URI to be used// ww w . jav a 2s .com * @param projection The string array for the search * @param selection The selection string * @param selectionArgs The selection arguments * @param sortOrder The sort order * @return The cursor containing the suggestions */ @Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { final String METHOD_NAME = CLASS_NAME + ".query()"; boolean loggingEnabled = Log.isLoggable(LOG_TAG, Log.DEBUG); if (loggingEnabled) { Log.d(METHOD_NAME, "ENTRY"); } int id = 1; MatrixCursor suggestionCursor = new MatrixCursor(COLUMNS); Cursor recentSearchCursor = null; try { recentSearchCursor = super.query(uri, projection, selection, selectionArgs, sortOrder); // get search history if (recentSearchCursor != null) { int searchTermIndex = recentSearchCursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1); while (recentSearchCursor.moveToNext() && id <= MAX_RECENT_TERM) { suggestionCursor.addRow(createRecentRow(id, recentSearchCursor.getString(searchTermIndex))); id++; } } } finally { if (recentSearchCursor != null) { recentSearchCursor.close(); recentSearchCursor = null; } } // get search suggestion if (selectionArgs[0] != null && !selectionArgs[0].equals("")) { List<String> suggestionList = getSearchTermSuggestions(selectionArgs[0]); if (suggestionList != null) { for (String aSuggestion : suggestionList) { suggestionCursor.addRow(createSuggestionRow(id, aSuggestion)); id++; } } } if (loggingEnabled) { Log.d(METHOD_NAME, "EXIT"); } return suggestionCursor; }
From source file:fr.matthiasbosc.translucentmap.PlaceProvider.java
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { Cursor c = null;//from w ww . ja va 2 s . c om PlaceJSONParser parser = new PlaceJSONParser(); PlaceDetailsJSONParser detailsParser = new PlaceDetailsJSONParser(); String jsonString = ""; String jsonPlaceDetails = ""; List<HashMap<String, String>> list = null; List<HashMap<String, String>> detailsList = null; MatrixCursor mCursor = null; switch (mUriMatcher.match(uri)) { case SEARCH: // Defining a cursor object with columns description, lat and lng mCursor = new MatrixCursor(new String[] { "description", "lat", "lng" }); // Create a parser object to parse places in JSON format parser = new PlaceJSONParser(); // Create a parser object to parse place details in JSON format detailsParser = new PlaceDetailsJSONParser(); // Get Places from Google Places API jsonString = getPlaces(selectionArgs); try { // Parse the places ( JSON => List ) list = parser.parse(new JSONObject(jsonString)); // Finding latitude and longitude for each places using Google Places Details API for (int i = 0; i < list.size(); i++) { HashMap<String, String> hMap = (HashMap<String, String>) list.get(i); detailsParser = new PlaceDetailsJSONParser(); // Get Place details jsonPlaceDetails = getPlaceDetails(hMap.get("reference")); // Parse the details ( JSON => List ) detailsList = detailsParser.parse(new JSONObject(jsonPlaceDetails)); // Creating cursor object with places for (int j = 0; j < detailsList.size(); j++) { HashMap<String, String> hMapDetails = detailsList.get(j); // Adding place details to cursor mCursor.addRow(new String[] { hMap.get("description"), hMapDetails.get("lat"), hMapDetails.get("lng") }); } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } c = mCursor; break; case SUGGESTIONS: // Defining a cursor object with columns id, SUGGEST_COLUMN_TEXT_1, SUGGEST_COLUMN_INTENT_EXTRA_DATA mCursor = new MatrixCursor(new String[] { "_id", SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA }); // Creating a parser object to parse places in JSON format parser = new PlaceJSONParser(); // Get Places from Google Places API jsonString = getPlaces(selectionArgs); try { // Parse the places ( JSON => List ) list = parser.parse(new JSONObject(jsonString)); // Creating cursor object with places for (int i = 0; i < list.size(); i++) { HashMap<String, String> hMap = (HashMap<String, String>) list.get(i); // Adding place details to cursor mCursor.addRow( new String[] { Integer.toString(i), hMap.get("description"), hMap.get("reference") }); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } c = mCursor; break; case DETAILS: // Defining a cursor object with columns description, lat and lng mCursor = new MatrixCursor(new String[] { "description", "lat", "lng" }); detailsParser = new PlaceDetailsJSONParser(); jsonPlaceDetails = getPlaceDetails(selectionArgs[0]); try { detailsList = detailsParser.parse(new JSONObject(jsonPlaceDetails)); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } for (int j = 0; j < detailsList.size(); j++) { HashMap<String, String> hMapDetails = detailsList.get(j); mCursor.addRow(new String[] { hMapDetails.get("formatted_address"), hMapDetails.get("lat"), hMapDetails.get("lng") }); } c = mCursor; break; } return c; }
From source file:fr.eoidb.activity.MarketGroupListActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (id == LOADER_ID) { return new CursorLoader(this, getIntent().getData(), new String[] { MarketGroups._ID, MarketGroups.COLUMN_NAME_NAME, MarketGroups.COLUMN_NAME_DESCRIPTION, MarketGroups.COLUMN_NAME_ICON_ID, MarketGroups.COLUMN_NAME_HAS_TYPE }, marketGroupId == -1 ? MarketGroups.COLUMN_NAME_PARENT_ID + " IS NULL" : null, null, null); } else if (id == SEARCH_LOADER_ID) { return new CursorLoader(this, Item.CONTENT_URI_SEARCH, new String[] { Item._ID, SearchManager.SUGGEST_COLUMN_TEXT_1 }, null, new String[] { query }, SearchManager.SUGGEST_COLUMN_TEXT_1); } else {/*from w w w . jav a2 s. c o m*/ return null; } }
From source file:fr.eoit.activity.ItemListActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (id == FAVORITE_LOADER_ID) { return new CursorLoader(this, getIntent().getData(), new String[] { Item._ID, Item.COLUMN_NAME_NAME, Item.COLUMN_NAME_VOLUME, Item.COLUMN_NAME_CHOSEN_PRICE_ID, Prices.COLUMN_NAME_BUY_PRICE, Prices.COLUMN_NAME_SELL_PRICE, Prices.COLUMN_NAME_PRODUCE_PRICE, Prices.COLUMN_NAME_OWN_PRICE, ColumnsNames.Categories.COLUMN_NAME_NAME_ALIAS }, Item.COLUMN_NAME_FAVORITE + " = 1", null, AmazingSimpleCursorAdapter.getOrderByQuery(orderType)); } else if (id == SEARCH_LOADER_ID) { return new CursorLoader(this, Item.CONTENT_URI_SEARCH, new String[] { Item._ID, SearchManager.SUGGEST_COLUMN_TEXT_1 }, null, new String[] { query }, SearchManager.SUGGEST_COLUMN_TEXT_1); } else {/* w w w . j a v a 2s. com*/ return null; } }
From source file:au.com.cybersearch2.classyfy.MainActivityTest.java
public void test_search() throws Throwable { final MainActivity mainActivity = getActivity(); Instrumentation instrumentation = getInstrumentation(); ActivityMonitor am = instrumentation.addMonitor(TitleSearchResultsActivity.class.getName(), null, false); assertThat(instrumentation.invokeMenuActionSync(mainActivity, R.id.action_search, 0)).isTrue(); ActionBar actionBar = mainActivity.getSupportActionBar(); assertThat(actionBar).isNotNull();/*from ww w . j ava 2s . co m*/ final FragmentManager sfm = mainActivity.getSupportFragmentManager(); runTestOnUiThread(new Runnable() { public void run() { sfm.executePendingTransactions(); } }); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_I); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_N); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_F); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_ENTER); runTestOnUiThread(new Runnable() { public void run() { sfm.executePendingTransactions(); } }); TitleSearchResultsActivity titleSearchResultsActivity = (TitleSearchResultsActivity) getInstrumentation() .waitForMonitorWithTimeout(am, 10000); assertThat(titleSearchResultsActivity).isNotNull(); assertThat(titleSearchResultsActivity.taskHandle).isNotNull(); synchronized (titleSearchResultsActivity.taskHandle) { titleSearchResultsActivity.taskHandle.wait(10000); } assertThat(titleSearchResultsActivity.taskHandle.getStatus()).isEqualTo(WorkStatus.FINISHED); SimpleCursorAdapter adapter = titleSearchResultsActivity.adapter; for (int i = 0; i < adapter.getCount(); i++) { Cursor cursor = (Cursor) adapter.getItem(i); int column = cursor.getColumnIndexOrThrow(SearchManager.SUGGEST_COLUMN_TEXT_1); assertThat(INF_LIST[i]).isEqualTo(cursor.getString(column)); } }
From source file:com.teocci.utubinbg.MainActivity.java
/** * Options menu in action bar//from w ww . j av a2 s . co m * * @param menu * @return */ @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); MenuItem searchItem = menu.findItem(R.id.action_search); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); if (searchView != null) { searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); } //suggestions final CursorAdapter suggestionAdapter = new SimpleCursorAdapter(this, R.layout.dropdown_menu, null, new String[] { SearchManager.SUGGEST_COLUMN_TEXT_1 }, new int[] { android.R.id.text1 }, 0); final List<String> suggestions = new ArrayList<>(); searchView.setSuggestionsAdapter(suggestionAdapter); searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int position) { return false; } @Override public boolean onSuggestionClick(int position) { searchView.setQuery(suggestions.get(position), false); searchView.clearFocus(); Intent suggestionIntent = new Intent(Intent.ACTION_SEARCH); suggestionIntent.putExtra(SearchManager.QUERY, suggestions.get(position)); handleIntent(suggestionIntent); return true; } }); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String s) { return false; //if true, no new intent is started } @Override public boolean onQueryTextChange(String suggestion) { // check network connection. If not available, do not query. // this also disables onSuggestionClick triggering if (suggestion.length() > 2) { //make suggestions after 3rd letter if (networkConf.isNetworkAvailable()) { new JsonAsyncTask(new JsonAsyncTask.AsyncResponse() { @Override public void processFinish(ArrayList<String> result) { suggestions.clear(); suggestions.addAll(result); String[] columns = { BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1 }; MatrixCursor cursor = new MatrixCursor(columns); for (int i = 0; i < result.size(); i++) { String[] tmp = { Integer.toString(i), result.get(i) }; cursor.addRow(tmp); } suggestionAdapter.swapCursor(cursor); } }).execute(suggestion); return true; } } return false; } }); return true; }
From source file:com.aboveware.sms.contacts.ContactSuggestionsAdapter.java
/** * Cache columns.//w w w. j av a2 s.c o m */ @SuppressLint("InlinedApi") @Override public void changeCursor(Cursor c) { if (DBG) Log.d(LOG_TAG, "changeCursor(" + c + ")"); if (mClosed) { Log.w(LOG_TAG, "Tried to change cursor after adapter was closed."); if (c != null) c.close(); return; } try { super.changeCursor(c); if (c != null) { mText1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1); mText2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2); mText2UrlCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2_URL); c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_1); mIconName2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_2); mFlagsCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_FLAGS); } } catch (Exception e) { Log.e(LOG_TAG, "error changing cursor and caching columns", e); } }
From source file:fr.eoit.activity.ItemListActivity.java
private void showResults() { orderType = OrderType.NAME_ALPHA;/* ww w . j a v a 2 s . c o m*/ adapter = new AmazingSimpleCursorAdapter(this, R.layout.row, dataColumnsSearch, viewIDs, SearchManager.SUGGEST_COLUMN_TEXT_1); adapter.setViewBinder(new ItemListViewBinder()); ListView itemListView = (ListView) findViewById(R.id.ITEM_LIST); itemListView.setAdapter(adapter); itemListView.setOnItemClickListener(new ItemOnItemListClickListener()); getSupportLoaderManager().restartLoader(SEARCH_LOADER_ID, null, this); }