List of usage examples for android.net Uri withAppendedPath
public static Uri withAppendedPath(Uri baseUri, String pathSegment)
From source file:com.ultramegasoft.flavordex2.fragment.AddFlavorsFragment.java
@SuppressWarnings("ConstantConditions") @NonNull//from ww w. j av a 2 s . co m @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { final Context context = getContext(); if (context == null) { return null; } final Uri uri = ContentUris.withAppendedId(Tables.Cats.CONTENT_ID_URI_BASE, mCatId); return new CursorLoader(context, Uri.withAppendedPath(uri, "flavor"), null, null, null, Tables.Flavors.POS + " ASC"); }
From source file:com.renard.documentview.DocumentAdapter.java
public Pair<List<Uri>, List<Spanned>> getTextsToSave() { List<Uri> documentIds = new ArrayList<Uri>(); List<Spanned> texts = new ArrayList<Spanned>(); for (Integer id : mChangedDocuments) { documentIds.add(Uri.withAppendedPath(DocumentContentProvider.CONTENT_URI, String.valueOf(id))); final CharSequence text = mChangedTexts.get(id); texts.add((Spanned) text);//from w ww .j av a2 s . c om } return new Pair<List<Uri>, List<Spanned>>(documentIds, texts); }
From source file:org.onebusaway.android.ui.MyStarredStopsFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case CONTEXT_MENU_DELETE: final String id = QueryUtils.StopList.getId(getListView(), info.position); final Uri uri = Uri.withAppendedPath(ObaContract.Stops.CONTENT_URI, id); ObaContract.Stops.markAsFavorite(getActivity(), uri, false); return true; default:/*from w ww. j a va 2 s . co m*/ return super.onContextItemSelected(item); } }
From source file:com.android.contacts.common.model.ContactLoaderTest.java
public void testLoadContactWithContactIdUri() { // Use content Uris that only contain the ID final Uri baseUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, CONTACT_ID); final Uri entityUri = Uri.withAppendedPath(baseUri, Contacts.Entity.CONTENT_DIRECTORY); final Uri lookupUri = ContentUris .withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, LOOKUP_KEY), CONTACT_ID); ContactQueries queries = new ContactQueries(); mContactsProvider.expectTypeQuery(baseUri, Contacts.CONTENT_ITEM_TYPE); queries.fetchAllData(entityUri, CONTACT_ID, RAW_CONTACT_ID, DATA_ID, LOOKUP_KEY); Contact contact = assertLoadContact(baseUri); assertEquals(CONTACT_ID, contact.getId()); assertEquals(RAW_CONTACT_ID, contact.getNameRawContactId()); assertEquals(DisplayNameSources.STRUCTURED_NAME, contact.getDisplayNameSource()); assertEquals(LOOKUP_KEY, contact.getLookupKey()); assertEquals(lookupUri, contact.getLookupUri()); assertEquals(1, contact.getRawContacts().size()); assertEquals(1, contact.getStatuses().size()); mContactsProvider.verify();/*from w w w. ja va 2 s . c o m*/ }
From source file:org.thoughtcrime.securesms.contacts.ContactAccessor.java
public Cursor getCursorForContactsWithPush(Context context) { final ContentResolver resolver = context.getContentResolver(); final String[] inProjection = new String[] { PhoneLookup._ID, PhoneLookup.DISPLAY_NAME }; final String[] outProjection = new String[] { PhoneLookup._ID, PhoneLookup.DISPLAY_NAME, PUSH_COLUMN }; MatrixCursor cursor = new MatrixCursor(outProjection); List<String> pushNumbers = Directory.getInstance(context).getActiveNumbers(); for (String pushNumber : pushNumbers) { Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(pushNumber)); Cursor lookupCursor = resolver.query(uri, inProjection, null, null, null); try {// w w w.jav a 2s .com if (lookupCursor != null && lookupCursor.moveToFirst()) { cursor.addRow(new Object[] { lookupCursor.getLong(0), lookupCursor.getString(1), 1 }); } } finally { if (lookupCursor != null) lookupCursor.close(); } } return cursor; }
From source file:org.thoughtcrime.SMP.contacts.ContactAccessor.java
public Collection<ContactData> getContactsWithPush(Context context) { final ContentResolver resolver = context.getContentResolver(); final String[] inProjection = new String[] { PhoneLookup._ID, PhoneLookup.DISPLAY_NAME }; List<String> pushNumbers = TextSecureDirectory.getInstance(context).getActiveNumbers(); final Collection<ContactData> lookupData = new ArrayList<ContactData>(pushNumbers.size()); for (String pushNumber : pushNumbers) { Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(pushNumber)); Cursor lookupCursor = resolver.query(uri, inProjection, null, null, null); try {/*from ww w .j a v a 2 s .c o m*/ if (lookupCursor != null && lookupCursor.moveToFirst()) { final ContactData contactData = new ContactData(lookupCursor.getLong(0), lookupCursor.getString(1)); contactData.numbers.add(new NumberData("TextSecure", pushNumber)); lookupData.add(contactData); } } finally { if (lookupCursor != null) lookupCursor.close(); } } return lookupData; }
From source file:com.example.ward.view.CursorFragment.java
public Loader<Cursor> onCreateLoader(int id, Bundle args) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't care about the ID. // First, pick the base URI to use depending on whether we are // currently filtering. Uri baseUri;/*from w ww. ja v a 2s .co m*/ if (mCurFilter != null) { baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI, Uri.encode(mCurFilter)); } else { baseUri = Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take care of // creating a Cursor for the data being displayed. String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND (" + Contacts.HAS_PHONE_NUMBER + "=1) AND (" + Contacts.DISPLAY_NAME + " != '' ))"; return new CursorLoader(getActivity(), baseUri, CONTACTS_SUMMARY_PROJECTION, select, null, Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"); }
From source file:org.smssecure.smssecure.contacts.ContactAccessor.java
public Collection<ContactData> getContactsWithPush(Context context) { final ContentResolver resolver = context.getContentResolver(); final String[] inProjection = new String[] { PhoneLookup._ID, PhoneLookup.DISPLAY_NAME }; List<String> pushNumbers = SMSSecureDirectory.getInstance(context).getActiveNumbers(); final Collection<ContactData> lookupData = new ArrayList<ContactData>(pushNumbers.size()); for (String pushNumber : pushNumbers) { Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(pushNumber)); Cursor lookupCursor = resolver.query(uri, inProjection, null, null, null); try {/*w w w .j a v a2s . co m*/ if (lookupCursor != null && lookupCursor.moveToFirst()) { final ContactData contactData = new ContactData(lookupCursor.getLong(0), lookupCursor.getString(1)); contactData.numbers.add(new NumberData("SMSSecure", pushNumber)); lookupData.add(contactData); } } finally { if (lookupCursor != null) lookupCursor.close(); } } return lookupData; }
From source file:cz.maresmar.sfm.view.menu.day.DayMenuPagerFragment.java
@NonNull @Override//from w w w . j av a 2 s . c o m public Loader<Cursor> onCreateLoader(int id, @Nullable Bundle args) { switch (id) { case DAY_LOADER: Uri portalsUri = Uri.withAppendedPath(mUserUri, ProviderContract.DAY_PATH); return new CursorLoader(getContext(), portalsUri, new String[] { ProviderContract.Day._ID }, null, null, null); default: throw new UnsupportedOperationException("Unknown loader id: " + id); } }