/** * Saves a new receipt account based on the fields in the TabHost values. It does a validation of * the data and then saves it to the database if valid. * * @param receiptAccount the receipt account to save * @return true if successful */ private boolean saveReceiptAccount(ReceiptAccount receiptAccount) { boolean result; String name = tabHost.getCurrentName(); String category = tabHost.getCurrentCategory(); long code = tabHost.getCurrentCode(); receiptAccount.setName(name); receiptAccount.setCategory(category); receiptAccount.setCode(code); if (ReceiptAccount.isValid(receiptAccount, receiptAccounts)) { communicator.saveReceiptAccount(receiptAccount); result = true; } else { communicator.showToast(ReceiptAccount.INVALID_ACCOUNT_MESSAGE); result = false; } return result; }
/** * Removes the selected receipt account from the list and deletes it from the database. * * @param receiptAccount the account to delete */ private void deleteReceiptAccount(ReceiptAccount receiptAccount) { receiptAccounts.remove(receiptAccount); communicator.deleteReceiptAccount(receiptAccount); }