Class ‘Anonymous class derived from Callback’ must either be declared abstract or implement abstract method ‘onError(Exception)’ in ‘Callback’
I am opening an old project. Now how to solve this problem?
my code is:
Picasso.get().load(p.getImageUrl()).into(iv, new Callback() {
@Override
public void onSuccess() {
Bitmap bitmap = convertImageViewToBitmap(iv);
Bitmap hiResBitmap = getResizedBitmap(bitmap, 600, 1000);
iv.setImageBitmap(hiResBitmap);
// iv.setImageBitmap(bitmap);
iv.setVisibility(View.VISIBLE);
// saveImageAndSavePathToSharedPrefrence(bitmap, p.getPost_id());
Log.i(TAG, "onSuccess: From WebUrl " + " Position : " + position + " PostId: " + p.getPost_id() + " Url : " + p.getImageUrl());
tvPhotoLink.setText("Photo Link");
tvPhotoLink.setTextColor(Color.BLUE);
tvPhotoLink.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
go_to_website(p.getImageUrl());
}
});
tvPhotoLink.setVisibility(View.VISIBLE);
}
@Override
public void onError() {
Log.i(TAG, "onSuccess:3_0 Picasso Error: from Net " + " Image Position Url is not Valid: " + "ImageUrl is : " + p.getImageUrl());
tvPhotoLink.setVisibility(View.GONE);
iv.setVisibility(View.GONE);
}
});
I want to run the file and find the solution
2
Answers
In the snippet the wrong signature of
onError()
is used, so the required method is not implemented. Please try replacing the linepublic void onError() {
withpublic void onError(Exception e) {
Error message is telling you that your anonymous class derived from Callback must implement the abstract method
onError(Exception)
. In your code, you have implementedonError()
without an Exception parameter. You need to modify your onError method to take an Exception as a parameter.see for reference: https://square.github.io/picasso/2.x/picasso/com/squareup/picasso/Callback.html