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

前端 未结 12 2023
栀梦
栀梦 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

    If you want to do this in KOTLIN, you can try that way:

        Glide.with(context)
                .load(url)
                .listener(object : RequestListener {
                    override fun onLoadFailed(e: GlideException?, model: Any?, target: Target?, isFirstResource: Boolean): Boolean {
                        //TODO: something on exception
                    }
                    override fun onResourceReady(resource: Drawable?, model: Any?, target: Target?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
                        Log.d(TAG, "OnResourceReady")
                        //do something when picture already loaded
                        return false
                    }
                })
                .into(imgView)
    

提交回复
热议问题