Skip to content

Conversation

@abhriyaroy
Copy link

Returning the drawable as a callback will allow the user to use the drawable as any manner which seems fit and not just bound to setting it to an Imageview.

Abhriya added 4 commits March 4, 2021 20:08
…b.com:abhriyaroy/GlideToVectorYou into return-drawable_with-onResourceReady-callback
When using a listener, the drawable obtained in the callback can be used instead of supplying an imageview as an extra argument. This will cater to the cases, where the user only wants to load a PictureDrawable without setting it to any specific imageview.
}

public void load(Uri uri, ImageView imageView) {
public void load(Uri uri) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break existing implementations. Maybe add a new method with the method signature that you want?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Kept the older method and just added a new one.

@Override
public boolean onResourceReady(PictureDrawable resource, Object model,
Target<PictureDrawable> target, DataSource dataSource, boolean isFirstResource) {
ImageView view = ((ImageViewTarget<?>) target).getView();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to keep this as is for backward compatibility as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I didn't consider backward compatibility. Have modified the same.

public interface GlideToVectorYouListener {
void onLoadFailed();
void onResourceReady();
void onResourceReady(PictureDrawable pictureDrawable);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on whether the PictureDrawable can be null or not, an annotation here would be helpful. For Kotlin usages

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added @Nullable

- Add support for backward compaitibility by keeping previous method for normal loading
- Add nullable annotation to onResourceReady
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants