本文整理汇总了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);
}
示例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()));
}
}
示例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;
}
}
示例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));
}
}
示例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);
}
}
示例6: isImage
import com.facebook.common.media.MediaUtils; //导入依赖的package包/类
public static boolean isImage(Context c, Uri u){
return MediaUtils.isPhoto(extractMimeType(c, u));
}