本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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()));
}
示例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;
}
示例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;
}
示例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.");
}
}
示例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;
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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()
);
}
示例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()
);
}