}
enum ItemType {generalData, transactionRow, bottomFiller}
+ //==========================================================================================
+
class Item extends Object {
private ItemType type;
private MutableLiveData<Date> date = new MutableLiveData<>();
private MutableLiveData<String> description = new MutableLiveData<>();
private LedgerTransactionAccount account;
- private MutableLiveData<String> amountHint = new MutableLiveData<>();
+ private MutableLiveData<String> amountHint = new MutableLiveData<>(null);
private NewTransactionModel model;
private MutableLiveData<Boolean> editable = new MutableLiveData<>(true);
public Item(NewTransactionModel model) {
public NewTransactionModel getModel() {
return model;
}
- public boolean isEditable() {
- ensureType(ItemType.transactionRow);
- return this.editable.getValue();
- }
public void setEditable(boolean editable) {
- ensureType(ItemType.transactionRow);
+ ensureType(ItemType.generalData, ItemType.transactionRow);
this.editable.setValue(editable);
}
+ private void ensureType(ItemType type1, ItemType type2) {
+ if ((type != type1) && (type != type2)) {
+ throw new RuntimeException(
+ String.format("Actual type (%s) differs from wanted (%s or %s)", type,
+ type1, type2));
+ }
+ }
public String getAmountHint() {
ensureType(ItemType.transactionRow);
return amountHint.getValue();