无法使用毕加索从URI加载图像

问题描述

在通过uri在imageview中加载图片时遇到问题。我正在使用毕加索,我的代码如下: 我有一个具有函数displayImageFromURI

的对象CreateImage。
fun displayImageFromURI(imageView: ImageView,uri: Uri?,context: Context){
    Log.e("url",uri.toString())
    Picasso.get()
        .load(uri)
        .fit().centerCrop()
        .into(imageView,object: com.squareup.picasso.Callback {
            override fun onSuccess() {
                val imageBitmap = (imageView.drawable as BitmapDrawable).bitmap
                val imageDrawable =
                    RoundedBitmapDrawableFactory.create(context.resources,imageBitmap)
                imageView.setimageDrawable(imageDrawable)
            }

            override fun onError(e: java.lang.Exception?) {
                Log.e("error",e.toString())
            }
        })
}

我从如下片段中调用函数

if (!photoUrl.equals("")) {
        Log.e("in photo url",photoUrl)
        val image = Uri.parse(photoUrl)
        CreateImage.displayImageFromURI(ivUploadQuestionImage,image,this)
    }

但是我的图像没有加载到imageview中。字符串photoUrl也包含字符串格式的链接。有人可以帮我吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)