List of usage examples for android.database MatrixCursor getString
@Override public String getString(int column)
From source file:com.nextgis.maplibui.control.PhotoGallery.java
public static void getAttaches(IGISApplication app, VectorLayer layer, long featureId, Map<String, Integer> map, boolean excludeSign) { Uri uri = Uri.parse("content://" + app.getAuthority() + "/" + layer.getPath().getName() + "/" + featureId + "/" + Constants.URI_ATTACH); MatrixCursor attachCursor = (MatrixCursor) layer.query(uri, new String[] { VectorLayer.ATTACH_DATA, VectorLayer.ATTACH_ID }, FIELD_ID + " = " + featureId, null, null, null);/* w w w .java2 s .c o m*/ if (attachCursor.moveToFirst()) { do { if (excludeSign && attachCursor.getInt(1) == Integer.MAX_VALUE) continue; map.put(attachCursor.getString(0), attachCursor.getInt(1)); } while (attachCursor.moveToNext()); } attachCursor.close(); }
From source file:com.esri.arcgisruntime.sample.findaddress.MainActivity.java
/** * Sets up the address SearchView. Uses MatrixCursor to show suggestions to the user as the user inputs text. *///from ww w . j a v a 2 s.com private void setupAddressSearchView() { mAddressGeocodeParameters = new GeocodeParameters(); // get place name and address attributes mAddressGeocodeParameters.getResultAttributeNames().add("PlaceName"); mAddressGeocodeParameters.getResultAttributeNames().add("StAddr"); // return only the closest result mAddressGeocodeParameters.setMaxResults(1); mAddressSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String address) { // geocode typed address geoCodeTypedAddress(address); // clear focus from search views mAddressSearchView.clearFocus(); return true; } @Override public boolean onQueryTextChange(String newText) { // as long as newText isn't empty, get suggestions from the locatorTask if (!newText.equals("")) { final ListenableFuture<List<SuggestResult>> suggestionsFuture = mLocatorTask .suggestAsync(newText); suggestionsFuture.addDoneListener(new Runnable() { @Override public void run() { try { // get the results of the async operation List<SuggestResult> suggestResults = suggestionsFuture.get(); MatrixCursor suggestionsCursor = new MatrixCursor(mColumnNames); int key = 0; // add each address suggestion to a new row for (SuggestResult result : suggestResults) { suggestionsCursor.addRow(new Object[] { key++, result.getLabel() }); } // define SimpleCursorAdapter String[] cols = new String[] { COLUMN_NAME_ADDRESS }; int[] to = new int[] { R.id.suggestion_address }; final SimpleCursorAdapter suggestionAdapter = new SimpleCursorAdapter( MainActivity.this, R.layout.suggestion, suggestionsCursor, cols, to, 0); mAddressSearchView.setSuggestionsAdapter(suggestionAdapter); // handle an address suggestion being chosen mAddressSearchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int position) { return false; } @Override public boolean onSuggestionClick(int position) { // get the selected row MatrixCursor selectedRow = (MatrixCursor) suggestionAdapter .getItem(position); // get the row's index int selectedCursorIndex = selectedRow.getColumnIndex(COLUMN_NAME_ADDRESS); // get the string from the row at index String address = selectedRow.getString(selectedCursorIndex); // use clicked suggestion as query mAddressSearchView.setQuery(address, true); return true; } }); } catch (Exception e) { Log.e(TAG, "Geocode suggestion error: " + e.getMessage()); } } }); } return true; } }); }
From source file:com.gsma.rcs.ri.sharing.SharingListView.java
private String getSelectedContact() { MatrixCursor cursor = (MatrixCursor) mSpinner.getSelectedItem(); String contact = cursor.getString(1); if (getString(R.string.label_history_log_contact_spinner_default_value).equals(contact)) { return contact; }/*from w ww .ja va 2 s . c o m*/ return ContactUtil.formatContact(contact).toString(); }
From source file:bf.io.openshop.ux.MainActivity.java
/** * Prepare toolbar search view. Invoke search suggestions and handle search queries. * * @param searchItem corresponding menu item. */// w ww .j a v a2s . co m private void prepareSearchView(@NonNull final MenuItem searchItem) { final SearchView searchView = (SearchView) searchItem.getActionView(); searchView.setSubmitButtonEnabled(true); SearchManager searchManager = (SearchManager) MainActivity.this.getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(MainActivity.this.getComponentName())); SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() { public boolean onQueryTextChange(String newText) { Timber.d("Search query text changed to: %s", newText); showSearchSuggestions(newText, searchView); return false; } public boolean onQueryTextSubmit(String query) { // Submit search query and hide search action view. onSearchSubmitted(query); searchView.setQuery("", false); searchView.setIconified(true); searchItem.collapseActionView(); return true; } }; searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int position) { return false; } @Override public boolean onSuggestionClick(int position) { // Submit search suggestion query and hide search action view. MatrixCursor c = (MatrixCursor) searchSuggestionsAdapter.getItem(position); onSearchSubmitted(c.getString(1)); searchView.setQuery("", false); searchView.setIconified(true); searchItem.collapseActionView(); return true; } }); searchView.setOnQueryTextListener(queryTextListener); }
From source file:com.esri.arcgisruntime.sample.findplace.MainActivity.java
/** * Sets up the proximity SearchView. Uses MatrixCursor to show suggestions to the user as the user inputs text. */// w w w . ja v a2s.c o m private void setupProximity() { mProximitySuggestParameters = new SuggestParameters(); mProximitySuggestParameters.getCategories().add("Populated Place"); mProximityGeocodeParameters = new GeocodeParameters(); // get all attributes mProximityGeocodeParameters.getResultAttributeNames().add("*"); mProximitySearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String address) { geoCodeTypedAddress(address); // clear focus from search views mPoiSearchView.clearFocus(); mProximitySearchView.clearFocus(); return true; } @Override public boolean onQueryTextChange(String newText) { // as long as newText isn't empty, get suggestions from the locatorTask if (!newText.equals("")) { mProximitySearchViewEmpty = false; final ListenableFuture<List<SuggestResult>> suggestionsFuture = mLocatorTask .suggestAsync(newText, mProximitySuggestParameters); suggestionsFuture.addDoneListener(new Runnable() { @Override public void run() { try { // get the list of suggestions List<SuggestResult> suggestResults = suggestionsFuture.get(); MatrixCursor suggestionsCursor = new MatrixCursor(mColumnNames); int key = 0; // add each SuggestResult to a new row for (SuggestResult result : suggestResults) { suggestionsCursor.addRow(new Object[] { key++, result.getLabel() }); } // define SimpleCursorAdapter String[] cols = new String[] { COLUMN_NAME_ADDRESS }; int[] to = new int[] { R.id.suggestion_address }; final SimpleCursorAdapter suggestionAdapter = new SimpleCursorAdapter( MainActivity.this, R.layout.suggestion, suggestionsCursor, cols, to, 0); mProximitySearchView.setSuggestionsAdapter(suggestionAdapter); mProximitySearchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int position) { return false; } @Override public boolean onSuggestionClick(int position) { // get the selected row MatrixCursor selectedRow = (MatrixCursor) suggestionAdapter .getItem(position); // get the row's index int selectedCursorIndex = selectedRow.getColumnIndex(COLUMN_NAME_ADDRESS); // get the string from the row at index final String address = selectedRow.getString(selectedCursorIndex); mLocatorTask.addDoneLoadingListener(new Runnable() { @Override public void run() { if (mLocatorTask.getLoadStatus() == LoadStatus.LOADED) { // geocode the selected address to get location of address final ListenableFuture<List<GeocodeResult>> geocodeFuture = mLocatorTask .geocodeAsync(address, mProximityGeocodeParameters); geocodeFuture.addDoneListener(new Runnable() { @Override public void run() { try { // Get the results of the async operation List<GeocodeResult> geocodeResults = geocodeFuture .get(); if (geocodeResults.size() > 0) { // use geocodeResult to focus search area GeocodeResult geocodeResult = geocodeResults .get(0); // update preferred search area to the geocode result mPreferredSearchProximity = geocodeResult .getDisplayLocation(); mPoiGeocodeParameters.setSearchArea( mPreferredSearchProximity); // set the address string to the SearchView, but don't submit as a query mProximitySearchView.setQuery(address, false); // call POI search query mPoiSearchView.setQuery(mPoiAddress, true); // clear focus from search views mProximitySearchView.clearFocus(); mPoiSearchView.clearFocus(); } else { Toast.makeText(getApplicationContext(), getString(R.string.location_not_found) + address, Toast.LENGTH_LONG).show(); } } catch (InterruptedException | ExecutionException e) { Log.e(TAG, "Geocode error: " + e.getMessage()); Toast.makeText(getApplicationContext(), getString(R.string.geo_locate_error), Toast.LENGTH_LONG).show(); } } }); } } }); return true; } }); } catch (Exception e) { Log.e(TAG, "Geocode suggestion error: " + e.getMessage()); } } }); // if search view is empty, set flag } else { mProximitySearchViewEmpty = true; } return true; } }); }
From source file:com.esri.arcgisruntime.sample.findplace.MainActivity.java
/** * Sets up the POI SearchView. Uses MatrixCursor to show suggestions to the user as the user inputs text. *//* ww w . j av a 2s .c om*/ private void setupPoi() { mPoiSuggestParameters = new SuggestParameters(); // filter categories for POI mPoiSuggestParameters.getCategories().add("POI"); mPoiGeocodeParameters = new GeocodeParameters(); // get all attributes mPoiGeocodeParameters.getResultAttributeNames().add("*"); mPoiSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String address) { // if proximity SearchView text box is empty, use the device location if (mProximitySearchViewEmpty) { mPreferredSearchProximity = mLocationDisplay.getMapLocation(); mProximitySearchView.setQuery("Using current location...", false); } // keep track of typed address mPoiAddress = address; // geocode typed address geoCodeTypedAddress(address); // clear focus from search views mPoiSearchView.clearFocus(); mProximitySearchView.clearFocus(); return true; } @Override public boolean onQueryTextChange(final String newText) { // as long as newText isn't empty, get suggestions from the locatorTask if (!newText.equals("")) { mPoiSuggestParameters.setSearchArea(mCurrentExtentGeometry); final ListenableFuture<List<SuggestResult>> suggestionsFuture = mLocatorTask .suggestAsync(newText, mPoiSuggestParameters); suggestionsFuture.addDoneListener(new Runnable() { @Override public void run() { try { // get the results of the async operation List<SuggestResult> suggestResults = suggestionsFuture.get(); if (!suggestResults.isEmpty()) { MatrixCursor suggestionsCursor = new MatrixCursor(mColumnNames); int key = 0; // add each poi_suggestion result to a new row for (SuggestResult result : suggestResults) { suggestionsCursor.addRow(new Object[] { key++, result.getLabel() }); } // define SimpleCursorAdapter String[] cols = new String[] { COLUMN_NAME_ADDRESS }; int[] to = new int[] { R.id.suggestion_address }; final SimpleCursorAdapter suggestionAdapter = new SimpleCursorAdapter( MainActivity.this, R.layout.suggestion, suggestionsCursor, cols, to, 0); mPoiSearchView.setSuggestionsAdapter(suggestionAdapter); // handle a poi_suggestion being chosen mPoiSearchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int position) { return false; } @Override public boolean onSuggestionClick(int position) { // get the selected row MatrixCursor selectedRow = (MatrixCursor) suggestionAdapter .getItem(position); // get the row's index int selectedCursorIndex = selectedRow .getColumnIndex(COLUMN_NAME_ADDRESS); // get the string from the row at index mPoiAddress = selectedRow.getString(selectedCursorIndex); mPoiSearchView.setQuery(mPoiAddress, true); return true; } }); } else { mPoiAddress = newText; } } catch (Exception e) { Log.e(TAG, "Geocode suggestion error: " + e.getMessage()); } } }); } return true; } }); }
From source file:com.esri.android.mapsapp.MapFragment.java
/** * Displays the search view layout/*w w w .j ava 2s. c o m*/ * */ private void showSearchBoxLayout() { // Inflating the layout from the xml file mSearchBox = mInflater.inflate(R.layout.searchview, null); // Inflate navigation drawer button on SearchView navButton = (ImageButton) mSearchBox.findViewById(R.id.btn_nav_menu); // Get the navigation drawer from Activity mDrawerLayout = (DrawerLayout) getActivity().findViewById(R.id.maps_app_activity_drawer_layout); mDrawerList = (ListView) getActivity().findViewById(R.id.maps_app_activity_left_drawer); // Set click listener to open/close drawer navButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } }); // Setting the layout parameters to the layout mSearchBox.setLayoutParams(mlayoutParams); // Initializing the searchview and the image view mSearchview = (SearchView) mSearchBox.findViewById(R.id.searchView1); ImageView iv_route = (ImageView) mSearchBox.findViewById(R.id.imageView1); mSearchview.setIconifiedByDefault(false); mSearchview.setQueryHint(SEARCH_HINT); applySuggestionCursor(); // navButton = (Button)mSearchBox.findViewById(R.id.navbutton); // Adding the layout to the map conatiner mMapContainer.addView(mSearchBox); // Setup the listener for the route onclick iv_route.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showRoutingDialogFragment(); } }); // Setup the listener when the search button is pressed on the keyboard mSearchview.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { onSearchButtonClicked(query); mSearchview.clearFocus(); return true; } @Override public boolean onQueryTextChange(String newText) { if (mLocator == null) return false; getSuggestions(newText); return true; } }); // Add the compass after getting the height of the layout mSearchBox.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { addCompass(mSearchBox.getHeight()); mSearchBox.getViewTreeObserver().removeGlobalOnLayoutListener(this); } }); mSearchview.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int position) { return false; } @Override public boolean onSuggestionClick(int position) { // Obtain the content of the selected suggesting place via cursor MatrixCursor cursor = (MatrixCursor) mSearchview.getSuggestionsAdapter().getItem(position); int indexColumnSuggestion = cursor.getColumnIndex(COLUMN_NAME_ADDRESS); final String address = cursor.getString(indexColumnSuggestion); suggestionClickFlag = true; // Find the Location of the suggestion new FindLocationTask(address).execute(address); cursor.close(); return true; } }); }