]> git.ktnx.net Git - mobile-ledger.git/commitdiff
new transaction: hook the currency selection to the item so that it still works after...
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 20 Apr 2020 18:45:16 +0000 (21:45 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 20 Apr 2020 18:45:16 +0000 (21:45 +0300)
app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java

index 3b6f2ecbc2861e90c54f5767604576613c37b696..77ce69a000dd96aaecc2e3ba95b1b27e4e692b78 100644 (file)
@@ -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);