diff --git a/graphenej/src/main/java/cy/agorise/graphenej/api/android/DeserializationMap.java b/graphenej/src/main/java/cy/agorise/graphenej/api/android/DeserializationMap.java
index 690bbde..049926f 100644
--- a/graphenej/src/main/java/cy/agorise/graphenej/api/android/DeserializationMap.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/api/android/DeserializationMap.java
@@ -10,6 +10,7 @@ import java.util.List;
import cy.agorise.graphenej.AccountOptions;
import cy.agorise.graphenej.AssetAmount;
+import cy.agorise.graphenej.AssetOptions;
import cy.agorise.graphenej.Authority;
import cy.agorise.graphenej.Transaction;
import cy.agorise.graphenej.api.calls.GetAccounts;
@@ -51,7 +52,7 @@ public class DeserializationMap {
// GetAccounts
mClassMap.put(GetAccounts.class, List.class);
Gson getAccountsGson = new GsonBuilder()
- .setExclusionStrategies(new GetAccountsExclusionStrategy())
+ .setExclusionStrategies(new SkipAccountOptionsStrategy())
.registerTypeAdapter(Authority.class, new Authority.AuthorityDeserializer())
.registerTypeAdapter(AccountOptions.class, new AccountOptions.AccountOptionsDeserializer())
.create();
@@ -64,9 +65,10 @@ public class DeserializationMap {
.create();
mGsonMap.put(GetRequiredFees.class, getRequiredFeesGson);
- // GetRelativeAccounthistory
+ // GetRelativeAccountHistory
mClassMap.put(GetRelativeAccountHistory.class, List.class);
Gson getRelativeAcountHistoryGson = new GsonBuilder()
+ .setExclusionStrategies(new SkipAccountOptionsStrategy(), new SkipAssetOptionsStrategy())
.registerTypeAdapter(OperationHistory.class, new OperationHistory.OperationHistoryDeserializer())
.registerTypeAdapter(TransferOperation.class, new TransferOperation.TransferDeserializer())
.registerTypeAdapter(AssetAmount.class, new AssetAmount.AssetAmountDeserializer())
@@ -88,7 +90,7 @@ public class DeserializationMap {
* This class is required in order to break a recursion loop when de-serializing the
* AccountProperties class instance.
*/
- private class GetAccountsExclusionStrategy implements ExclusionStrategy {
+ public static class SkipAccountOptionsStrategy implements ExclusionStrategy {
@Override
public boolean shouldSkipField(FieldAttributes f) {
@@ -100,4 +102,21 @@ public class DeserializationMap {
return clazz == AccountOptions.class;
}
}
+
+ /**
+ * This class is required in order to break a recursion loop when de-serializing the
+ * AssetAmount instance.
+ */
+ public static class SkipAssetOptionsStrategy implements ExclusionStrategy {
+
+ @Override
+ public boolean shouldSkipField(FieldAttributes f) {
+ return false;
+ }
+
+ @Override
+ public boolean shouldSkipClass(Class> clazz) {
+ return clazz == AssetOptions.class;
+ }
+ }
}
diff --git a/graphenej/src/main/java/cy/agorise/graphenej/objects/Memo.java b/graphenej/src/main/java/cy/agorise/graphenej/objects/Memo.java
index 2f77218..8bd3324 100644
--- a/graphenej/src/main/java/cy/agorise/graphenej/objects/Memo.java
+++ b/graphenej/src/main/java/cy/agorise/graphenej/objects/Memo.java
@@ -32,7 +32,6 @@ import cy.agorise.graphenej.interfaces.JsonSerializable;
* {@url https://bitshares.org/doxygen/structgraphene_1_1chain_1_1memo__data.html}
*/
public class Memo implements ByteSerializable, JsonSerializable {
- public final static String TAG = "Memo";
public static final String KEY_FROM = "from";
public static final String KEY_TO = "to";
public static final String KEY_NONCE = "nonce";
@@ -291,13 +290,15 @@ public class Memo implements ByteSerializable, JsonSerializable {
memoObject.addProperty(KEY_FROM, "");
memoObject.addProperty(KEY_TO, "");
memoObject.addProperty(KEY_NONCE, "");
- memoObject.addProperty(KEY_MESSAGE, Util.bytesToHex(this.message));
+ if(this.message != null)
+ memoObject.addProperty(KEY_MESSAGE, Util.bytesToHex(this.message));
return null;
}else{
memoObject.addProperty(KEY_FROM, this.from.toString());
memoObject.addProperty(KEY_TO, this.to.toString());
memoObject.addProperty(KEY_NONCE, String.format("%x", this.nonce));
- memoObject.addProperty(KEY_MESSAGE, Util.bytesToHex(this.message));
+ if(this.message != null)
+ memoObject.addProperty(KEY_MESSAGE, Util.bytesToHex(this.message));
}
return memoObject;
}
@@ -310,8 +311,9 @@ public class Memo implements ByteSerializable, JsonSerializable {
*/
public JsonElement toJson(boolean decimal){
JsonElement jsonElement = toJsonObject();
- if(decimal){
+ if(decimal && jsonElement != null){
JsonObject jsonObject = (JsonObject) jsonElement;
+ // The nonce is interpreted in base 16, but it is going to be written in base 10
BigInteger nonce = new BigInteger(jsonObject.get(KEY_NONCE).getAsString(), 16);
jsonObject.addProperty(KEY_NONCE, nonce.toString());
}
diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml
index 68920e8..52b1955 100644
--- a/sample/src/main/res/layout/activity_main.xml
+++ b/sample/src/main/res/layout/activity_main.xml
@@ -9,7 +9,7 @@
android:id="@+id/output_text_container"
android:layout_width="0dp"
android:layout_height="0dp"
- app:layout_constraintBottom_toTopOf="@+id/container_get_accounts_call"
+ app:layout_constraintBottom_toTopOf="@+id/container_controls"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
@@ -18,52 +18,68 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
-
-
-
-
-
-
+ android:orientation="vertical">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ app:layout_constraintTop_toBottomOf="@id/container_controls" />