Set visibility of progress bar gone on completion of image loading using Glide library

前端 未结 12 2028
栀梦
栀梦 2020-12-04 11:04

Hi I want to have a progress bar for image which will shown while image loading but when image loading will be completed I want to set it to gone. Earlier I was using Picass

12条回答
  •  日久生厌
    2020-12-04 11:25

    Kotlin way

    Glide.with(context)
                    .load(image_url)
                    .listener(object : com.bumptech.glide.request.RequestListener {
                        override fun onLoadFailed(
                            e: GlideException?,
                            model: Any?,
                            target: Target?,
                            isFirstResource: Boolean
                        ): Boolean {
                            return false
                        }
    
                        override fun onResourceReady(
                            resource: Drawable?,
                            model: Any?,
                            target: Target?,
                            dataSource: DataSource?,
                            isFirstResource: Boolean
                        ): Boolean {
                            img_product_banner.visibility = View.VISIBLE
                            return false
                        }
    
                    }).placeholder(R.drawable.placeholder)
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .into(img_product_banner)
    

提交回复
热议问题