Skip to content

Instantly share code, notes, and snippets.

☕️
Coffee coffee

Jaewoong Eum skydoves

☕️
Coffee coffee
Block or report user

Report or block skydoves

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Profile.java
@PreferenceEntity(name = "UserProfile")
public class Profile {
protected final boolean login = false;
@KeyName(name = "nickname") protected final String userNickName = null;
@KeyName(name = "visits") protected final int visitCount = 1;
@KeyName(name = "userPet")
@TypeConverter(converter = PetConverter.class)
protected Pet userPetInfo;
View PreferenceRoomActivity.java
Preference_UserProfile userProfile = Preference_UserProfile.getInstance(this);
userProfile.putNickname("my nickname"); // puts a SharedPreference in NickName key.
userProfile.getNickname(); // gets a SharedPreference value in NickName key.
userProfile.containsNickname(); // checks nickname key value is exist in SharedPreference.
userProfile.removeNickname(); // removes nickname key's value in SharedPreference.
userProfile.nicknameKeyName(); // returns nickname fields's key name.
userProfile.getEntityName(); // returns UserProfile entity's name;
userProfile.getkeyNameList(); // returns UserProfile entity's KeyName list of fields.
View Preference_UserProfile.java
Preference_UserProfile.getInstance(this).putNickname("my nickname");
View PrivateInfoConverter.java
public class PrivateInfoConverter extends PreferenceTypeConverter<PrivateInfo> {
@Override
public String convertObject(PrivateInfo privateInfo) {
return privateInfo.getName() + "," + privateInfo.getAge();
}
@Override
public PrivateInfo convertType(String string) {
if(string == null) return new PrivateInfo("null",0);
View Converter_Example.java
@KeyName(name = "userPet")
@TypeConverter(converter = PetConverter.class)
protected Pet userPetInfo;
View PetConverter.java
public class PetConverter extends PreferenceTypeConverter<Pet> {
private final Gson gson;
/**
* default constructor will be called by PreferenceRoom
*/
public PetConverter() {
this.gson = new Gson();
}
View PreferenceFunction_Example.java
@PreferenceFunction(keyname = "nickname")
public String putUserNickFunction(String nickname) {
return "Hello, " + nickname;
}
@PreferenceFunction(keyname = "nickname")
public String getUserNickFunction(String nickname) {
return nickname + "!!!";
}
View PreferenceFunction_Example2.java
@PreferenceFunction(keyname = "visits")
public int putVisitCountFunction(int count) {
return ++count;
}
View PreferenceFunction_Example3.java
component.UserProfile().putVisits(component.UserProfile().getVisits());
View PreferenceFunction_Example4.java
@PreferenceFunction(keyname = "uuid")
public String putUuidFunction(String uuid) {
return SecurityUtils.encrypt(uuid);
}
@PreferenceFunction(keyname = "uuid")
public String getUuidFunction(String uuid) {
return SecurityUtils.decrypt(uuid);
}
You can’t perform that action at this time.