Skip to content
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

Add Id to ImageResource mapper #229

Closed
ataulm opened this issue Jun 15, 2022 · 2 comments
Closed

Add Id to ImageResource mapper #229

ataulm opened this issue Jun 15, 2022 · 2 comments

Comments

@ataulm
Copy link
Contributor

ataulm commented Jun 15, 2022

fun idToImageResource(id: Int) = ImageResource.Builder()
       .setAndroidResourceByResId(
               AndroidImageResourceByResId.Builder()
                       .setResourceId(id)
                       .build()
       )
       .build()

From here:

https://github.com/joreilly/PeopleInSpace/pull/139/files#diff-4058974ed1ff8fbb817967ab294ee5a8b422543b015c50cf3481cc2fddffbe0cR119-R126

I'm using it for a component audit (in combination with LayoutPreview) but presumably it's handy for the tile renderer too.

Notes:

  • consider adding @DrawableRes to the function
@yschimke
Copy link
Collaborator

+1 to DrawableRes. Also as an extension function on Resources.Builder, it should show up magically inside the Preview blocks and so on.

@yschimke
Copy link
Collaborator

Adding in #235

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

No branches or pull requests

2 participants