We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
It might be useful to support saving complex/structured objects that are composed of multiple preference keys.
@PrefType public class User { String username; String email; String phone; int age; @PrefKey("is_verified") boolean verified; }
or
@PrefType public interface User { String getUsername(); void setUsername(String username); String getEmail(); void setEmail(String email); String getPhone(); void setPhone(String phone); int getAge(); void setAge(int age); @PrefKey("is_verified") boolean getVerified(); void setVerified(boolean verified); }
Usage:
@BindPrefType(listen = false) User user; @BindPrefType(init = false) void bindToUser(User user) { ... } @BindPrefType({User.class, Settings.class}) void onUserOrSettingsChanged() { ... }
PreferenceBinder.save(context, user); PreferenceBinder.save(context, "prefs_file", user);
The text was updated successfully, but these errors were encountered:
public class User$$PreferenceStructureBinder<T extends User> [extends xxx$$PreferenceStructureBinder<T extends User] { public void load(T target, SharedPreferences prefs) { [super.load(target, prefs)] target.username = prefs.getString("User_username", null); target.email= prefs.getString("User_email", null); target.phone = prefs.getString("User_phone", null); target.age = prefs.getInt("User_age", 0); target.verified = prefs.getBoolean("is_verified", false); } public void save(T target, SharedPreferences.Editor editor) { [super.save(target, editor)] editor .putString("User_username", target.username) .putString("User_email", target.email) .putString("User_phone", target.phone) .putInt("User_age", target.age) .putBoolean("is_verified", target.verified); } }
Sorry, something went wrong.
Allow construction of structured SharedPreferences types.
b3ec374
These class types have each of their fields saved/loaded individually. Fixes #25
denley
No branches or pull requests
It might be useful to support saving complex/structured objects that are composed of multiple preference keys.
or
Usage:
The text was updated successfully, but these errors were encountered: