KOTLIN:Glide 图像未从 Firebase 存储加载到片段中
KOTLIN: Glide Image Not Loading into Fragment From 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'
出于某种原因,Android Kotlin Glide v4 要求您在 gradle 项目中声明“应用插件”库两次,即
一审:
二审:
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'
出于某种原因,Android Kotlin Glide v4 要求您在 gradle 项目中声明“应用插件”库两次,即
一审:
二审: