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


Java ImageRequest.getSourceUri方法代码示例

本文整理汇总了Java中com.facebook.imagepipeline.request.ImageRequest.getSourceUri方法的典型用法代码示例。如果您正苦于以下问题:Java ImageRequest.getSourceUri方法的具体用法?Java ImageRequest.getSourceUri怎么用?Java ImageRequest.getSourceUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.imagepipeline.request.ImageRequest的用法示例。


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

示例1: getEncodedImageProducerSequence

import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
/**
 * Returns a sequence that can be used for a request for an encoded image from either network or
 * local files.
 *
 * @param imageRequest the request that will be submitted
 * @return the sequence that should be used to process the request
 */
public Producer<CloseableReference<PooledByteBuffer>> getEncodedImageProducerSequence(
    ImageRequest imageRequest) {
  validateEncodedImageRequest(imageRequest);
  final Uri uri = imageRequest.getSourceUri();

  switch (imageRequest.getSourceUriType()) {
    case SOURCE_TYPE_NETWORK:
      return getNetworkFetchEncodedImageProducerSequence();
    case SOURCE_TYPE_LOCAL_VIDEO_FILE:
    case SOURCE_TYPE_LOCAL_IMAGE_FILE:
      return getLocalFileFetchEncodedImageProducerSequence();
    default:
      throw new IllegalArgumentException(
          "Unsupported uri scheme for encoded image fetch! Uri is: "
              + getShortenedUriString(uri));
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:ProducerSequenceFactory.java

示例2: getEncodedImagePrefetchProducerSequence

import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
/**
 * Returns a sequence that can be used for a prefetch request for an encoded image.
 *
 * <p>Guaranteed to return the same sequence as
 * {@code getEncodedImageProducerSequence(request)}, except that it is pre-pended with a
 * {@link SwallowResultProducer}.
 * @param imageRequest the request that will be submitted
 * @return the sequence that should be used to process the request
 */
public Producer<Void> getEncodedImagePrefetchProducerSequence(ImageRequest imageRequest) {
  validateEncodedImageRequest(imageRequest);

  switch (imageRequest.getSourceUriType()) {
    case SOURCE_TYPE_NETWORK:
      return getNetworkFetchToEncodedMemoryPrefetchSequence();
    case SOURCE_TYPE_LOCAL_VIDEO_FILE:
    case SOURCE_TYPE_LOCAL_IMAGE_FILE:
      return getLocalFileFetchToEncodedMemoryPrefetchSequence();
    default:
      final Uri uri = imageRequest.getSourceUri();
      throw new IllegalArgumentException(
          "Unsupported uri scheme for encoded image fetch! Uri is: "
              + getShortenedUriString(uri));
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:ProducerSequenceFactory.java

示例3: getEncodedImage

import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的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

示例4: getEncodedImage

import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
@Override
protected EncodedImage getEncodedImage(final ImageRequest imageRequest) throws IOException {
  final Uri uri = imageRequest.getSourceUri();
  final InputStream inputStream = mContentResolver.openInputStream(uri);

  return getEncodedImage(inputStream, EncodedImage.UNKNOWN_STREAM_SIZE);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:QualifiedResourceFetchProducer.java

示例5: getLocalFilePath

import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的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

示例6: getEncodedImage

import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的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

示例7: getBasicDecodedImageSequence

import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
private Producer<CloseableReference<CloseableImage>> getBasicDecodedImageSequence(
    ImageRequest imageRequest) {
  Preconditions.checkNotNull(imageRequest);

  Uri uri = imageRequest.getSourceUri();
  Preconditions.checkNotNull(uri, "Uri is null.");

  switch (imageRequest.getSourceUriType()) {
    case SOURCE_TYPE_NETWORK:
      return getNetworkFetchSequence();
    case SOURCE_TYPE_LOCAL_VIDEO_FILE:
      return getLocalVideoFileFetchSequence();
    case SOURCE_TYPE_LOCAL_IMAGE_FILE:
      return getLocalImageFileFetchSequence();
    case SOURCE_TYPE_LOCAL_CONTENT:
      if (MediaUtils.isVideo(mContentResolver.getType(uri))) {
        return getLocalVideoFileFetchSequence();
      }
      return getLocalContentUriFetchSequence();
    case SOURCE_TYPE_LOCAL_ASSET:
      return getLocalAssetFetchSequence();
    case SOURCE_TYPE_LOCAL_RESOURCE:
      return getLocalResourceFetchSequence();
    case SOURCE_TYPE_QUALIFIED_RESOURCE:
      return getQualifiedResourceFetchSequence();
    case SOURCE_TYPE_DATA:
      return getDataFetchSequence();
    default:
      throw new IllegalArgumentException(
          "Unsupported uri scheme! Uri is: " + getShortenedUriString(uri));
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:ProducerSequenceFactory.java


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