bod / android-prefs Goto Github PK
View Code? Open in Web Editor NEWAndroid preferences for WINNERS!
License: Apache License 2.0
Android preferences for WINNERS!
License: Apache License 2.0
It will be great to have easy way to put and get custom POJO objects to shared prefs. One of the simplest solution would be use gson or jackson to parse it.
It'll be nice to support field annotations like IntDef
annotations.
Eg. I want that this field
@Navigation.NavSection
@DefaultInt(Navigatory.DEFAULT_NAV_SECTION) //DEFAULT_NAV_SECTION == 666
Integer currentNavItem;
will generate
@Navigation.NavSection
public Integer getCurrentNavItem() {
if (!contains("currentNavItem")) return 666; //btw - is this line necessary?
return getInt("currentNavItem", 666);
}
public boolean containsCurrentNavItem() {
return contains("currentNavItem");
}
public SharedPrefs putCurrentNavItem(@Navigation.NavSection Integer currentNavItem) {
edit().putCurrentNavItem(currentNavItem).apply();
return this;
}
public SharedPrefs removeCurrentNavItem() {
edit().remove("currentNavItem").apply();
return this;
}
clear() -> edit().clear().apply()
If there is no default value.
Hi @BoD . You can update function replace Prefs in <YourClassName>Prefs
with a different characters
Ex: <YourClassName>Prefs ---> <YourClassName>Helper.
Hi @BoD by default , I have class Worker and Manager, and skip add preference key, using default preference key:
@"Prefs"
class Worker {
String user;
String password;
}
@"Prefs"
class Manager{
String user;
String password;
}
If i save user Worker, then i save user Manager ---> value user, password manager will replace user, password worker. Although i can use @name("........") resolve it . But i don't want.
To reproduce:
@DefaultString("line1\nline2")
Workaround:
Escape the backslash, e.g.:
@DefaultString("line1\\nline2")
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.