AppWidgetTarget doesn't work inside RemoteViewsFactory. How to get around this?

316 Views Asked by At

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)
1

There are 1 best solutions below

3
On

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.