Java 类com.facebook.common.util.UriUtil 实例源码

项目:GitHub    文件:DecodeProducer.java   
@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);
}
项目:GitHub    文件:QualifiedResourceFetchProducerTest.java   
@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);
}
项目:GitHub    文件:ProducerSequenceFactoryTest.java   
@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);
}
项目:GitHub    文件:FrescoHolder.java   
@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);
}
项目:APlayer    文件:ImageUriRequest.java   
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()));

}
项目:DemoFrescoFragment2Fragment    文件:EndFragment.java   
@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;
}
项目:nono-android    文件:NoteReelArray.java   
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;
}
项目:nono-android    文件:NoteReelArray.java   
public String getUriString(){
    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)(id%2)]
                //  R.drawable.banner
            ))
            .build();
    String uriString;
    uriString = uri.toString();
    if(reel_title_pic.startsWith("http") ){
        uriString = reel_title_pic;
    }else if(!TextUtils.isEmpty(reel_title_pic)){
        uriString  = Uri.fromFile(new File(reel_title_pic)).toString();
    }
    return uriString;
}
项目:fresco    文件:DecodeProducer.java   
@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);
}
项目:fresco    文件:QualifiedResourceFetchProducerTest.java   
@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);
}
项目:fresco    文件:ProducerSequenceFactoryTest.java   
@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);
}
项目:fresco    文件:FrescoHolder.java   
@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);
}
项目:GitHub    文件:ImageRequestBuilder.java   
/** 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.");
  }
}
项目:GitHub    文件:ImageRequest.java   
/**
 * 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;
  }
}
项目:GitHub    文件:LocalContentUriFetchProducer.java   
@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);
}
项目:GitHub    文件:LocalVideoThumbnailProducer.java   
@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;
}
项目:GitHub    文件:LocalContentUriThumbnailFetchProducer.java   
@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;
}
项目:GitHub    文件:ImagePipeline.java   
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);
  }
}
项目:FrescoLoader    文件:FrescoLoader.java   
public FrescoLoader load(int resourceId) {
    return load(
            new Uri.Builder()
                    .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
                    .path(String.valueOf(resourceId))
                    .build()
    );
}
项目:FrescoLoader    文件:FrescoLoader.java   
public FrescoLoader lowerLoad(int resourceId) {
    return lowerLoad(
            new Uri.Builder()
                    .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
                    .path(String.valueOf(resourceId))
                    .build()
    );
}
项目:GongXianSheng    文件:FrecoFactory.java   
/**
     * 自定义控件调用该方法显示
     * @param draweeView
     * @param uri
     * @param resizeOptions
     * @param defaultDrawable
     * @param scaleType
     */
    public void disPlay(DraweeView draweeView, Uri uri, String lowResUri, ResizeOptions resizeOptions, Drawable defaultDrawable, ScalingUtils.ScaleType scaleType, ControllerListener controllerListener) {
//        System.out.println(draweeView.hasHierarchy());
        if (!draweeView.hasHierarchy()) {
            setDefaultHierarchy(draweeView,defaultDrawable,scaleType);
        }
        ImageRequestBuilder imageRequestBuilder =
                ImageRequestBuilder.newBuilderWithSource(uri);
        if (UriUtil.isNetworkUri(uri)) {
            imageRequestBuilder.setProgressiveRenderingEnabled(true);
        }
        else {
            imageRequestBuilder.setLocalThumbnailPreviewsEnabled(true);
            imageRequestBuilder.setProgressiveRenderingEnabled(false);
            if ( resizeOptions != null ) {
                imageRequestBuilder.setResizeOptions(resizeOptions);
            }
        }
//        imageRequestBuilder.setAutoRotateEnabled(true);
//        imageRequestBuilder.setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH);
        DraweeController draweeController = Fresco.newDraweeControllerBuilder()
                .setImageRequest(imageRequestBuilder.build())
                .setOldController(draweeView.getController())
                .setLowResImageRequest(ImageRequest.fromUri(lowResUri))
                .setControllerListener(controllerListener)
                .build();
        draweeView.setController(draweeController);
    }
