-2

There is not enough documentation or blogs around this topic.

Can someone point me in the right direction? Tried this in getView. Works on an imageview that is not part of item of listview.

                 val articleImage: AppWidgetTarget = object : AppWidgetTarget(appContext, R.id.article_image, views, appWidgetId) {
                    override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
                        super.onResourceReady(resource, transition)
                    }
                }

                val options = RequestOptions()
                    .override(62, 62)
                    .placeholder(R.drawable.news_thumbnail)
                    .error(R.drawable.news_thumbnail)

                Glide
                    .with(appContext)
                    .asBitmap()
                    .load("/*URL*/")
                    .apply(options)
                    .into(articleImage)
suhas_sm
  • 2,064
  • 1
  • 18
  • 23
  • This has been answered in [here](https://stackoverflow.com/questions/24771297/picasso-load-images-to-widget-listview#comment121484613_27851642) It uses Picasso instead of Glide. – suhas_sm Aug 11 '21 at 11:24
  • That is a different solution. A good workaround if you are looking to load images in `RemoteViewsFactory` – suhas_sm Aug 11 '21 at 11:33

1 Answers1

1

AppWidgetTarget appears to be for an ImageView directly in the app widget's layout, as it uses updateAppWidget() to push over the change. It does not appear to tie into a RemoteViewsFactory, which is how you populate an AdapterView inside of an app widget.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Right. Makes sense looking at code. Is there no straight or out-of-the-box solution to achieve this? – suhas_sm Aug 11 '21 at 10:44
  • @suhas_sm: I did not see a suitable `Target` in that Glide directory, and I am uncertain if it is even possible. I do not know of a "push" mechanism for `RemoteViewsFactory`, such that you could update a row in your list when the image arrived. – CommonsWare Aug 11 '21 at 10:50
  • 1
    A different solution works. Commented under the question. Thanks, Mark. – suhas_sm Aug 11 '21 at 11:35