I'm trying to show image in RecyclerView
using Fresco. I have image in my file system and i want to display it in SimpleDraweeView
by image location in String
format. But in this view i have empty image. Log doesn't show any error. Can anyone help me? Here's my code where i'm trying to set the image:
imageView.setVisibility(View.VISIBLE);
if (new File(imageData.getLocation()).exists()){
Uri fileLocationUri = Uri.parse("file:/" + imageData.getLocation());
ImageRequest request = ImageRequest.fromUri(fileLocationUri);
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.setOldController(imageView.getController())
.setAutoPlayAnimations(true)
.build();
imageView.setController(controller);
}
Image location is a string, which started with /
, so Uri parser returns correct result. XML file:
<com.facebook.drawee.view.SimpleDraweeView
a:id = "@+id/outgoing_photo_view"
a:layout_width="300dp"
a:layout_height="300dp"
a:adjustViewBounds="true"
a:visibility="gone"
fresco:actualImageScaleType="focusCrop"
fresco:placeholderImageScaleType="fitCenter"
fresco:failureImageScaleType="centerInside"
fresco:retryImageScaleType="centerCrop"
fresco:roundAsCircle="false"
fresco:roundedCornerRadius="1dp"
fresco:roundTopLeft="true"
fresco:roundTopRight="false"
fresco:roundBottomLeft="false"
fresco:roundBottomRight="true"
fresco:roundingBorderWidth="2dp"/>
I guess your file URI is not valid.
It should work with something like this:
File file = ... // your file
Uri uri = Uri.fromFile(file); // to get a valid file:// URI
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setUri(uri)
.build();