try {
String input = String.valueOf(b.accountRowAccAmounts.getText());
input = input.replace(decimalSeparator, decimalDot);
- b.accountRowAccAmounts.setText(
- String.format("%4.2f", Float.parseFloat(input)));
+ final String newText = String.format("%4.2f", Float.parseFloat(input));
+ if (!newText.equals(input)) {
+ boolean wasSyncingData = syncingData;
+ syncingData = true;
+ try {
+ b.accountRowAccAmounts.setText(newText);
+ }
+ finally {
+ syncingData = wasSyncingData;
+ }
+ }
}
catch (NumberFormatException ex) {
// ignored
b.currencyButton.setOnClickListener(v -> {
CurrencySelectorFragment cpf = new CurrencySelectorFragment();
cpf.showPositionAndPadding();
- cpf.setOnCurrencySelectedListener(
- c -> adapter.setItemCurrency(getAdapterPosition(), c.getName()));
+ cpf.setOnCurrencySelectedListener(c -> adapter.setItemCurrency(getAdapterPosition(),
+ (c == null) ? null : c.getName()));
cpf.show(activity.getSupportFragmentManager(), "currency-selector");
});
if (showCurrency) {
b.currency.setVisibility(View.VISIBLE);
b.currencyButton.setVisibility(View.VISIBLE);
- b.currency.setText(mProfile.getDefaultCommodity());
+ setCurrencyString(mProfile.getDefaultCommodity());
}
else {
b.currency.setVisibility(View.GONE);
b.currencyButton.setVisibility(View.GONE);
- b.currency.setText(null);
+ setCurrencyString(null);
}
});
private void setCurrencyString(String currency) {
@ColorInt int textColor = b.dummyText.getTextColors()
.getDefaultColor();
- if ((currency == null) || currency.isEmpty()) {
+ if (TextUtils.isEmpty(currency)) {
b.currency.setText(R.string.currency_symbol);
int alpha = (textColor >> 24) & 0xff;
alpha = alpha * 3 / 4;
return false;
}
+ if (getAdapterPosition() < 0) {
+ // probably the row was swiped out
+ Logger.debug("new-trans", "Ignoring request to suncData(): adapter position negative");
+ return false;
+ }
+
NewTransactionModel.Item item = getItem();
syncingData = true;