import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.model.LedgerTransactionAccount;
import net.ktnx.mobileledger.model.MobileLedgerProfile;
+import net.ktnx.mobileledger.ui.AutoCompleteTextViewWithClear;
import net.ktnx.mobileledger.ui.DatePickerFragment;
import net.ktnx.mobileledger.utils.Logger;
import net.ktnx.mobileledger.utils.MLDB;
boolean wasSyncing = syncingData;
syncingData = true;
try {
- adapter.updateFocusedItem(getAdapterPosition());
+ final int pos = getAdapterPosition();
+ adapter.updateFocusedItem(pos);
+ if (v instanceof AutoCompleteTextViewWithClear) {
+ adapter.noteFocusIsOnAccount(pos);
+ }
+ else {
+ adapter.noteFocusIsOnAmount(pos);
+ }
}
finally {
syncingData = wasSyncing;
case transactionRow:
// do nothing if a row element already has the focus
if (!itemView.hasFocus()) {
- focused = tvAccount.requestFocus();
- tvAccount.dismissDropDown();
- if (focused)
- Misc.showSoftKeyboard((NewTransactionActivity) tvAccount.getContext());
+ if (item.focusIsOnAmount()) {
+ tvAmount.requestFocus();
+ }
+ else {
+ focused = tvAccount.requestFocus();
+ tvAccount.dismissDropDown();
+ if (focused)
+ Misc.showSoftKeyboard((NewTransactionActivity) tvAccount.getContext());
+ }
}
break;
public void updateFocusedItem(int position) {
model.updateFocusedItem(position);
}
+ public void noteFocusIsOnAccount(int position) {
+ model.noteFocusIsOnAccount(position);
+ }
+ public void noteFocusIsOnAmount(int position) {
+ model.noteFocusIsOnAmount(position);
+ }
}
public void updateFocusedItem(int position) {
focusedItem.setValue(position);
}
+ public void noteFocusIsOnAccount(int position) {
+ getItem(position).setFocusIsOnAmount(false);
+ }
+ public void noteFocusIsOnAmount(int position) {
+ getItem(position).setFocusIsOnAmount(true);
+ }
enum ItemType {generalData, transactionRow, bottomFiller}
//==========================================================================================
private MutableLiveData<String> amountHint = new MutableLiveData<>(null);
private NewTransactionModel model;
private MutableLiveData<Boolean> editable = new MutableLiveData<>(true);
+ public boolean focusIsOnAmount() {
+ return focusIsOnAmount;
+ }
+ private boolean focusIsOnAmount = false;
public Item(NewTransactionModel model) {
this.model = model;
type = ItemType.bottomFiller;
public void stopObservingEditableFlag(Observer<Boolean> observer) {
editable.removeObserver(observer);
}
+ public void setFocusIsOnAmount(boolean flag) {
+ focusIsOnAmount = flag;
+ }
}
}