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

Auto implementing of sharedpref client-defined interface #32

Open
semanticer opened this issue May 27, 2015 · 2 comments
Open

Auto implementing of sharedpref client-defined interface #32

semanticer opened this issue May 27, 2015 · 2 comments

Comments

@semanticer
Copy link
Contributor

It would be great to have a functionality to let client define interface with all his preferences (getters&setter) and then generate implementation for him. I like this idea in https://github.com/martino2k6/StoreBox.

@pwittchen
Copy link
Owner

Thanks for reporting that issue. Actually, I wanted to add such feature. It requires to create additional project (annotation processor) for code generation and it needs to be added as a second library.
I think, I'll add such feature in one of the next versions of the library or as a separate project, but I cannot promise, when it'll be available.

@ypresto
Copy link
Contributor

ypresto commented Aug 5, 2015

StoreBox implements it with Proxy+InvocationHandler, which is simpler than annotation processor.
But I think using interface is overkill to implement the only 1-2 lines of code:

public void put(String key, String value) {
    prefs.edit().setString(key, value).apply();
}

The other hand, retrofit is suitable case of interface because it uses Proxy to wrap complicated I/O logic in it, and to handle various request parameters (@Query, @POST, ...).

Just I like simplicity of this library. :)

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