Java Code Examples for com.facebook.common.util.UriUtil#isNetworkUri()
The following examples show how to use
com.facebook.common.util.UriUtil#isNetworkUri() .
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: ImageUriRequest.java From APlayer with GNU General Public License v3.0 | 6 votes |
private String parseLastFMNetworkImageUrl(UriRequest request, ResponseBody body) throws IOException { String imageUrl = null; String bodyString = body.string(); if (request.getSearchType() == ImageUriRequest.URL_ALBUM) { LastFmAlbum lastFmAlbum = new Gson().fromJson(bodyString, LastFmAlbum.class); if (lastFmAlbum.getAlbum() != null) { imageUrl = ImageUriUtil.getLargestAlbumImageUrl(lastFmAlbum.getAlbum().getImage()); } } else if (request.getSearchType() == ImageUriRequest.URL_ARTIST) { LastFmArtist lastFmArtist = new Gson().fromJson(bodyString, LastFmArtist.class); if (lastFmArtist.getArtist() != null) { imageUrl = ImageUriUtil.getLargestArtistImageUrl(lastFmArtist.getArtist().getImage()); } } if (BLACKLIST.contains(imageUrl)) { imageUrl = null; } if (!TextUtils.isEmpty(imageUrl) && UriUtil.isNetworkUri(Uri.parse(imageUrl))) { SPUtil.putValue(App.getContext(), SPUtil.COVER_KEY.NAME, request.getLastFMKey(), imageUrl); } return imageUrl; }
Example 2
Source File: DecodeProducer.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 6 votes |
@Override public void produceResults( final Consumer<CloseableReference<CloseableImage>> consumer, final ProducerContext context) { final ImageRequest imageRequest = context.getImageRequest(); ProgressiveDecoder progressiveDecoder; if (!UriUtil.isNetworkUri(imageRequest.getSourceUri())) { progressiveDecoder = new LocalImagesProgressiveDecoder(consumer, context); } else { ProgressiveJpegParser jpegParser = new ProgressiveJpegParser(mByteArrayPool); progressiveDecoder = new NetworkImagesProgressiveDecoder( consumer, context, jpegParser, mProgressiveJpegConfig); } mNextProducer.produceResults(progressiveDecoder, context); }
Example 3
Source File: ImagePipeline.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 6 votes |
private <T> DataSource<CloseableReference<T>> submitFetchRequest( Producer<CloseableReference<T>> producerSequence, ImageRequest imageRequest, Object callerContext) { SettableProducerContext settableProducerContext = new SettableProducerContext( imageRequest, generateUniqueFutureId(), mRequestListener, callerContext, /* isPrefetch */ false, imageRequest.getProgressiveRenderingEnabled() || !UriUtil.isNetworkUri(imageRequest.getSourceUri()), Priority.HIGH); return CloseableProducerToDataSourceAdapter.create( producerSequence, settableProducerContext, mRequestListener); }
Example 4
Source File: FrescoHolder.java From fresco with MIT License | 6 votes |
@Override protected void onBind(String uriString) { Uri uri = Uri.parse(uriString); ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(uri); if (UriUtil.isNetworkUri(uri)) { imageRequestBuilder.setProgressiveRenderingEnabled(true); } else { imageRequestBuilder.setResizeOptions( new ResizeOptions( mImageView.getLayoutParams().width, mImageView.getLayoutParams().height)); } DraweeController draweeController = Fresco.newDraweeControllerBuilder() .setImageRequest(imageRequestBuilder.build()) .setOldController(mImageView.getController()) .setControllerListener(mImageView.getListener()) .setAutoPlayAnimations(true) .build(); mImageView.setController(draweeController); }
Example 5
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 6
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; } }
Example 7
Source File: DecodeProducer.java From fresco with MIT License | 5 votes |
@Override public void produceResults( final Consumer<CloseableReference<CloseableImage>> consumer, final ProducerContext producerContext) { try { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection("DecodeProducer#produceResults"); } final ImageRequest imageRequest = producerContext.getImageRequest(); ProgressiveDecoder progressiveDecoder; if (!UriUtil.isNetworkUri(imageRequest.getSourceUri())) { progressiveDecoder = new LocalImagesProgressiveDecoder( consumer, producerContext, mDecodeCancellationEnabled, mMaxBitmapSize); } else { ProgressiveJpegParser jpegParser = new ProgressiveJpegParser(mByteArrayPool); progressiveDecoder = new NetworkImagesProgressiveDecoder( consumer, producerContext, jpegParser, mProgressiveJpegConfig, mDecodeCancellationEnabled, mMaxBitmapSize); } mInputProducer.produceResults(progressiveDecoder, producerContext); } finally { if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } } }
Example 8
Source File: ImageRequestBuilder.java From fresco with MIT License | 4 votes |
/** Returns whether the use of the disk cache is enabled, which is partly dependent on the URI. */ public boolean isDiskCacheEnabled() { return mDiskCacheEnabled && UriUtil.isNetworkUri(mSourceUri); }
Example 9
Source File: DecodeProducer.java From fresco with MIT License | 4 votes |
public ProgressiveDecoder( final Consumer<CloseableReference<CloseableImage>> consumer, final ProducerContext producerContext, final boolean decodeCancellationEnabled, final int maxBitmapSize) { super(consumer); mProducerContext = producerContext; mProducerListener = producerContext.getProducerListener(); mImageDecodeOptions = producerContext.getImageRequest().getImageDecodeOptions(); mIsFinished = false; JobRunnable job = new JobRunnable() { @Override public void run(EncodedImage encodedImage, @Status int status) { if (encodedImage != null) { mProducerContext.setExtra("image_format", encodedImage.getImageFormat().getName()); if (mDownsampleEnabled || !statusHasFlag(status, Consumer.IS_RESIZING_DONE)) { ImageRequest request = producerContext.getImageRequest(); if (mDownsampleEnabledForNetwork || !UriUtil.isNetworkUri(request.getSourceUri())) { encodedImage.setSampleSize( DownsampleUtil.determineSampleSize( request.getRotationOptions(), request.getResizeOptions(), encodedImage, maxBitmapSize)); } } if (producerContext .getImagePipelineConfig() .getExperiments() .shouldDownsampleIfLargeBitmap()) { maybeIncreaseSampleSize(encodedImage); } doDecode(encodedImage, status); } } }; mJobScheduler = new JobScheduler(mExecutor, job, mImageDecodeOptions.minDecodeIntervalMs); mProducerContext.addCallbacks( new BaseProducerContextCallbacks() { @Override public void onIsIntermediateResultExpectedChanged() { if (mProducerContext.isIntermediateResultExpected()) { mJobScheduler.scheduleJob(); } } @Override public void onCancellationRequested() { if (decodeCancellationEnabled) { handleCancellation(); } } }); }
Example 10
Source File: ImagePipeline.java From fresco with MIT License | 4 votes |
private <T> DataSource<CloseableReference<T>> submitFetchRequest( Producer<CloseableReference<T>> producerSequence, ImageRequest imageRequest, ImageRequest.RequestLevel lowestPermittedRequestLevelOnSubmit, Object callerContext, @Nullable RequestListener requestListener, @Nullable String uiComponentId) { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection("ImagePipeline#submitFetchRequest"); } final RequestListener2 requestListener2 = new InternalRequestListener( getRequestListenerForRequest(imageRequest, requestListener), mRequestListener2); if (mCallerContextVerifier != null) { mCallerContextVerifier.verifyCallerContext(callerContext, false); } try { ImageRequest.RequestLevel lowestPermittedRequestLevel = ImageRequest.RequestLevel.getMax( imageRequest.getLowestPermittedRequestLevel(), lowestPermittedRequestLevelOnSubmit); SettableProducerContext settableProducerContext = new SettableProducerContext( imageRequest, generateUniqueFutureId(), uiComponentId, requestListener2, callerContext, lowestPermittedRequestLevel, /* isPrefetch */ false, imageRequest.getProgressiveRenderingEnabled() || !UriUtil.isNetworkUri(imageRequest.getSourceUri()), imageRequest.getPriority(), mConfig); return CloseableProducerToDataSourceAdapter.create( producerSequence, settableProducerContext, requestListener2); } catch (Exception exception) { return DataSources.immediateFailedDataSource(exception); } finally { if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } } }