Question

I downloaded the Picasso image cache library and tried to get the sample code to work. I set up an Android project from the existing code, included the picasso-2.2.0.jar and android-support-v4.jar

However, when I tried to compile and run it, it says there are errors in the PicassoSampleAdapter and SampleWidgetProvider files.

This is the line in question:

picasso.load(Data.URLS[new Random().nextInt(Data.URLS.length)]) //
    .placeholder(R.drawable.placeholder) //
    .error(R.drawable.error) //
    .transform(new GrayscaleTransformation(picasso)) //
    .into(updateViews, R.id.image, appWidgetIds);

And this is the error:

The method into(ImageView, Callback) in the type RequestCreator is not applicable for the arguments (RemoteViews, int, int[])

I checked the documentation on the picasso website and indeed, into takes those two parameters. It seems inconceivable to me that there'd be an error like this on such a great library, so I'm thinking it must be something I'm not doing right when setting this up? The other files do not have errors in them, so I believe I've set things up right.

Can anyone help? Do you have the same error when you try to set up the sample project and run it?

Was it helpful?

Solution

The sample on master is for the code on master. That is, it only works with the Picasso library that also exists on master (2.3.0-SNAPSHOT). The RemoteView variant of the into() API hasn't been released yet.

If you are using version 2.2.0, you need to use the sample from version 2.2.0 which can be found here: https://github.com/square/picasso/tree/picasso-parent-2.2.0/picasso-sample (note the matching tag in the URL).

OTHER TIPS

https://github.com/square/picasso/blob/master/picasso/src/main/java/com/squareup/picasso/RequestCreator.java

into method takes one or two parameters. Pass your imageView instance there.

Error is at line where you are calling .into(updateViews, R.id.image, appWidgetIds); It has three variants as mentioned here http://square.github.io/picasso/javadoc/index.html. You can change it to .into(updateViews) and it should work. Assuming updateViews is the ImageView you want to load the final image into.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top