Last active
July 20, 2016 09:26
-
-
Save daolq/eec7b0b5bd337152c166f9e2cad4b548 to your computer and use it in GitHub Desktop.
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
package vn.fstyle.realmandroiddemo.realm; | |
import io.realm.RealmObject; | |
/** | |
* RealmString. | |
* | |
* @author DaoLQ | |
*/ | |
public class RealmString extends RealmObject { | |
String stringValue; | |
/** | |
* constructor | |
*/ | |
public RealmString() { | |
} | |
/** | |
* @param stringValue value | |
*/ | |
public RealmString(String stringValue) { | |
this.stringValue = stringValue; | |
} | |
/** | |
* @return value | |
*/ | |
public String getStringValue() { | |
return stringValue; | |
} | |
/** | |
* @param stringValue input | |
*/ | |
public void setStringValue(String stringValue) { | |
this.stringValue = stringValue; | |
} | |
} |
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
package vn.fstyle.realmandroiddemo.realm; | |
import com.google.gson.JsonArray; | |
import com.google.gson.JsonDeserializationContext; | |
import com.google.gson.JsonDeserializer; | |
import com.google.gson.JsonElement; | |
import com.google.gson.JsonParseException; | |
import java.lang.reflect.Type; | |
import io.realm.RealmList; | |
/** | |
* RealmStringDeserializer. | |
* | |
* @author DaoLQ | |
*/ | |
public class RealmStringDeserializer implements | |
JsonDeserializer<RealmList<RealmString>> { | |
@Override | |
public RealmList<RealmString> deserialize(JsonElement json, Type typeOfT, | |
JsonDeserializationContext context) throws JsonParseException { | |
RealmList<RealmString> realmStrings = new RealmList<>(); | |
JsonArray stringList = json.getAsJsonArray(); | |
for (JsonElement stringElement : stringList) { | |
realmStrings.add(new RealmString(stringElement.getAsString())); | |
} | |
return realmStrings; | |
} | |
} |
In Object
private RealmList<RealmString> mStrings;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Config
Gson
when CreateRestAdapter.Builder
of retrofit: