This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Preference_UserProfile.getInstance(this).putNickname("my nickname"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@KeyName(name = "userPet") | |
@TypeConverter(converter = PetConverter.class) | |
protected Pet userPetInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PetConverter extends PreferenceTypeConverter<Pet> { | |
private final Gson gson; | |
/** | |
* default constructor will be called by PreferenceRoom | |
*/ | |
public PetConverter() { | |
this.gson = new Gson(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@PreferenceFunction(keyname = "nickname") | |
public String putUserNickFunction(String nickname) { | |
return "Hello, " + nickname; | |
} | |
@PreferenceFunction(keyname = "nickname") | |
public String getUserNickFunction(String nickname) { | |
return nickname + "!!!"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@PreferenceFunction(keyname = "visits") | |
public int putVisitCountFunction(int count) { | |
return ++count; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component.UserProfile().putVisits(component.UserProfile().getVisits()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@PreferenceFunction(keyname = "uuid") | |
public String putUuidFunction(String uuid) { | |
return SecurityUtils.encrypt(uuid); | |
} | |
@PreferenceFunction(keyname = "uuid") | |
public String getUuidFunction(String uuid) { | |
return SecurityUtils.decrypt(uuid); | |
} |
OlderNewer