当前位置: 首页>>代码示例>>Java>>正文


Java UriUtil类代码示例

本文整理汇总了Java中com.facebook.common.util.UriUtil的典型用法代码示例。如果您正苦于以下问题:Java UriUtil类的具体用法?Java UriUtil怎么用?Java UriUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UriUtil类属于com.facebook.common.util包,在下文中一共展示了UriUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: produceResults

import com.facebook.common.util.UriUtil; //导入依赖的package包/类
@Override
public void produceResults(
    final Consumer<CloseableReference<CloseableImage>> consumer,
    final ProducerContext producerContext) {
  final ImageRequest imageRequest = producerContext.getImageRequest();
  ProgressiveDecoder progressiveDecoder;
  if (!UriUtil.isNetworkUri(imageRequest.getSourceUri())) {
    progressiveDecoder = new LocalImagesProgressiveDecoder(
        consumer,
        producerContext,
        mDecodeCancellationEnabled);
  } else {
    ProgressiveJpegParser jpegParser = new ProgressiveJpegParser(mByteArrayPool);
    progressiveDecoder = new NetworkImagesProgressiveDecoder(
        consumer,
        producerContext,
        jpegParser,
        mProgressiveJpegConfig,
        mDecodeCancellationEnabled);
  }
  mInputProducer.produceResults(progressiveDecoder, producerContext);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:DecodeProducer.java

示例2: setUp

import com.facebook.common.util.UriUtil; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  mExecutor = new TestExecutorService(new FakeClock());
  mQualifiedResourceFetchProducer = new QualifiedResourceFetchProducer(
      mExecutor,
      mPooledByteBufferFactory,
      mContentResolver);
  mContentUri = UriUtil.getUriForQualifiedResource(PACKAGE_NAME, RESOURCE_ID);

  mProducerContext = new SettableProducerContext(
      mImageRequest,
      REQUEST_ID,
      mProducerListener,
      CALLER_CONTEXT,
      ImageRequest.RequestLevel.FULL_FETCH,
      false,
      true,
      Priority.MEDIUM);
  when(mImageRequest.getSourceUri()).thenReturn(mContentUri);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:QualifiedResourceFetchProducerTest.java

示例3: setUp

import com.facebook.common.util.UriUtil; //导入依赖的package包/类
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  PowerMockito.mockStatic(UriUtil.class, MediaUtils.class);

  ProducerFactory producerFactory = mock(ProducerFactory.class, RETURNS_MOCKS);

  mProducerSequenceFactory = new ProducerSequenceFactory(
      RuntimeEnvironment.application.getContentResolver(),
      producerFactory,
      null,
      true,
      false,
      null,
      false,
      false,
      false);

  when(mImageRequest.getLowestPermittedRequestLevel())
      .thenReturn(ImageRequest.RequestLevel.FULL_FETCH);
  mUri = Uri.parse("http://dummy");
  when(mImageRequest.getSourceUri()).thenReturn(mUri);
  when(MediaUtils.extractMime(mUri.getPath())).thenReturn(mDummyMime);
  when(MediaUtils.isVideo(mDummyMime)).thenReturn(false);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:ProducerSequenceFactoryTest.java

示例4: onBind

import com.facebook.common.util.UriUtil; //导入依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:FrescoHolder.java

示例5: getNetworkThumbObservable

import com.facebook.common.util.UriUtil; //导入依赖的package包/类
private Observable<String> getNetworkThumbObservable(NSearchRequest request){
    return Observable.concat(new Observable<String>() {
        @Override
        protected void subscribeActual(Observer<? super String> observer) {
            String imageUrl = SPUtil.getValue(APlayerApplication.getContext(),"HttpCache",request.getKey(),"");
            if(!TextUtils.isEmpty(imageUrl) && UriUtil.isNetworkUri(Uri.parse(imageUrl))){
                observer.onNext(imageUrl);
            }
            observer.onComplete();
        }},Observable.just(isAutoDownloadCover())
            .filter(aBoolean -> aBoolean)
            .flatMap(aBoolean -> HttpClient.getNeteaseApiservice()
                    .getNeteaseSearch(request.getKey(), 0, 1, request.getNType())
                    .map(responseBody -> parseNetworkImageUrl(request, responseBody))
    .firstElement().toObservable()));

}
 
开发者ID:rRemix,项目名称:APlayer,代码行数:18,代码来源:ImageUriRequest.java

示例6: onCreateView

import com.facebook.common.util.UriUtil; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.fragment_end, container, false);

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    SimpleDraweeView draweeView = (SimpleDraweeView) view.findViewById(R.id.img);
    Uri uri = new Uri.Builder()
            .scheme(UriUtil.LOCAL_RESOURCE_SCHEME) // "res"
            .path(String.valueOf(R.drawable.img_test))
            .build();
    draweeView.setImageURI(uri);
  }

  return view;
}
 
开发者ID:sperochon,项目名称:DemoFrescoFragment2Fragment,代码行数:17,代码来源:EndFragment.java

示例7: getUriString

import com.facebook.common.util.UriUtil; //导入依赖的package包/类
public static String getUriString(String reel_title_pic){
	int [] bannerResArray = new int[]{
			R.drawable.banner,
			R.drawable.banner3
	};
	Uri uri = new Uri.Builder()
			.scheme(UriUtil.LOCAL_RESOURCE_SCHEME) // "res"
			.path(String.valueOf(
					bannerResArray[(int)(Math.random()*2)]
					//	R.drawable.banner
			))
			.build();
	String uriString;
	uriString = uri.toString();
	if(!reel_title_pic.endsWith("http") &&!TextUtils.isEmpty(reel_title_pic)){
		uriString  = Uri.fromFile(new File(reel_title_pic)).toString();
	}
	return uriString;
}
 
