-1

I am making a Widget and in the Widget service in the getViewAt method i have set corrently the text to my widget but it is complicated to pass my images from my object.

@Override
    public RemoteViews getViewAt(int position) {

        RemoteViews views = new RemoteViews(mContext.getPackageName(), R.layout.widget_item);
        Automoviles autoService=mArraylistAutomoviles.get(position);
        String imagen=autoService.getImagen();
        String marca =autoService.getMarca();


//        int imagenInt= Integer.parseInt(imagen);

        // Update the plant image
        views.setImageViewResource(R.id.widget_image_item, R.drawable.mazda2azul);

        views.setTextViewText(R.id.textView,marca);


        return views;

    }

Notice that in order to retreive the images i need to use Glide(Thats what i use in my project) .At the moment i have R.drawable.mazda2azul that is an int so the method doesnt complain .String imagen=autoService.getImagen return the following Url = https://firebasestorage.googleapis.com/v0/b/udacitycapstonefinal.appspot.com/o/CarImages%2Fford_escape_negra.jpeg?alt=media&token=89ea95d3-852c-4d24-9f09-b9ef519928a3

I tried to do int imagenInt= Integer.parseInt(imagen); but it didnt load the widget images or Text .

So i need a way to do the Glide part and pass it to the setImageResource second parameter. This is my big problem.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Felipe Franco
  • 171
  • 3
  • 15

1 Answers1

0

You can use this method:

Bitmap bitmap = Glide.
    with(context).
    load(imagen).
    asBitmap().get();
views.setImageViewBitmap(R.id.widget_image_item, bitmap);
Vladyslav Matviienko
  • 10,610
  • 4
  • 33
  • 52