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

Pass style res to @OnCreateMountContent #80

Open
emilsjolander opened this issue Apr 12, 2017 · 1 comment
Open

Pass style res to @OnCreateMountContent #80

emilsjolander opened this issue Apr 12, 2017 · 1 comment

Comments

@emilsjolander
Copy link
Contributor

There are Views in Android that only accept some attributes when the view is created and can't be changed after that (e.g. android:textCursorDrawable in EditText). We need a way to pass down these attribute sets into @OnCreateMountContent to allow android widgets to be constructed with them.

Code pointers

https://github.com/facebook/litho/blob/master/litho-core/src/main/java/com/facebook/litho/ComponentLifecycle.java#L414

https://github.com/facebook/litho/blob/master/litho-processor/src/main/java/com/facebook/litho/specmodels/processor/MountSpecModelFactory.java#L104

Point of contact: @emilsjolander

@dmayle
Copy link

dmayle commented Oct 12, 2017

There's no "supported" way of doing this. the obtainStyledAttributes() method used to retrieve custom attributes is implemented in ResourcesImpl.java (in AOSP) and it casts the received attribute set to XmlBlock.Parser, which is a package private final class that has hooks into native code. If you were willing to use reflection to hack into these classes and hook into the classloader to do runtime injection inheriting from the classes unlocked by reflection, it would theoretically be possible... but the effort required is staggeringly large

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants