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


Java MediaUtils类代码示例

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


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

示例1: setUp

import com.facebook.common.media.MediaUtils; //导入依赖的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

示例2: onRun

import com.facebook.common.media.MediaUtils; //导入依赖的package包/类
@Override
public void onRun() throws Throwable {
  Log.i(TAG, "RUNNING UploadJob for Item["+itemId+"] Uri["+uri.toString()+"]");

  if(MediaUtils.isPhoto(UriUtils.extractMimeType(weakReference.get(), uri))) {
    DataSource<CloseableReference<CloseableImage>> dataSource = Fresco.getImagePipeline().fetchDecodedImage(ImageRequest.fromUri(uri), weakReference.get());
    Throwable failureCause = dataSource.getFailureCause();
    if (failureCause != null) {
      throw failureCause;
    }

    CloseableReference<CloseableImage> result = dataSource.getResult();
    if (result != null) {
      CloseableImage closeableImage = result.get();
      if (closeableImage instanceof CloseableBitmap) {
        Bitmap bitmap = ((CloseableBitmap) closeableImage).getUnderlyingBitmap();
        uploadFile(createImageTempFile(bitmap));
      }
    }
  }else{
    uploadFile(new File(uri.getPath()));
  }
}
 
开发者ID:bnsantos,项目名称:android-upload-service,代码行数:24,代码来源:UploadJob.java

示例3: getSourceUriType

import com.facebook.common.media.MediaUtils; //导入依赖的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

示例4: getBasicDecodedImageSequence

import com.facebook.common.media.MediaUtils; //导入依赖的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

示例5: extractMimeType

import com.facebook.common.media.MediaUtils; //导入依赖的package包/类
public static String extractMimeType(Context context, Uri uri){
  File f = new File(uri.getPath());
  if(f.isFile()){
    return MediaUtils.extractMime(f.getPath());
  }else{
    return context.getContentResolver().getType(uri);
  }
}
 
开发者ID:bnsantos,项目名称:android-upload-service,代码行数:9,代码来源:UriUtils.java

示例6: isImage

import com.facebook.common.media.MediaUtils; //导入依赖的package包/类
public static boolean isImage(Context c, Uri u){
  return MediaUtils.isPhoto(extractMimeType(c, u));
}
 
开发者ID:bnsantos,项目名称:android-upload-service,代码行数:4,代码来源:UriUtils.java


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