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;
import net.ktnx.mobileledger.utils.MLDB;
import net.ktnx.mobileledger.utils.Misc;
+import org.jetbrains.annotations.NotNull;
+
import java.text.DecimalFormatSymbols;
import java.util.Calendar;
import java.util.Date;
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;
private boolean inUpdate = false;
private boolean syncingData = false;
private View commentButton;
- private NewTransactionItemsAdapter adapter;
//TODO multiple amounts with different currencies per posting
NewTransactionItemHolder(@NonNull View itemView, NewTransactionItemsAdapter adapter) {
super(itemView);
- this.adapter = adapter;
tvAccount = itemView.findViewById(R.id.account_row_acc_name);
tvComment = itemView.findViewById(R.id.comment);
new TextViewClearHelper().attachToTextView((EditText) tvComment);
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");
});
tvAccount.setEnabled(editable);
tvAmount.setEnabled(editable);
}
- private void setCommentVisible(Boolean visible) {
+ private void setCommentVisible(@NotNull Boolean visible) {
if (visible) {
// showing; show the comment view and align the comment button to it
tvComment.setVisibility(View.VISIBLE);
commentButton.setLayoutParams(lp);
}
else {
- // hiding; hide the comment comment view and align amounts layout under it
+ // hiding; hide the comment view and align the comment bottom to the amount
tvComment.setVisibility(View.GONE);
ConstraintLayout.LayoutParams lp =
(ConstraintLayout.LayoutParams) commentButton.getLayoutParams();
- lp.bottomToBottom = R.id.ntr_account; // R.id.parent doesn't work here
+ lp.bottomToBottom = R.id.amount_layout; // R.id.parent doesn't work here
commentButton.setLayoutParams(lp);
}
}
@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);