-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Get the Drawable from a success request on Compose #858
Comments
I was able to leverage the transform to grab the bitmap https://stackoverflow.com/q/68094647 |
This should be easier in 2.0 since |
Oh, thats cool and much easier. Is there a way to check when the request is done? maybe checking for changes on the painter and check if it has a successful result? |
@metehus You can use |
@colinrtwhite is it possible to access the drawable in onSuccess? |
Maybe I missed something. Is BitmapPainter have a bitmap property? I can't make this work properly. |
@univeous Ah! Sorry I totally got this wrong and it's not possible to access the bitmap in val painter = rememberImagePainter("https://www.example.com/image.jpg")
val drawable = (painter.state.result as? SuccessResult)?.drawable
Image(painter = painter, contentDescription = null) EDIT: Sorry for the delay. I've held of rolling out the update temporarily to verify that adding this attribute doesn't increase recompositions. |
Is your feature request related to a problem? Please describe.
There's a discussion on #851 about getting the drawable from the
rememberImagePainter
in order to use on other methods (like getting the color palette) without making another request externally.The best way of doing that would be using the
target
from theImageRequest
. But, as seen on the discussion, it is set internally so it's not possible to use that on the image request builder inside therememberImagePainter
Describe the solution you'd like
A solution i see to that would be a callback like the ImageRequest's target on the compose function, like so:
The internal target would pipe the the
onStart
,onError
andonSuccess
from the internal target to the callbacks on the remember function.The text was updated successfully, but these errors were encountered: