while parsing JSON accounts, skip the "root" account
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 7 Mar 2019 04:14:51 +0000 (06:14 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 7 Mar 2019 04:14:51 +0000 (06:14 +0200)
app/src/main/java/net/ktnx/mobileledger/json/AccountListParser.java

index 4dd2e37..2551c28 100644 (file)
@@ -17,6 +17,8 @@
 
 package net.ktnx.mobileledger.json;
 
+import android.util.Log;
+
 import com.fasterxml.jackson.databind.MappingIterator;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.ObjectReader;
@@ -35,6 +37,13 @@ public class AccountListParser {
         iter = reader.readValues(input);
     }
     public ParsedLedgerAccount nextAccount() throws IOException {
-        return iter.hasNext() ? iter.next() : null;
+        if (!iter.hasNext()) return null;
+
+        ParsedLedgerAccount next = iter.next();
+
+        if (next.getAname().equalsIgnoreCase("root")) return nextAccount();
+
+        Log.d("accounts", String.format("Got account '%s'", next.getAname()));
+        return next;
     }
 }