Glide load local image by Uri.

自作多情 提交于 2019-11-27 12:23:15

While waiting for someone to respond, I tried to make a File instance from the Uri and load that. It works! Weird!

Glide.with(mContext)
    .load(new File(pictureUri.getPath())) // Uri of the picture
    .transform(new CircleTransform(..))
    .into(profileAvatar);

If you pass an Uri instance it better be compliant, it looks like yours doesn't have a schema (file://).

You can check how Uri, String and File models are loaded to debunk the weirdness :)

If it is a file path, it can be passed directly. Tested with Glide 4.8.0

 Glide.with(context)
  .load(pictureUri.getPath())
  .transform(new CircleTransform(..))
  .into(profileAvatar);

Make sure that the Uri is from file.

Uri photoUri = Uri.fromFile( new File( preferences.getPhotoUrl()));

Glide.with(this).load( photoUri).into( civUserProfilePhoto);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!