【问题标题】:KOTLIN: Glide Image Not Loading into Fragment From Firebase-StorageKOTLIN:Glide 图像未从 Firebase-Storage 加载到片段中
【发布时间】:2020-08-27 09:19:37
【问题描述】:

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 android-fragments android-glide


    【解决方案1】:

    出于某种原因,Android Kotlin Glide v4 要求您在 gradle 项目中声明两次“应用插件”库,即

    一审:

    二审:

    【讨论】:

    • 如果有人有其他更简单的方法,我将不胜感激
    • 下次请复制文字而不是图片
    猜你喜欢
    • 1970-01-01
    • 2016-11-03
    • 2020-09-02
    • 1970-01-01
    • 2018-05-02
    • 1970-01-01
    • 2017-07-28
    • 2022-12-18
    • 2017-05-16
    相关资源
    最近更新 更多