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

Created 10 new res-injecting annotations and transformator for them. #27

Closed
wants to merge 2 commits into from
Closed

Conversation

MrBIMC
Copy link
Contributor

@MrBIMC MrBIMC commented May 21, 2015

new Annotations:
(String) @StringRes,
(Integer,int) @IntegerRes,
(Boolean,boolean) @BooleanRes,
(Float,float) @DimenRes,
(Integer,int) @ColorRes,
(String[]) @StringArrayRes,
(int[]) @IntegerArrayRes,
(Drawable) @DrawableRes,
(Animation) @AnimationRes,
(ColorStateList) @ColorStateListRes

Each annotation optionally applies single param(link to resource like R.sting.app_name, R.dimen.awesomeness_level), if annotation is applied without param, transformer will try to access resource by the name of variable.

For now supported only resources from in-app package(i.e. R.), android.R. resources will not work.

@eugene-kamenev
Copy link
Collaborator

Hey, big thanks for contributing, I think PR looks nice. Can't build it
right now.

As a humor: SwissKnife should define TooManyAnnotationsException 👯

@MrBIMC
Copy link
Contributor Author

MrBIMC commented May 23, 2015

When will you accept this?

Cuz I'd like to use SwissKnife through compile "com.arasthel:swissknife:+" rather than importing my local module.

@jmartinesp
Copy link
Owner

I was doing some testing and I found that this:

@IntegerArrayRes(R.array.int_array)
    Integer[] intArray

Will throw this error General error during canonicalization: Annotated field must be int[]. Type: [Ljava.lang.Integer;. I don't know if you only wanted to support int[] or if this is a bug. I'll keep testing a bit.

EDIT: ok, I should read PR messages more carefully. Anyways, this will be merged soon. Thanks.

@jmartinesp
Copy link
Owner

There are a couple of bugs, actually:

@AnimationRes(R.anim.abc_fade_in)
    Animation anim 

Throws: com.arasthel.swissknife.annotations.resources.ResTransformation$WrongTypeException: Annotated field must be Animation. Type: android.view.animation.Animation.

While looking at that, I found some typos on ResTransformation, I have commented them on your commit. I think that with those fixed everything should be fine. Thanks and sorry for taking so long to reply, I've been quite busy lately.

@MrBIMC
Copy link
Contributor Author

MrBIMC commented May 23, 2015

Oh, ok. Sorry for my derps with Animation in int[] typing :D

Added support for Integer[] on @IntegerArrayRes
@MrBIMC
Copy link
Contributor Author

MrBIMC commented May 23, 2015

Ok, let's cancel this one, I'll create new pull request with fixes in a minute.

@MrBIMC MrBIMC closed this May 23, 2015
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.

None yet

3 participants