X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;ds=sidebyside;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fasync%2FUpdateTransactionsTask.java;fp=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fasync%2FUpdateTransactionsTask.java;h=0000000000000000000000000000000000000000;hb=68cd8ad9a58628674aec13a0d43fd89683728669;hp=785ec1447eac017e3303a192f2e9eafe7269504a;hpb=96c0c980b90119e043ee1d754cfcaa6115912321;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/async/UpdateTransactionsTask.java b/app/src/main/java/net/ktnx/mobileledger/async/UpdateTransactionsTask.java deleted file mode 100644 index 785ec144..00000000 --- a/app/src/main/java/net/ktnx/mobileledger/async/UpdateTransactionsTask.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your opinion), any later version. - * - * MoLe is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License terms for details. - * - * You should have received a copy of the GNU General Public License - * along with MoLe. If not, see . - */ - -package net.ktnx.mobileledger.async; - -import android.os.AsyncTask; - -import net.ktnx.mobileledger.db.DB; -import net.ktnx.mobileledger.db.Profile; -import net.ktnx.mobileledger.db.TransactionWithAccounts; -import net.ktnx.mobileledger.model.Data; -import net.ktnx.mobileledger.model.LedgerTransaction; -import net.ktnx.mobileledger.ui.MainModel; -import net.ktnx.mobileledger.utils.Logger; - -import java.util.ArrayList; -import java.util.List; - -import static net.ktnx.mobileledger.db.Profile.NO_PROFILE_ID; -import static net.ktnx.mobileledger.utils.Logger.debug; - -public class UpdateTransactionsTask extends AsyncTask { - protected String doInBackground(MainModel[] parentModel) { - final Profile profile = Data.getProfile(); - - long profileId = (profile == null) ? NO_PROFILE_ID : profile.getId(); - Data.backgroundTaskStarted(); - try { - Logger.debug("UTT", "Starting DB transaction list retrieval"); - - final MainModel model = parentModel[0]; - final String accFilter = model.getAccountFilter() - .getValue(); - final List transactions; - - if (profileId == NO_PROFILE_ID) - transactions = new ArrayList<>(); - else if (accFilter == null) { - transactions = DB.get() - .getTransactionDAO() - .getAllWithAccountsSync(profileId); - } - else { - transactions = DB.get() - .getTransactionDAO() - .getAllWithAccountsFilteredSync(profileId, accFilter); - } - - TransactionAccumulator accumulator = new TransactionAccumulator(accFilter); - - for (TransactionWithAccounts tr : transactions) { - if (isCancelled()) - return null; - - accumulator.put(new LedgerTransaction(tr)); - } - - accumulator.publishResults(model); - - debug("UTT", "transaction list value updated"); - - return null; - } - finally { - Data.backgroundTaskFinished(); - } - } -}