From: Damyan Ivanov Date: Sat, 30 Nov 2019 14:10:35 +0000 (+0200) Subject: fix NPE in ParsedLedgerTransaction.setTindex X-Git-Tag: v0.11.0~5 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=db35dd62138b367c23527a58ff0570142f607198;p=mobile-ledger.git fix NPE in ParsedLedgerTransaction.setTindex --- diff --git a/app/src/main/java/net/ktnx/mobileledger/json/ParsedLedgerTransaction.java b/app/src/main/java/net/ktnx/mobileledger/json/ParsedLedgerTransaction.java index 81d76475..7ba1421c 100644 --- a/app/src/main/java/net/ktnx/mobileledger/json/ParsedLedgerTransaction.java +++ b/app/src/main/java/net/ktnx/mobileledger/json/ParsedLedgerTransaction.java @@ -101,20 +101,21 @@ public class ParsedLedgerTransaction { } public void setTindex(int tindex) { this.tindex = tindex; - for(ParsedPosting p : tpostings) { - p.setPtransaction_(tindex); - } + if (tpostings != null) + for (ParsedPosting p : tpostings) { + p.setPtransaction_(tindex); + } } public List getTpostings() { return tpostings; } + public void setTpostings(List tpostings) { + this.tpostings = tpostings; + } public void addPosting(ParsedPosting posting) { posting.setPtransaction_(tindex); tpostings.add(posting); } - public void setTpostings(List tpostings) { - this.tpostings = tpostings; - } public LedgerTransaction asLedgerTransaction() throws ParseException { Date date = Globals.parseIsoDate(tdate); LedgerTransaction tr = new LedgerTransaction(tindex, date, tdescription);