]> git.ktnx.net Git - mobile-ledger.git/commitdiff
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 4dd2e375ae7ac79e9c66c31feb7afc6b6e978e07..2551c28d9024365ebfb5ee0f30613bcac74327a5 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;
     }
 }