image not loading from URL in custom infoWindow using Picasso image loading library in android

前端 未结 3 1480
孤独总比滥情好
孤独总比滥情好 2020-12-09 13:46

I am trying to load an image from the URL in custom infoWindow when the user click on the marker. I was able to load the other details but the image is not loading int it. i

3条回答
  •  爱一瞬间的悲伤
    2020-12-09 14:06

    mMap.setInfoWindowAdapter(object : GoogleMap.InfoWindowAdapter { override fun getInfoContents(p0: Marker?): View? { return null }

            override fun getInfoWindow(p0: Marker?): View? {
    
                if (p0!!.tag != null) {
                    val view = LayoutInflater.from(this@ProviderMainActivity).inflate(R.layout.infowindow_client, null)
                    val text = view.findViewById(R.id.TXT_NAME)
                    val TXT_location = view.findViewById(R.id.TXT_location)
                    val proimg = view.findViewById(R.id.IMG)
                    val datares = p0!!.tag as ResponseDataItem
    
                    Glide.with(this@ProviderMainActivity).load(datares.user!!.profileImageWithURL)
                        .apply(RequestOptions.circleCropTransform().override(50,50).placeholder(R.drawable.placeholder_profile))
                        .listener(object :RequestListener{
                            override fun onLoadFailed(
                                e: GlideException?,
                                model: Any?,
                                target: Target?,
                                isFirstResource: Boolean
                            ): Boolean {
                                return true
                            }
    
                            override fun onResourceReady(
                                resource: Drawable?,
                                model: Any?,
                                target: Target?,
                                dataSource: DataSource?,
                                isFirstResource: Boolean
                            ): Boolean {
                                Klog.d("## FIRST RESOURCE-","-".plus(isFirstResource))
                                Klog.d("## FIRST DATA SOURCE-","-".plus(dataSource?.name))
                                proimg.setImageDrawable(resource)
                                if (dataSource?.name.equals("DATA_DISK_CACHE")) {
                                    p0.showInfoWindow()
                                }
                                return true
                            }
    
                        }).into(proimg)
                    text.setText(datares.user!!.fullName)
                    var loc = datares.location!!.text!!.split(",").map { it.trim() }
                    TXT_location.setText(loc.get(0))
    
                    return view
                } else {
                    return null
                }
            }
        })
    

提交回复
热议问题