https://kotlinlang.org logo
#compose
Title
# compose
l

Luca Nicoletti

11/19/2019, 3:36 PM
Is it possible that
imageFromResource
does not work in
repo
?
I added a drawable but that always return
null
a

Adam Powell

11/19/2019, 3:38 PM
is it a bitmap or a vector? at the moment it only does bitmaps
l

Luca Nicoletti

11/19/2019, 3:39 PM
the old fashioned 5 .png files 😄
Oh, actually, it also has a
xml
for
anyDp
Can this be the problem?
a

Adam Powell

11/19/2019, 3:40 PM
Could be
l

Luca Nicoletti

11/19/2019, 3:40 PM
It was
a

Adam Powell

11/19/2019, 3:40 PM
I'm agitating for something
Drawable
-like in compose but without `Drawable`'s regrets
not there yet though 🙂
l

Luca Nicoletti

11/19/2019, 3:40 PM
Removing the
xml
files now won’t crash the app 😄
a

Adam Powell

11/19/2019, 3:41 PM
the current situation with vectors being handled at composition time makes things awkward
r

romainguy

11/19/2019, 4:11 PM
@Adam Powell Drawables without all the things that make them more like widgets would be fine
a

Adam Powell

11/19/2019, 4:15 PM
Yeah exactly
Model observation should give us nearly everything we need in terms of smarts where it's needed
l

Luca Nicoletti

11/19/2019, 4:16 PM
🤔
a

Adam Powell

11/19/2019, 4:17 PM
Invalidation for changes stays implicit, if something in a drawable is backed by
@Model
then that value changing will trigger redraw
👍 1
l

Luca Nicoletti

11/19/2019, 4:18 PM
how is this related to getting a
null
value when there’s also a
xml
for
anyDp
?
a

Adam Powell

11/19/2019, 4:18 PM
Same with any kind of preferred size being read by the composable that lays out and draws it
Just that we can unify vectors and bitmaps so you don't have to see this distinction
One resource load that just works
l

Luca Nicoletti

11/19/2019, 4:19 PM
Oh, I see, it was an internal discussion 😄
a

Adam Powell

11/19/2019, 4:19 PM
Yeah, just giving a view inside 🙂
l

Luca Nicoletti

11/19/2019, 4:20 PM
👀
r

romainguy

11/19/2019, 4:21 PM
imageResource
blindly tries to decode a bitmap which is why you get null
An XML is not a bitmap
l

Luca Nicoletti

11/19/2019, 4:21 PM
Yeah I know that
My question was more: why is it retrieving the
xml
file alongside all the ones available
a

Adam Powell

11/19/2019, 4:25 PM
It was the variant of that drawable selected for your current configuration
Android resources treat the two as equivalent in terms of identity
And compose isn't currently set up to play as nicely with that as it needs to be
2 Views