/*
- * 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
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;
return null;
}
}
- public MobileLedgerProfile getProfile() {
- return profile;
- }
@Override
protected void onProgressUpdate(Progress... values) {
super.onProgressUpdate(values);
else {
parentAccount = null;
}
- lastAccount = new LedgerAccount(profile, accName, parentAccount);
+ lastAccount = new LedgerAccount(accName, parentAccount);
accounts.add(lastAccount);
map.put(accName, lastAccount);
parentAccount = null;
}
- acc = new LedgerAccount(profile, accountName, parentAccount);
+ acc = new LedgerAccount(accountName, parentAccount);
createdAccounts.add(acc);
return acc;
}
}
private List<LedgerAccount> 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;
}
private List<LedgerAccount> retrieveAccountListAnyVersion()
throws HTTPException, ApiNotSupportedException {
- for (SendTransactionTask.API ver : SendTransactionTask.API.allVersions) {
+ for (API ver : API.allVersions) {
try {
return retrieveAccountListForVersion(ver);
}
throw new RuntimeException("This should never be reached");
}
- private List<LedgerAccount> retrieveAccountListForVersion(SendTransactionTask.API version)
+ private List<LedgerAccount> retrieveAccountListForVersion(API version)
throws IOException, HTTPException {
HttpURLConnection http = NetworkUtil.prepareConnection(profile, "accounts");
http.setAllowUserInteraction(false);
}
private List<LedgerTransaction> 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;
}
private List<LedgerTransaction> retrieveTransactionListAnyVersion()
throws ApiNotSupportedException {
- for (SendTransactionTask.API ver : SendTransactionTask.API.allVersions) {
+ for (API ver : API.allVersions) {
try {
return retrieveTransactionListForVersion(ver);
}
throw new RuntimeException("This should never be reached");
}
- private List<LedgerTransaction> retrieveTransactionListForVersion(
- SendTransactionTask.API apiVersion) throws IOException, ParseException, HTTPException {
+ private List<LedgerTransaction> retrieveTransactionListForVersion(API apiVersion)
+ throws IOException, ParseException, HTTPException {
Progress progress = new Progress();
progress.setTotal(expectedPostingsCount);
.compareTo(o1.getDate());
if (res != 0)
return res;
- return Integer.compare(o2.getId(), o1.getId());
+ return Long.compare(o2.getId(), o1.getId());
});
return trList;
}