X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fasync%2FRetrieveTransactionsTask.java;h=aa47d73d403cc456bf6fca05a7046e8dbd421241;hb=8098a8b37a4331b9faf6cf50a51a0d7aa9677421;hp=d092a1cbfc55f1f0294cef1f6fc583248e14efa6;hpb=a87079ed41bdc3ad89fe8bd15dfba10e37b29b76;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java index d092a1cb..aa47d73d 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java @@ -1,5 +1,5 @@ /* - * Copyright © 2020 Damyan Ivanov. + * Copyright © 2021 Damyan Ivanov. * This file is part of MoLe. * MoLe is free software: you can distribute it and/or modify it * under the term of the GNU General Public License as published by @@ -28,6 +28,7 @@ import com.fasterxml.jackson.databind.RuntimeJsonMappingException; import net.ktnx.mobileledger.App; import net.ktnx.mobileledger.err.HTTPException; +import net.ktnx.mobileledger.json.API; import net.ktnx.mobileledger.json.AccountListParser; import net.ktnx.mobileledger.json.ApiNotSupportedException; import net.ktnx.mobileledger.json.TransactionListParser; @@ -120,9 +121,6 @@ public class RetrieveTransactionsTask extends return null; } } - public MobileLedgerProfile getProfile() { - return profile; - } @Override protected void onProgressUpdate(Progress... values) { super.onProgressUpdate(values); @@ -213,7 +211,7 @@ public class RetrieveTransactionsTask extends else { parentAccount = null; } - lastAccount = new LedgerAccount(profile, accName, parentAccount); + lastAccount = new LedgerAccount(accName, parentAccount); accounts.add(lastAccount); map.put(accName, lastAccount); @@ -377,7 +375,7 @@ public class RetrieveTransactionsTask extends parentAccount = null; } - acc = new LedgerAccount(profile, accountName, parentAccount); + acc = new LedgerAccount(accountName, parentAccount); createdAccounts.add(acc); return acc; } @@ -386,11 +384,11 @@ public class RetrieveTransactionsTask extends } private List retrieveAccountList() throws IOException, HTTPException, ApiNotSupportedException { - final SendTransactionTask.API apiVersion = profile.getApiVersion(); - if (apiVersion.equals(SendTransactionTask.API.auto)) { + final API apiVersion = profile.getApiVersion(); + if (apiVersion.equals(API.auto)) { return retrieveAccountListAnyVersion(); } - else if (apiVersion.equals(SendTransactionTask.API.html)) { + else if (apiVersion.equals(API.html)) { Logger.debug("json", "Declining using JSON API for /accounts with configured legacy API version"); return null; @@ -401,7 +399,7 @@ public class RetrieveTransactionsTask extends } private List retrieveAccountListAnyVersion() throws HTTPException, ApiNotSupportedException { - for (SendTransactionTask.API ver : SendTransactionTask.API.allVersions) { + for (API ver : API.allVersions) { try { return retrieveAccountListForVersion(ver); } @@ -416,7 +414,7 @@ public class RetrieveTransactionsTask extends throw new RuntimeException("This should never be reached"); } - private List retrieveAccountListForVersion(SendTransactionTask.API version) + private List retrieveAccountListForVersion(API version) throws IOException, HTTPException { HttpURLConnection http = NetworkUtil.prepareConnection(profile, "accounts"); http.setAllowUserInteraction(false); @@ -467,11 +465,11 @@ public class RetrieveTransactionsTask extends } private List retrieveTransactionList() throws ParseException, HTTPException, IOException, ApiNotSupportedException { - final SendTransactionTask.API apiVersion = profile.getApiVersion(); - if (apiVersion.equals(SendTransactionTask.API.auto)) { + final API apiVersion = profile.getApiVersion(); + if (apiVersion.equals(API.auto)) { return retrieveTransactionListAnyVersion(); } - else if (apiVersion.equals(SendTransactionTask.API.html)) { + else if (apiVersion.equals(API.html)) { Logger.debug("json", "Declining using JSON API for /accounts with configured legacy API version"); return null; @@ -483,7 +481,7 @@ public class RetrieveTransactionsTask extends } private List retrieveTransactionListAnyVersion() throws ApiNotSupportedException { - for (SendTransactionTask.API ver : SendTransactionTask.API.allVersions) { + for (API ver : API.allVersions) { try { return retrieveTransactionListForVersion(ver); } @@ -498,8 +496,8 @@ public class RetrieveTransactionsTask extends throw new RuntimeException("This should never be reached"); } - private List retrieveTransactionListForVersion( - SendTransactionTask.API apiVersion) throws IOException, ParseException, HTTPException { + private List retrieveTransactionListForVersion(API apiVersion) + throws IOException, ParseException, HTTPException { Progress progress = new Progress(); progress.setTotal(expectedPostingsCount); @@ -554,7 +552,7 @@ public class RetrieveTransactionsTask extends .compareTo(o1.getDate()); if (res != 0) return res; - return Integer.compare(o2.getId(), o1.getId()); + return Long.compare(o2.getId(), o1.getId()); }); return trList; }