package net.ktnx.mobileledger.ui.activity;
+import android.annotation.SuppressLint;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
tvAmount.setNextFocusForwardId(View.NO_ID); // magic!
tvDate.setOnFocusChangeListener((v, hasFocus) -> {
- if (hasFocus) pickTransactionDate();
+ if (hasFocus)
+ pickTransactionDate();
});
tvDate.setOnClickListener(v -> pickTransactionDate());
mProfile = Data.profile.getValue();
- if (mProfile == null) throw new AssertionError();
+ if (mProfile == null)
+ throw new AssertionError();
MLDB.hookAutocompletionAdapter(tvDescription.getContext(), tvDescription,
MLDB.DESCRIPTION_HISTORY_TABLE, "description", false, adapter, mProfile);
@Override
public void afterTextChanged(Editable s) {
// debug("input", "text changed");
- if (inUpdate) return;
+ if (inUpdate)
+ return;
Logger.debug("textWatcher", "calling syncData()");
syncData();
tvAmount.addTextChangedListener(tw);
dateObserver = date -> {
- if (syncingData) return;
+ if (syncingData)
+ return;
syncingData = true;
try {
tvDate.setText(item.getFormattedDate());
}
};
descriptionObserver = description -> {
- if (syncingData) return;
+ if (syncingData)
+ return;
syncingData = true;
try {
tvDescription.setText(description);
}
};
hintObserver = hint -> {
- if (syncingData) return;
+ if (syncingData)
+ return;
syncingData = true;
try {
+ if (hint == null)
+ hint = tvAmount.getResources()
+ .getString(R.string.zero_amount);
tvAmount.setHint(hint);
}
finally {
//if (!tvDate.hasFocus()) tvDate.requestFocus();
boolean focused = tvDescription.requestFocus();
tvDescription.dismissDropDown();
- if (focused) Misc.showSoftKeyboard(
- (NewTransactionActivity) tvDescription.getContext());
+ if (focused)
+ Misc.showSoftKeyboard(
+ (NewTransactionActivity) tvDescription.getContext());
break;
case transactionRow:
focused = tvAccount.requestFocus();
item.getAccount()
.getAmount())
: "unset") : "")));
- if (adapterPosition == count) tvAmount.setImeOptions(EditorInfo.IME_ACTION_DONE);
- else tvAmount.setImeOptions(EditorInfo.IME_ACTION_NEXT);
+ if (adapterPosition == count)
+ tvAmount.setImeOptions(EditorInfo.IME_ACTION_DONE);
+ else
+ tvAmount.setImeOptions(EditorInfo.IME_ACTION_NEXT);
};
}
private void setEditable(Boolean editable) {
tvAmount.setEnabled(editable);
}
private void beginUpdates() {
- if (inUpdate) throw new RuntimeException("Already in update mode");
+ if (inUpdate)
+ throw new RuntimeException("Already in update mode");
inUpdate = true;
}
private void endUpdates() {
- if (!inUpdate) throw new RuntimeException("Not in update mode");
+ if (!inUpdate)
+ throw new RuntimeException("Not in update mode");
inUpdate = false;
}
/**
* Stores the data from the UI elements into the model item
*/
private void syncData() {
- if (item == null) return;
+ if (item == null)
+ return;
if (syncingData) {
Logger.debug("new-trans", "skipping syncData() loop");
.resetAmount();
}
}
- else item.getAccount()
- .resetAmount();
+ else
+ item.getAccount()
+ .resetAmount();
break;
case bottomFiller:
*
* @param item updates the UI elements with the data from the model item
*/
+ @SuppressLint("DefaultLocale")
public void setData(NewTransactionModel.Item item) {
beginUpdates();
try {
LedgerTransactionAccount acc = item.getAccount();
tvAccount.setText(acc.getAccountName());
tvAmount.setText(
- acc.isAmountSet() ? String.format(Locale.US, "%1.2f", acc.getAmount())
- : "");
+ acc.isAmountSet() ? String.format("%1.2f", acc.getAmount()) : "");
lHead.setVisibility(View.GONE);
lAccount.setVisibility(View.VISIBLE);
lPadding.setVisibility(View.GONE);
c.set(year, month, day);
item.setDate(c.getTime());
boolean focused = tvDescription.requestFocus();
- if (focused) Misc.showSoftKeyboard((NewTransactionActivity) tvAccount.getContext());
+ if (focused)
+ Misc.showSoftKeyboard((NewTransactionActivity) tvAccount.getContext());
}
@Override