项目:WindowImageView    文件:WindowImageView.java   
public Uri getUri() {
    if (resUri == null) {
        if (resId == 0) {
            return null;
        }
        return UriUtil.getUriForResourceId(resId);
    }
    return resUri;
}
项目:RNLearn_Project1    文件:FrescoBasedReactTextInlineImageShadowNode.java   
private static @Nullable Uri getResourceDrawableUri(Context context, @Nullable String name) {
  if (name == null || name.isEmpty()) {
    return null;
  }
  name = name.toLowerCase(Locale.getDefault()).replace("-", "_");
  int resId = context.getResources().getIdentifier(
    name,
    "drawable",
    context.getPackageName());
  return new Uri.Builder()
    .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
    .path(String.valueOf(resId))
    .build();
}
项目:RNLearn_Project1    文件:ReactImageView.java   
private boolean shouldResize(ImageSource imageSource) {
  // Resizing is inferior to scaling. See http://frescolib.org/docs/resizing-rotating.html#_
  // We resize here only for images likely to be from the device's camera, where the app developer
  // has no control over the original size
  if (mResizeMethod == ImageResizeMethod.AUTO) {
    return
      UriUtil.isLocalContentUri(imageSource.getUri()) ||
      UriUtil.isLocalFileUri(imageSource.getUri());
  } else if (mResizeMethod == ImageResizeMethod.RESIZE) {
    return true;
  } else {
    return false;
  }
}
项目:RNLearn_Project1    文件:FrescoBasedReactTextInlineImageShadowNode.java   
private static @Nullable Uri getResourceDrawableUri(Context context, @Nullable String name) {
  if (name == null || name.isEmpty()) {
    return null;
  }
  name = name.toLowerCase(Locale.getDefault()).replace("-", "_");
  int resId = context.getResources().getIdentifier(
    name,
    "drawable",
    context.getPackageName());
  return new Uri.Builder()
    .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
    .path(String.valueOf(resId))
    .build();
}
项目:RNLearn_Project1    文件:ReactImageView.java   
private boolean shouldResize(ImageSource imageSource) {
  // Resizing is inferior to scaling. See http://frescolib.org/docs/resizing-rotating.html#_
  // We resize here only for images likely to be from the device's camera, where the app developer
  // has no control over the original size
  if (mResizeMethod == ImageResizeMethod.AUTO) {
    return
      UriUtil.isLocalContentUri(imageSource.getUri()) ||
      UriUtil.isLocalFileUri(imageSource.getUri());
  } else if (mResizeMethod == ImageResizeMethod.RESIZE) {
    return true;
  } else {
    return false;
  }
}
项目:ReactNativeSignatureExample    文件:FrescoBasedReactTextInlineImageShadowNode.java   
private static @Nullable Uri getResourceDrawableUri(Context context, @Nullable String name) {
  if (name == null || name.isEmpty()) {
    return null;
  }
  name = name.toLowerCase(Locale.getDefault()).replace("-", "_");
  int resId = context.getResources().getIdentifier(
    name,
    "drawable",
    context.getPackageName());
  return new Uri.Builder()
    .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
    .path(String.valueOf(resId))
    .build();
}
项目:ReactNativeSignatureExample    文件:ResourceDrawableIdHelper.java   
public Uri getResourceDrawableUri(Context context, @Nullable String name) {
  int resId = getResourceDrawableId(context, name);
  return resId > 0 ? new Uri.Builder()
      .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
      .path(String.valueOf(resId))
      .build() : Uri.EMPTY;
}
项目:GalleryFinal-master    文件:FrescoImageLoader.java   
@Override
public void displayImage(Activity activity, String path, GFImageView imageView, Drawable defaultDrawable, int width, int height) {
    Resources resources = context.getResources();
    GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(resources)
            .setFadeDuration(300)
            .setPlaceholderImage(defaultDrawable)
            .setFailureImage(defaultDrawable)
            .setProgressBarImage(new ProgressBarDrawable())
            .build();
    final DraweeHolder<GenericDraweeHierarchy> draweeHolder = DraweeHolder.create(hierarchy, context);
    imageView.setOnImageViewListener(new GFImageView.OnImageViewListener() {
        @Override
        public void onDetach() {
            draweeHolder.onDetach();
        }

        @Override
        public void onAttach() {
            draweeHolder.onAttach();
        }

        @Override
        public boolean verifyDrawable(Drawable dr) {
            if (dr == draweeHolder.getHierarchy().getTopLevelDrawable()) {
                return true;
            }
            return false;
        }
    });
    Uri uri = new Uri.Builder()
            .scheme(UriUtil.LOCAL_FILE_SCHEME)
            .path(path)
            .build();
    displayImage(uri, new ResizeOptions(width, height), imageView, draweeHolder);
}
项目:react-native-ibeacon-android    文件:FrescoBasedReactTextInlineImageShadowNode.java   
private static @Nullable Uri getResourceDrawableUri(Context context, @Nullable String name) {
  if (name == null || name.isEmpty()) {
    return null;
  }
  name = name.toLowerCase(Locale.getDefault()).replace("-", "_");
  int resId = context.getResources().getIdentifier(
    name,
    "drawable",
    context.getPackageName());
  return new Uri.Builder()
    .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
    .path(String.valueOf(resId))
    .build();
}
项目:react-native-ibeacon-android    文件:ResourceDrawableIdHelper.java   
public Uri getResourceDrawableUri(Context context, @Nullable String name) {
  int resId = getResourceDrawableId(context, name);
  return resId > 0 ? new Uri.Builder()
      .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
      .path(String.valueOf(resId))
      .build() : Uri.EMPTY;
}
项目:ultra-music-player    文件:AlbumArtLoader.java   
public static void initializeDefaultArt() {
    try {
        defaultUri = new Uri.Builder()
                .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
                .path(String.valueOf(R.drawable.default_art))
                .build();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:react-native-box-loaders    文件:FrescoBasedReactTextInlineImageShadowNode.java   
private static @Nullable Uri getResourceDrawableUri(Context context, @Nullable String name) {
  if (name == null || name.isEmpty()) {
    return null;
  }
  name = name.toLowerCase(Locale.getDefault()).replace("-", "_");
  int resId = context.getResources().getIdentifier(
    name,
    "drawable",
    context.getPackageName());
  return new Uri.Builder()
    .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
    .path(String.valueOf(resId))
    .build();
}
项目:react-native-box-loaders    文件:ResourceDrawableIdHelper.java   
public Uri getResourceDrawableUri(Context context, @Nullable String name) {
  int resId = getResourceDrawableId(context, name);
  return resId > 0 ? new Uri.Builder()
      .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
      .path(String.valueOf(resId))
      .build() : Uri.EMPTY;
}
项目:Ironman    文件:FrescoBasedReactTextInlineImageShadowNode.java   
private static @Nullable Uri getResourceDrawableUri(Context context, @Nullable String name) {
  if (name == null || name.isEmpty()) {
    return null;
  }
  name = name.toLowerCase(Locale.getDefault()).replace("-", "_");
  int resId = context.getResources().getIdentifier(
    name,
    "drawable",
    context.getPackageName());
  return new Uri.Builder()
    .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
    .path(String.valueOf(resId))
    .build();
}
项目:Ironman    文件:ReactImageView.java   
private boolean shouldResize(ImageSource imageSource) {
  // Resizing is inferior to scaling. See http://frescolib.org/docs/resizing-rotating.html#_
  // We resize here only for images likely to be from the device's camera, where the app developer
  // has no control over the original size
  if (mResizeMethod == ImageResizeMethod.AUTO) {
    return
      UriUtil.isLocalContentUri(imageSource.getUri()) ||
      UriUtil.isLocalFileUri(imageSource.getUri());
  } else if (mResizeMethod == ImageResizeMethod.RESIZE) {
    return true;
  } else {
    return false;
  }
}
项目:react-native-navigation    文件:ResourceDrawableIdHelper.java   
public Uri getResourceDrawableUri(Context context, @Nullable String name) {
    int resId = getResourceDrawableId(context, name);
    return resId > 0 ? new Uri.Builder()
            .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
            .path(String.valueOf(resId))
            .build() : Uri.EMPTY;
}
项目:DemoFrescoFragment2Fragment    文件:MyAdapter.java   
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
  SimpleDraweeView draweeView = holder.imgView;
  Uri uri = new Uri.Builder()
          .scheme(UriUtil.LOCAL_RESOURCE_SCHEME) // "res"
          .path(String.valueOf(R.drawable.img_test))
          .build();
  draweeView.setImageURI(uri);
}
项目:wechat-gallery    文件:FrescoImageLoader.java   
public void displayImage(Context context, String path, GFImageView imageView, int width, int height) {
        Resources resources = context.getResources();
        Drawable defaultDrawable = ContextCompat.getDrawable(context, R.drawable.common_crop_image_placeholder);
//        imageView.setImageDrawable(defaultDrawable);
        imageView.setImageDrawable(null);
        GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(resources)
                .setFadeDuration(300)
                .setPlaceholderImage(defaultDrawable)
                .setFailureImage(defaultDrawable)
                .setProgressBarImage(new ProgressBarDrawable())
                .build();
        final DraweeHolder<GenericDraweeHierarchy> draweeHolder = DraweeHolder.create(hierarchy, context);
        imageView.setOnImageViewListener(new GFImageView.OnImageViewListener() {
            @Override
            public void onDetach() {
                draweeHolder.onDetach();
            }

            @Override
            public void onAttach() {
                draweeHolder.onAttach();
            }

            @Override
            public boolean verifyDrawable(Drawable dr) {
                if (dr == draweeHolder.getHierarchy().getTopLevelDrawable()) {
                    return true;
                }
                return false;
            }
        });
        Uri uri = new Uri.Builder()
                .scheme(UriUtil.LOCAL_FILE_SCHEME)
                .path(path)
                .build();
        displayImage(uri, new ResizeOptions(width, height), imageView, draweeHolder);
    }
项目:react-native-imagewand    文件:RNImageWand.java   
private static Uri getResourceDrawableUri(Context context, @Nullable String name) {
    int resId = getResourceDrawableId(context, name);
    return resId > 0 ? new Uri.Builder()
            .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
            .path(String.valueOf(resId))
            .build() : Uri.EMPTY;
}