From: Damyan Ivanov Date: Thu, 7 Mar 2019 04:14:51 +0000 (+0200) Subject: while parsing JSON accounts, skip the "root" account X-Git-Tag: v0.8~32 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=8440406eafce2900954cfc280343aa1a5daa7d29;p=mobile-ledger.git while parsing JSON accounts, skip the "root" account --- diff --git a/app/src/main/java/net/ktnx/mobileledger/json/AccountListParser.java b/app/src/main/java/net/ktnx/mobileledger/json/AccountListParser.java index 4dd2e375..2551c28d 100644 --- a/app/src/main/java/net/ktnx/mobileledger/json/AccountListParser.java +++ b/app/src/main/java/net/ktnx/mobileledger/json/AccountListParser.java @@ -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; } }