Skip to content

Support for Library Rs#196

Open
johncarl81 wants to merge 21 commits intomasterfrom
LibraryR
Open

Support for Library Rs#196
johncarl81 wants to merge 21 commits intomasterfrom
LibraryR

Conversation

@johncarl81
Copy link
Owner

Android libraries use R classes without public static final (http://tools.android.com/tips/non-constant-fields):

public final class R {
    public static final class anim {
        public static int abc_fade_in=0x7f040000;
        public static int abc_fade_out=0x7f040001;
...

This means you can't reference these fields from an annotation as there are not considered constants. The previous alternative was to use tags, which looses compile time checking. This PR gives an alternative way...

This PR adds a secondary annotation processor to generate a R class with public static final analogies for library public final non-static. Transfuse, in turn, recognizes these analogies and swaps in the original R library identifier. The only requirement is to annotate your source with the Bridge annotation:

@Bridge(R.class)
public class ...

Then you may use RBridge instead of R in any Transfuse annotation:

@Layout(RBridge.layout.main)
@View(RBridge.view.button)

@dbachelder
Copy link
Contributor

❤️

@dbachelder
Copy link
Contributor

@johncarl81 thoughts on merging to master?

@johncarl81
Copy link
Owner Author

johncarl81 commented Jul 11, 2016

I have a couple changes I made recently to be able to publish this on maven central. I have a couple other tweaks to make, mainly to accommodate other libraries that use the base. Then it's time for prime time.

@dbachelder
Copy link
Contributor

great.. do those changes change anything about the usage as I know it right now?

@johncarl81
Copy link
Owner Author

They may affect how you reference the rbridge library.

@johncarl81
Copy link
Owner Author

Ok @dbachelder, could you review the latest changes?

@dbachelder
Copy link
Contributor

@johncarl81 I like that you've moved it into TF proper.. would you mind pushing this up as the snapshot release and I'll try it one more time before we merge it?

@johncarl81
Copy link
Owner Author

Sure, done.

Copy link
Contributor

@dbachelder dbachelder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm ;)

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.

2 participants