List of usage examples for android.net Uri getAuthority
@Nullable public abstract String getAuthority();
From source file:com.wiret.arbrowser.AbstractArchitectCamActivity.java
/** * @param uri The Uri to check./*from w ww. j a v a 2 s . co m*/ * @return Whether the Uri authority is MediaProvider. */ private boolean isMediaDocument(Uri uri) { return "com.android.providers.media.documents".equals(uri.getAuthority()); }
From source file:com.wiret.arbrowser.AbstractArchitectCamActivity.java
/** * @param uri The Uri to check./* ww w. j a v a 2 s . c om*/ * @return Whether the Uri authority is Google Photos. */ private boolean isGooglePhotosUri(Uri uri) { return "com.google.android.apps.photos.content".equals(uri.getAuthority()); }
From source file:com.wiret.arbrowser.AbstractArchitectCamActivity.java
/** * @param uri The Uri to check.//from ww w .j a v a 2s . c o m * @return Whether the Uri authority is DownloadsProvider. */ private boolean isDownloadsDocument(Uri uri) { return "com.android.providers.downloads.documents".equals(uri.getAuthority()); }
From source file:android.support.v7.widget.SuggestionsAdapter.java
/** * Import of hidden method: ContentResolver.getResourceId(Uri). * Modified to return a drawable, rather than a hidden type. *///from w ww .j av a 2 s . co m Drawable getDrawableFromResourceUri(Uri uri) throws FileNotFoundException { String authority = uri.getAuthority(); Resources r; if (TextUtils.isEmpty(authority)) { throw new FileNotFoundException("No authority: " + uri); } else { try { r = mContext.getPackageManager().getResourcesForApplication(authority); } catch (NameNotFoundException ex) { throw new FileNotFoundException("No package found for authority: " + uri); } } List<String> path = uri.getPathSegments(); if (path == null) { throw new FileNotFoundException("No path: " + uri); } int len = path.size(); int id; if (len == 1) { try { id = Integer.parseInt(path.get(0)); } catch (NumberFormatException e) { throw new FileNotFoundException("Single path segment is not a resource ID: " + uri); } } else if (len == 2) { id = r.getIdentifier(path.get(1), path.get(0), authority); } else { throw new FileNotFoundException("More than two path segments: " + uri); } if (id == 0) { throw new FileNotFoundException("No resource found for: " + uri); } return r.getDrawable(id); }
From source file:org.coocood.vcontentprovider.VContentProvider.java
private void notifyChange(Uri uri, int count) { if (!batchingUris.contains(uri) && count != 0) { getContext().getContentResolver().notifyChange(uri, null); // Notify not only the table Uri, but also the view Uris which // contain the table. String table = uri.getPathSegments().get(0); for (String view : viewTablesMap.keySet()) { if (viewTablesMap.get(view).contains(table)) { Uri viewUri = new Uri.Builder().scheme(uri.getScheme()).authority(uri.getAuthority()) .appendPath(view).build(); getContext().getContentResolver().notifyChange(viewUri, null); }/*ww w . j a v a2 s . c om*/ } } }
From source file:com.mishiranu.dashchan.ui.gallery.GalleryActivity.java
@Override public void onCreate(Bundle savedInstanceState) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); int[] imageViewPosition = savedInstanceState == null ? getIntent().getIntArrayExtra(C.EXTRA_VIEW_POSITION) : null;/*w w w . ja va 2 s . c om*/ if (!C.API_LOLLIPOP || imageViewPosition == null) { overridePendingTransition(R.anim.fast_fade_in, 0); } applyStatusNavigationTranslucency(); super.onCreate(savedInstanceState); setVolumeControlStream(AudioManager.STREAM_MUSIC); getActionBar().setDisplayHomeAsUpEnabled(true); ViewUtils.applyToolbarStyle(this, null); expandedScreen = getIntent().getBooleanExtra(C.EXTRA_ALLOW_EXPANDED_SCREEN, false); instance.actionBarColor = ACTION_BAR_COLOR; boolean obtainImages = getIntent().getBooleanExtra(C.EXTRA_OBTAIN_ITEMS, false); ArrayList<GalleryItem> galleryItems = obtainImages ? NavigationUtils.obtainImagesProvider(this) : null; String chanName = getIntent().getStringExtra(C.EXTRA_CHAN_NAME); Uri uri = getIntent().getData(); int imagePosition = savedInstanceState != null ? savedInstanceState.getInt(EXTRA_POSITION, -1) : -1; if (chanName == null && uri != null) { chanName = ChanManager.getInstance().getChanNameByHost(uri.getAuthority()); } ChanLocator locator = null; if (chanName != null) { locator = ChanLocator.get(chanName); } threadTitle = getIntent().getStringExtra(C.EXTRA_THREAD_TITLE); boolean defaultLocator = false; if (locator == null) { locator = ChanLocator.getDefault(); defaultLocator = true; } if (uri != null && galleryItems == null) { galleryItems = new ArrayList<>(1); String boardName = null; String threadNumber = null; if (!defaultLocator) { boardName = locator.safe(true).getBoardName(uri); threadNumber = locator.safe(true).getThreadNumber(uri); } galleryItems.add(new GalleryItem(uri, boardName, threadNumber)); overrideUpButton = true; imagePosition = 0; } else if (imagePosition == -1) { imagePosition = getIntent().getIntExtra(C.EXTRA_IMAGE_INDEX, 0); } instance.chanName = chanName; instance.locator = locator; instance.galleryItems = galleryItems; allowNavigatePost = getIntent().getBooleanExtra(C.EXTRA_ALLOW_NAVIGATE_POST, false); actionBar = findViewById(getResources().getIdentifier("action_bar", "id", "android")); rootView = new WindowControlFrameLayout(this); rootView.setOnApplyWindowPaddingsListener(this); rootView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); backgroundDrawable = new GalleryBackgroundDrawable(rootView, C.API_LOLLIPOP ? imageViewPosition : null, BACKGROUND_COLOR); rootView.setBackground(backgroundDrawable); setContentView(rootView); if (galleryItems == null || galleryItems.size() == 0) { View errorView = getLayoutInflater().inflate(R.layout.widget_error, rootView, false); TextView textView = (TextView) errorView.findViewById(R.id.error_text); textView.setText(R.string.message_empty_gallery); rootView.addView(errorView); } else { listUnit = new ListUnit(instance); pagerUnit = new PagerUnit(instance); rootView.addView(listUnit.getListView(), FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); rootView.addView(pagerUnit.getView(), FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); pagerUnit.addAndInitViews(rootView, imagePosition); if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_GALLERY_MODE)) { galleryMode = savedInstanceState.getBoolean(EXTRA_GALLERY_MODE); galleryWindow = savedInstanceState.getBoolean(EXTRA_GALLERY_WINDOW); switchMode(galleryMode, false); modifySystemUiVisibility(GalleryInstance.FLAG_LOCKED_USER, savedInstanceState.getBoolean(EXTRA_SYSTEM_UI_VISIBILITY)); } else { galleryWindow = imagePosition < 0 || getIntent().getBooleanExtra(C.EXTRA_GALLERY_MODE, false); if (galleryWindow && imagePosition >= 0) { listUnit.setListSelection(imagePosition, false); } switchMode(galleryWindow, false); } pagerUnit.onViewsCreated(imageViewPosition); } }
From source file:com.stfalcon.contentmanager.ContentManager.java
private boolean isFileMediaDocument(Uri uri) { return "com.android.providers.media.documents".equals(uri.getAuthority()); }
From source file:com.stfalcon.contentmanager.ContentManager.java
private boolean isFileDownloadsDocument(Uri uri) { return "com.android.providers.downloads.documents".equals(uri.getAuthority()); }
From source file:com.appbase.androidquery.callback.AbstractAjaxCallback.java
private static String extractUrl(Uri uri) { String result = uri.getScheme() + "://" + uri.getAuthority() + uri.getPath(); String fragment = uri.getFragment(); if (fragment != null) result += "#" + fragment; return result; }
From source file:com.vuze.android.remote.VuzeEasyTrackerOld.java
public Map<String, String> getReferrerMapFromUri(Uri uri) { MapBuilder paramMap = new MapBuilder(); // If no URI, return an empty Map. if (uri == null) { return paramMap.build(); }// w w w . ja v a2 s . c om try { // Source is the only required campaign field. No need to continue if not // present. if (uri.isHierarchical() && uri.getQueryParameter(CAMPAIGN_SOURCE_PARAM) != null) { // MapBuilder.setCampaignParamsFromUrl parses Google Analytics campaign // ("UTM") parameters from a string URL into a Map that can be set on // the Tracker. paramMap.setCampaignParamsFromUrl(uri.toString()); // If no source parameter, set authority to source and medium to // "referral". } else if (uri.getAuthority() != null && uri.getAuthority().length() > 0) { paramMap.set(Fields.CAMPAIGN_MEDIUM, "referral"); paramMap.set(Fields.CAMPAIGN_SOURCE, uri.getAuthority()); } else if (uri.getScheme() != null) { paramMap.set(Fields.CAMPAIGN_MEDIUM, uri.getScheme()); } } catch (Throwable t) { // I found: java.lang.UnsupportedOperationException: This isn't a hierarchical URI. // Fixed above with isHeirarchical, but who knows what other throws there are if (AndroidUtils.DEBUG) { t.printStackTrace(); } } return paramMap.build(); }