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

Overload inject to accept just a Fragment #8

Closed
robisaks opened this issue Feb 24, 2015 · 4 comments
Closed

Overload inject to accept just a Fragment #8

robisaks opened this issue Feb 24, 2015 · 4 comments

Comments

@robisaks
Copy link

If the preference injector is added to a fragment, it does not appear to populate the fields correctly.

denley added a commit that referenced this issue Feb 24, 2015
@denley
Copy link
Owner

denley commented Feb 24, 2015

I've just tested using a Fragment, and it appears to work fine for me. Can you elaborate on the problem? If you could provide a sample of code that is not working as expected it would help.

I added the test I just made to the sample module, so you can now see a sample case using a Fragment there: https://github.com/denley/PreferenceInjector/blob/master/sample/src/main/java/me/denley/preferenceinjector/SampleFragment.java

The only real difference is that you have to use PreferenceInjector.inject(getActivity(), this) for Fragments instead of just PreferenceInjector.inject(this);

@robisaks
Copy link
Author

@denley thanks! Looks like I was not initializing it correctly.

robisaks added a commit to robisaks/PreferenceInjector that referenced this issue Feb 24, 2015
More explicitly state how to use with Fragments. I missed the "too" in the docs :)
@denley
Copy link
Owner

denley commented Feb 24, 2015

@robisaks Thanks for the report.

There's actually no reason it has to be this way. The constructor is overloaded for Activity, View and Dialog. There's no reason the same can't be done for Fragment as getActivity is public. It would certainly make the API simpler. I will take that on board as an issue.

@denley denley reopened this Feb 24, 2015
@denley denley changed the title Does not appear to work in Fragments Overload inject to accept just a Fragment Feb 24, 2015
@denley denley closed this as completed Feb 24, 2015
@denley
Copy link
Owner

denley commented Feb 24, 2015

Version 2.1.1 has been released with this change. You can now call PreferenceInjector.inject(this) from a Fragment

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

2 participants