From aa68224c994c89ac69c8a944f2f72aa8230fc8db Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Mon, 20 Apr 2020 21:45:16 +0300 Subject: [PATCH] new transaction: hook the currency selection to the item so that it still works after a reconfiguration --- .../ui/activity/NewTransactionItemHolder.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java index 3b6f2ecb..77ce69a0 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java @@ -46,7 +46,6 @@ import net.ktnx.mobileledger.model.LedgerTransactionAccount; import net.ktnx.mobileledger.model.MobileLedgerProfile; import net.ktnx.mobileledger.ui.CurrencySelectorFragment; import net.ktnx.mobileledger.ui.DatePickerFragment; -import net.ktnx.mobileledger.ui.OnCurrencySelectedListener; import net.ktnx.mobileledger.ui.TextViewClearHelper; import net.ktnx.mobileledger.utils.Colors; import net.ktnx.mobileledger.utils.DimensionUtils; @@ -63,8 +62,7 @@ import java.util.Locale; import static net.ktnx.mobileledger.ui.activity.NewTransactionModel.ItemType; class NewTransactionItemHolder extends RecyclerView.ViewHolder - implements DatePickerFragment.DatePickedListener, DescriptionSelectedCallback, - OnCurrencySelectedListener { + implements DatePickerFragment.DatePickedListener, DescriptionSelectedCallback { private final String decimalSeparator; private final String decimalDot; private final TextView tvCurrency; @@ -225,8 +223,8 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder tvCurrency.setOnClickListener(v -> { CurrencySelectorFragment cpf = new CurrencySelectorFragment(); - cpf.setOnCurrencySelectedListener(this); cpf.showPositionAndPadding(); + cpf.setOnCurrencySelectedListener(c -> item.setCurrency(c)); final AppCompatActivity activity = (AppCompatActivity) v.getContext(); cpf.show(activity.getSupportFragmentManager(), "currency-selector"); }); @@ -653,10 +651,6 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder } @Override - public void onCurrencySelected(Currency currency) { - adapter.model.setItemCurrency(this.item, currency, adapter); - } - @Override public void descriptionSelected(String description) { tvAccount.setText(description); tvAmount.requestFocus(View.FOCUS_FORWARD); -- 2.39.5