From db35dd62138b367c23527a58ff0570142f607198 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 30 Nov 2019 16:10:35 +0200 Subject: [PATCH] fix NPE in ParsedLedgerTransaction.setTindex --- .../mobileledger/json/ParsedLedgerTransaction.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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); -- 2.39.5