android - KOTLIN:Glide 图像未从 Firebase-Storage 加载到片段中
问题描述
Glide 似乎没有从 Firebase-storage 中的指定路径加载图像。尽管我的代码没有错误并且图像上传没有错误,但我仍然没有在加载时获得更新的片段页面。
声明代码:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == RC_SELECT_IMAGE && resultCode == Activity.RESULT_OK &&
data != null && data.data != null
) {
val selectedImagePath = data.data
val selectedImageBmp = MediaStore.Images.Media
.getBitmap(activity?.contentResolver, selectedImagePath)
val outputStream = ByteArrayOutputStream()
selectedImageBmp.compress(Bitmap.CompressFormat.JPEG, 90, outputStream)
selectedImageBytes = outputStream.toByteArray()
Glide.with(this)
.load(selectedImageBytes)
.into(imageView_profile_picture)
pictureJustChanged = true
}
}
override fun onStart() {
super.onStart()
FirestoreUtil.getCurrentUser { user ->
if (this@HomeFragment.isVisible) {
edittextPersonname.setText(user.name)
editTextBio.setText(user.bio)
editTextTextEmailAddress.setText(user.email)
edittextage.setText(user.age)
if (!pictureJustChanged && user.profilePicturePath != null)
Glide.with(this)
.load(StorageUtil.pathToReference(user.profilePicturePath))
.apply(RequestOptions()
.placeholder(R.drawable.ic_circle))
.into(imageView_profile_picture)
}
}
}
以下是我的 Gradle 库包:
//滑行
implementation 'com.github.bumptech.glide:glide:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'
apply plugin: 'kotlin-kapt'
解决方案
推荐阅读
- linux - Docker 容器未与主机 mariaDB 连接
- wpf - 为什么 Wpf 用户控件多次调用一个方法?
- javascript - 如何从node.js的python-shell中的python代码获取返回值?
- rabbitmq - 如何检查和监控 RabbitMQ 中的活动日志
- report - 如何使 pytest 将失败测试的摘要打印为列表?
- graphviz - PNG文件未在graphviz dot程序中呈现
- git - 从两台计算机上处理一个 git 项目 - 如何避免中间提交?
- sql-server - 来自 SQL 查询的错误格式转换
- oauth-2.0 - 我多久刷新一次 Web 应用程序中的离线访问令牌?
- dart - Dart,将 onClick 事件添加到动态添加的元素