-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return drawable with on resource ready callback #16
base: master
Are you sure you want to change the base?
Return drawable with on resource ready callback #16
Conversation
…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.
@@ -50,7 +53,7 @@ public GlideToVectorYou setPlaceHolder(int placeHolderLoading, int placeHolderEr | |||
return instance; | |||
} | |||
|
|||
public void load(Uri uri, ImageView imageView) { | |||
public void load(Uri uri) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@@ -41,11 +41,9 @@ public boolean onLoadFailed(GlideException e, Object model, Target<PictureDrawab | |||
@Override | |||
public boolean onResourceReady(PictureDrawable resource, Object model, | |||
Target<PictureDrawable> target, DataSource dataSource, boolean isFirstResource) { | |||
ImageView view = ((ImageViewTarget<?>) target).getView(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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.