开发者ID:tianyuan168326,项目名称:nono-android,代码行数:20,代码来源:NoteReelArray.java

示例8: validate

import com.facebook.common.util.UriUtil; //导入依赖的package包/类
/** 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.");
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:ImageRequestBuilder.java

示例9: getSourceUriType

import com.facebook.common.util.UriUtil; //导入依赖的package包/类
/**
 * 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;
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:ImageRequest.java

示例10: getEncodedImage

import com.facebook.common.util.UriUtil; //导入依赖的package包/类
@Override
protected EncodedImage getEncodedImage(ImageRequest imageRequest) throws IOException {
  Uri uri = imageRequest.getSourceUri();
  if (UriUtil.isLocalContactUri(uri)) {
    final InputStream inputStream;
    if (uri.toString().endsWith("/photo")) {
      inputStream =  mContentResolver.openInputStream(uri);
    } else {
      inputStream = ContactsContract.Contacts.openContactPhotoInputStream(mContentResolver, uri);
      if (inputStream == null) {
        throw new IOException("Contact photo does not exist: " + uri);
      }
    }
    // If a Contact URI is provided, use the special helper to open that contact's photo.
    return getEncodedImage(
        inputStream,
        EncodedImage.UNKNOWN_STREAM_SIZE);
  }

  if (UriUtil.isLocalCameraUri(uri)) {
    EncodedImage cameraImage = getCameraImage(uri);
    if (cameraImage != null) {
      return cameraImage;
    }
  }

  return getEncodedImage(
      mContentResolver.openInputStream(uri),
      EncodedImage.UNKNOWN_STREAM_SIZE);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:LocalContentUriFetchProducer.java

示例11: getLocalFilePath

import com.facebook.common.util.UriUtil; //导入依赖的package包/类
@Nullable private String getLocalFilePath(ImageRequest imageRequest) {
  Uri uri = imageRequest.getSourceUri();
  if (UriUtil.isLocalFileUri(uri)) {
    return imageRequest.getSourceFile().getPath();
  } else if (UriUtil.isLocalContentUri(uri)) {
    String selection = null;
    String[] selectionArgs = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
        && "com.android.providers.media.documents".equals(uri.getAuthority())) {
      String documentId = DocumentsContract.getDocumentId(uri);
      uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
      selection = MediaStore.Video.Media._ID + "=?";
      selectionArgs = new String[] {documentId.split(":")[1]};
    }
    Cursor cursor =
        mContentResolver.query(
            uri, new String[] {MediaStore.Video.Media.DATA}, selection, selectionArgs, null);
    try {
      if (cursor != null && cursor.moveToFirst()) {
        return cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA));
      }
    } finally {
      if (cursor != null) {
        cursor.close();
      }
    }
  }
  return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:LocalVideoThumbnailProducer.java

示例12: getEncodedImage

import com.facebook.common.util.UriUtil; //导入依赖的package包/类
@Override
protected EncodedImage getEncodedImage(ImageRequest imageRequest) throws IOException {
  Uri uri = imageRequest.getSourceUri();

  if (UriUtil.isLocalCameraUri(uri)) {
    EncodedImage cameraImage = getCameraImage(uri, imageRequest.getResizeOptions());
    if (cameraImage != null) {
      return cameraImage;
    }
  }

  return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:LocalContentUriThumbnailFetchProducer.java

示例13: submitFetchRequest

import com.facebook.common.util.UriUtil; //导入依赖的package包/类
private <T> DataSource<CloseableReference<T>> submitFetchRequest(
    Producer<CloseableReference<T>> producerSequence,
    ImageRequest imageRequest,
    ImageRequest.RequestLevel lowestPermittedRequestLevelOnSubmit,
    Object callerContext) {
  final RequestListener requestListener = getRequestListenerForRequest(imageRequest);

  try {
    ImageRequest.RequestLevel lowestPermittedRequestLevel =
        ImageRequest.RequestLevel.getMax(
            imageRequest.getLowestPermittedRequestLevel(),
            lowestPermittedRequestLevelOnSubmit);
    SettableProducerContext settableProducerContext = new SettableProducerContext(
        imageRequest,
        generateUniqueFutureId(),
        requestListener,
        callerContext,
        lowestPermittedRequestLevel,
      /* isPrefetch */ false,
        imageRequest.getProgressiveRenderingEnabled() ||
            imageRequest.getMediaVariations() != null ||
            !UriUtil.isNetworkUri(imageRequest.getSourceUri()),
        imageRequest.getPriority());
    return CloseableProducerToDataSourceAdapter.create(
        producerSequence,
        settableProducerContext,
        requestListener);
  } catch (Exception exception) {
    return DataSources.immediateFailedDataSource(exception);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:ImagePipeline.java

示例14: load

import com.facebook.common.util.UriUtil; //导入依赖的package包/类
public FrescoLoader load(int resourceId) {
    return load(
            new Uri.Builder()
                    .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
                    .path(String.valueOf(resourceId))
                    .build()
    );
}
 
开发者ID:lizhangqu,项目名称:FrescoLoader,代码行数:9,代码来源:FrescoLoader.java

示例15: lowerLoad

import com.facebook.common.util.UriUtil; //导入依赖的package包/类
public FrescoLoader lowerLoad(int resourceId) {
    return lowerLoad(
            new Uri.Builder()
                    .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
                    .path(String.valueOf(resourceId))
                    .build()
    );
}
 
开发者ID:lizhangqu,项目名称:FrescoLoader,代码行数:9,代码来源:FrescoLoader.java


注:本文中的com.facebook.common.util.UriUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。