Java Code Examples for com.facebook.common.util.UriUtil#isLocalAssetUri()
The following examples show how to use
com.facebook.common.util.UriUtil#isLocalAssetUri() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageRequestBuilder.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
/** Performs validation. */ protected void validate() { // make sure that the source uri is set correctly. if (mSourceUri == null) { throw new BuilderException("Source must be set!"); } // For local resource we require caller to specify statically generated resource id as a path. if (UriUtil.isLocalResourceUri(mSourceUri)) { if (!mSourceUri.isAbsolute()) { throw new BuilderException("Resource URI path must be absolute."); } if (mSourceUri.getPath().isEmpty()) { throw new BuilderException("Resource URI must not be empty"); } try { Integer.parseInt(mSourceUri.getPath().substring(1)); } catch (NumberFormatException ignored) { throw new BuilderException("Resource URI path must be a resource id."); } } // For local asset we require caller to specify absolute path of an asset, which will be // resolved by AssetManager relative to configured asset folder of an app. if (UriUtil.isLocalAssetUri(mSourceUri) && !mSourceUri.isAbsolute()) { throw new BuilderException("Asset URI path must be absolute."); } }
Example 2
Source File: ProducerSequenceFactory.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
private Producer<CloseableReference<CloseableImage>> getBasicDecodedImageSequence( ImageRequest imageRequest) { Preconditions.checkNotNull(imageRequest); ImageRequest.RequestLevel lowestPermittedRequestLevel = imageRequest.getLowestPermittedRequestLevel(); Preconditions.checkState( lowestPermittedRequestLevel.equals(ImageRequest.RequestLevel.FULL_FETCH) || lowestPermittedRequestLevel.equals( ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE), "Only support bitmap memory cache or full fetch at present, request level is %s ", lowestPermittedRequestLevel); if (lowestPermittedRequestLevel.equals(ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE)) { return getBitmapCacheGetOnlySequence(); } Uri uri = imageRequest.getSourceUri(); if (UriUtil.isNetworkUri(uri)) { return getNetworkFetchSequence(); } else if (UriUtil.isLocalFileUri(uri)) { if (MediaUtils.isVideo(MediaUtils.extractMime(uri.getPath()))) { return getLocalVideoFileFetchSequence(); } else { return getLocalImageFileFetchSequence(); } } else if (UriUtil.isLocalContentUri(uri)) { return getLocalContentUriFetchSequence(); } else if (UriUtil.isLocalAssetUri(uri)) { return getLocalAssetFetchSequence(); } else if (UriUtil.isLocalResourceUri(uri)) { return getLocalResourceFetchSequence(); } else { throw new RuntimeException( "Unsupported image type! Uri is: " + uri.toString().substring(0, 30)); } }
Example 3
Source File: ImageRequestBuilder.java From fresco with MIT License | 5 votes |
/** Performs validation. */ protected void validate() { // make sure that the source uri is set correctly. if (mSourceUri == null) { throw new BuilderException("Source must be set!"); } // For local resource we require caller to specify statically generated resource id as a path. if (UriUtil.isLocalResourceUri(mSourceUri)) { if (!mSourceUri.isAbsolute()) { throw new BuilderException("Resource URI path must be absolute."); } if (mSourceUri.getPath().isEmpty()) { throw new BuilderException("Resource URI must not be empty"); } try { Integer.parseInt(mSourceUri.getPath().substring(1)); } catch (NumberFormatException ignored) { throw new BuilderException("Resource URI path must be a resource id."); } } // For local asset we require caller to specify absolute path of an asset, which will be // resolved by AssetManager relative to configured asset folder of an app. if (UriUtil.isLocalAssetUri(mSourceUri) && !mSourceUri.isAbsolute()) { throw new BuilderException("Asset URI path must be absolute."); } }
Example 4
Source File: ImageRequest.java From fresco with MIT License | 5 votes |
/** * This is a utility method which returns the type of Uri * * @param uri The Uri to test * @return The type of the given Uri if available or SOURCE_TYPE_UNKNOWN if not */ private static @SourceUriType int getSourceUriType(final Uri uri) { if (uri == null) { return SOURCE_TYPE_UNKNOWN; } if (UriUtil.isNetworkUri(uri)) { return SOURCE_TYPE_NETWORK; } else if (UriUtil.isLocalFileUri(uri)) { if (MediaUtils.isVideo(MediaUtils.extractMime(uri.getPath()))) { return SOURCE_TYPE_LOCAL_VIDEO_FILE; } else { return SOURCE_TYPE_LOCAL_IMAGE_FILE; } } else if (UriUtil.isLocalContentUri(uri)) { return SOURCE_TYPE_LOCAL_CONTENT; } else if (UriUtil.isLocalAssetUri(uri)) { return SOURCE_TYPE_LOCAL_ASSET; } else if (UriUtil.isLocalResourceUri(uri)) { return SOURCE_TYPE_LOCAL_RESOURCE; } else if (UriUtil.isDataUri(uri)) { return SOURCE_TYPE_DATA; } else if (UriUtil.isQualifiedResourceUri(uri)) { return SOURCE_TYPE_QUALIFIED_RESOURCE; } else { return SOURCE_TYPE_UNKNOWN; } }