X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FNewTransactionItemsAdapter.java;h=0da28e8e07bd69823dae2824a9de298d51ee4885;hb=a24375557ffc7362886df61606252dbd9c382468;hp=741af1b048252dc4ae84ee195f3e114ee8c71957;hpb=887a3e831a8d40c534d1f67b057c514ed985c4af;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java index 741af1b0..0da28e8e 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright © 2019 Damyan Ivanov. + * Copyright © 2020 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 @@ -20,6 +20,7 @@ package net.ktnx.mobileledger.ui.activity; import android.annotation.SuppressLint; import android.app.Activity; import android.database.Cursor; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.LinearLayout; @@ -29,7 +30,8 @@ import androidx.annotation.Nullable; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; -import net.ktnx.mobileledger.App; +import com.google.android.material.snackbar.Snackbar; + import net.ktnx.mobileledger.BuildConfig; import net.ktnx.mobileledger.R; import net.ktnx.mobileledger.async.DescriptionSelectedCallback; @@ -52,9 +54,9 @@ import static net.ktnx.mobileledger.utils.Logger.debug; class NewTransactionItemsAdapter extends RecyclerView.Adapter implements DescriptionSelectedCallback { - NewTransactionModel model; + private final NewTransactionModel model; private MobileLedgerProfile mProfile; - private ItemTouchHelper touchHelper; + private final ItemTouchHelper touchHelper; private RecyclerView recyclerView; private int checkHoldCounter = 0; NewTransactionItemsAdapter(NewTransactionModel viewModel, MobileLedgerProfile profile) { @@ -126,10 +128,10 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter params = new ArrayList<>(); StringBuilder sb = new StringBuilder("select t.profile, t.id from transactions t"); - if (!Misc.isEmptyOrNull(accFilter)) { + if (!TextUtils.isEmpty(accFilter)) { sb.append(" JOIN transaction_accounts ta") .append(" ON ta.profile = t.profile") .append(" AND ta.transaction_id = t.id"); @@ -203,16 +205,16 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter Snackbar.make(recyclerView, R.string.ignoring_preferred_account, + Snackbar.LENGTH_LONG) + .show()); MLDB.queryInBackground(broaderSql, new String[]{description}, new MLDB.CallbackHelper() { @@ -277,7 +284,7 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter accounts = tr.getAccounts(); + List accounts = tr.getAccounts(); NewTransactionModel.Item firstNegative = null; NewTransactionModel.Item firstPositive = null; int singleNegativeIndex = -1; @@ -344,7 +351,7 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter 2) notifyItemRangeRemoved(3, presentItemCount - 2); // all the rest are gone } - public void updateFocusedItem(int position) { + void updateFocusedItem(int position) { model.updateFocusedItem(position); } - public void noteFocusIsOnAccount(int position) { + void noteFocusIsOnAccount(int position) { model.noteFocusChanged(position, NewTransactionModel.FocusedElement.Account); } - public void noteFocusIsOnAmount(int position) { + void noteFocusIsOnAmount(int position) { model.noteFocusChanged(position, NewTransactionModel.FocusedElement.Amount); } - public void noteFocusIsOnComment(int position) { + void noteFocusIsOnComment(int position) { model.noteFocusChanged(position, NewTransactionModel.FocusedElement.Comment); } + void noteFocusIsOnTransactionComment(int position) { + model.noteFocusChanged(position, NewTransactionModel.FocusedElement.TransactionComment); + } + public void noteFocusIsOnDescription(int pos) { + model.noteFocusChanged(pos, NewTransactionModel.FocusedElement.Description); + } private void holdSubmittableChecks() { checkHoldCounter++; } @@ -460,7 +473,12 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter hashMap = new HashMap<>(); + + private static class BalanceForCurrency { + private final HashMap hashMap = new HashMap<>(); float get(String currencyName) { Float f = hashMap.get(currencyName); if (f == null) { @@ -653,8 +672,8 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter> hashMap = new HashMap<>(); + private static class ItemsForCurrency { + private final HashMap> hashMap = new HashMap<>(); @NonNull List getList(@Nullable String currencyName) { List list = hashMap.get(currencyName);