private void saveOrder(Order orderToSave) { valueList.put("_id", currentOrder.getOrderId()); for (EditText fieldToSave : editFields) { if (fieldToSave.getText() != null) { valueList.put(fieldToSave.getTag().toString(), fieldToSave.getText().toString()); } } orderToSave.setOrderValues(valueList); if (orderToSave.save()) { Toast toast = Toast.makeText( MainActivity.appContext, "Order " + orderToSave.getOrderId() + " saved", Toast.LENGTH_LONG); toast.show(); } }
public void onFocusChange(View view, boolean hasFocus) { EditText currentEditField = (EditText) view; if (!hasFocus) { if (currentEditField.getText() != null) { valueList.put( currentEditField.getTag().toString(), currentEditField.getText().toString()); } } }
@Override public boolean onKey(View view, int keyCode, KeyEvent keyEvent) { EditText currentField = (EditText) view; View nextField = mainLayout.findViewById(view.getNextFocusDownId()); String currentFieldTag = (String) currentField.getTag(); if (keyEvent.getAction() == KeyEvent.ACTION_DOWN && (keyCode == KeyEvent.KEYCODE_ENTER)) { if (currentField.getText() != null) { valueList.put(currentFieldTag, currentField.getText().toString()); } if (nextField != null) { nextField.requestFocus(); } return true; } return false; }