List of usage examples for android.net Uri withAppendedPath
public static Uri withAppendedPath(Uri baseUri, String pathSegment)
From source file:can.yrt.onebusaway.MyRecentStopsFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case CONTEXT_MENU_DELETE: ObaContract.Stops.markAsUnused(getActivity(), Uri.withAppendedPath(ObaContract.Stops.CONTENT_URI, QueryUtils.StopList.getId(getListView(), info.position))); return true; default:// w ww . ja va 2s. c o m return super.onContextItemSelected(item); } }
From source file:can.yrt.onebusaway.MyRecentRoutesFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case CONTEXT_MENU_DELETE: ObaContract.Routes.markAsUnused(getActivity(), Uri.withAppendedPath(ObaContract.Routes.CONTENT_URI, QueryUtils.RouteList.getId(getListView(), info.position))); return true; default://from w w w. j a v a 2s. com return super.onContextItemSelected(item); } }
From source file:org.odk.collect.android.utilities.MediaUtils.java
public static final Uri getImageUriFromMediaProvider(String imageFile) { String selection = Images.ImageColumns.DATA + "=?"; String[] selectArgs = { imageFile }; String[] projection = { Images.ImageColumns._ID }; Cursor c = null;//from ww w. j a va 2 s . c o m try { c = Collect.getInstance().getContentResolver().query( android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, selection, selectArgs, null); if (c.getCount() > 0) { c.moveToFirst(); String id = c.getString(c.getColumnIndex(Images.ImageColumns._ID)); return Uri.withAppendedPath(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id); } return null; } finally { if (c != null) { c.close(); } } }
From source file:com.soundcloud.android.crop.support.ImagesFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { View v = inflater.inflate(R.layout.gallery, null); Toolbar toolbar = (Toolbar) v.findViewById(R.id.toolbar); toolbar.setTitle(""); toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override//from w w w .jav a 2 s . co m public void onClick(View v) { getActivity().onBackPressed(); } }); Cursor cur = getActivity().getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[] { MediaStore.Images.Media.DATA, MediaStore.Images.Media.DISPLAY_NAME, MediaStore.Images.Media.DATE_TAKEN, MediaStore.Images.Media.SIZE, MediaStore.Images.Media._ID }, MediaStore.Images.Media.BUCKET_ID + " = ?", new String[] { String.valueOf(getArguments().getInt("bucket")) }, MediaStore.Images.Media.DATE_MODIFIED + " DESC"); final List<GridItem> images = new ArrayList<GridItem>(cur.getCount()); if (cur != null) { if (cur.moveToFirst()) { while (!cur.isAfterLast()) { Uri uri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "" + cur.getString(4)); images.add(new GridItem(cur.getString(1), cur.getString(0), cur.getString(2), cur.getLong(3), uri)); cur.moveToNext(); } } cur.close(); } GridView grid = (GridView) v.findViewById(R.id.grid); grid.setAdapter(new GalleryAdapter(getActivity(), images)); grid.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ((SelectPictureActivity) getActivity()).imageSelected(images.get(position).path, images.get(position).imageTaken, images.get(position).imageSize, images.get(position).uri); } }); return v; }
From source file:can.yrt.onebusaway.MyStarredStopsFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case MyListConstants.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 www. j av a2 s .c om*/ return super.onContextItemSelected(item); } }
From source file:org.jamienicol.episodes.ShowDetailsFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { int showId = args.getInt("showId"); Uri uri = Uri.withAppendedPath(ShowsProvider.CONTENT_URI_SHOWS, String.valueOf(showId)); String[] projection = { ShowsTable.COLUMN_OVERVIEW, ShowsTable.COLUMN_FIRST_AIRED }; return new CursorLoader(getActivity(), uri, projection, null, null, null); }
From source file:com.mindprotectionkit.freephone.contacts.ContactAccessor.java
public CursorLoader getFavoritesCursor(Context context, String filter) { Uri uri = Uri.withAppendedPath(Phone.CONTENT_FILTER_URI, Uri.encode(filter)); return getFavoritesCursor(context, uri); }
From source file:com.jaspersoft.android.jaspermobile.activities.favorites.adapter.FavoritesAdapter.java
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { long id = Lists.newArrayList(getCheckedItems()).get(0); Uri uri = Uri.withAppendedPath(JasperMobileDbProvider.FAVORITES_CONTENT_URI, String.valueOf(id)); switch (item.getItemId()) { case R.id.removeFromFavorites: getContext().getContentResolver().delete(uri, null, null); finishActionMode();/*from w w w . j a v a 2 s . c o m*/ return true; case R.id.showAction: showAboutInfo(uri); return true; default: return false; } }
From source file:com.ultrafunk.network_info.service.NetworkStateService.java
@Override public void onCreate() { super.onCreate(); // Log.e(this.getClass().getSimpleName(), "onCreate()"); localBroadcastManager = LocalBroadcastManager.getInstance(this); telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) mobileDataSettingUri = Uri.withAppendedPath(Settings.System.CONTENT_URI, "mobile_data"); else/*from ww w .j a va 2s. c o m*/ mobileDataSettingUri = Uri.withAppendedPath(Settings.Global.CONTENT_URI, "mobile_data"); initEnabledWidgets(Utils.getEnabledWidgets(this, AppWidgetManager.getInstance(this))); }
From source file:com.securecomcode.voice.contacts.ContactsCursorLoader.java
private Cursor queryAndroidDb(String filter) { Uri baseUri;/*w w w. ja va2 s.c o m*/ Cursor cursor; List<Cursor> cursors = new ArrayList<Cursor>(); if (filter != null) { baseUri = Uri.withAppendedPath(ContactsContract.CommonDataKinds.Phone.CONTENT_FILTER_URI, Uri.encode(filter)); cursor = context.getContentResolver().query(baseUri, null, null, null, CONTACT_LIST_SORT); cursors.add(cursor); baseUri = Uri.withAppendedPath(ContactsContract.CommonDataKinds.Email.CONTENT_FILTER_URI, Uri.encode(filter)); cursor = context.getContentResolver().query(baseUri, null, null, null, CONTACT_LIST_SORT); cursors.add(cursor); return new MergeCursor(cursors.toArray(new Cursor[] {})); } else { baseUri = ContactsContract.Data.CONTENT_URI; cursor = context.getContentResolver().query(baseUri, null, ContactsContract.Data.IN_VISIBLE_GROUP + "!=0 AND (" + ContactsContract.Data.MIMETYPE + "=? OR " + ContactsContract.Data.MIMETYPE + "=?)", new String[] { ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE }, CONTACT_LIST_SORT); return cursor; } }