+ public void sendFocusedNotification() {
+ focusedItem.setValue(focusedItem.getValue());
+ }
+ void updateFocusedItem(int position) {
+ focusedItem.setValue(position);
+ }
+ void noteFocusChanged(int position, FocusedElement element) {
+ getItem(position).setFocusedElement(element);
+ }
+ void swapItems(int one, int two) {
+ Collections.swap(items, one - 1, two - 1);
+ }
+ void toggleComment(int position) {
+ final MutableLiveData<Boolean> commentVisible = getItem(position).commentVisible;
+ commentVisible.postValue(!commentVisible.getValue());
+ }
+ void moveItemLast(int index) {
+ /* 0
+ 1 <-- index
+ 2
+ 3 <-- desired position
+ */
+ int itemCount = items.size();
+
+ if (index < itemCount - 1) {
+ Item acc = items.remove(index);
+ items.add(itemCount - 1, acc);
+ }
+ }
+ void toggleCurrencyVisible() {
+ showCurrency.setValue(!showCurrency.getValue());
+ }
+ public void setItemCurrency(Item item, Currency newCurrency,
+ NewTransactionItemsAdapter adapter) {
+ Currency oldCurrency = item.getCurrency();
+ if (!Currency.equal(newCurrency, oldCurrency)) {
+ holdSubmittableChecks();
+ try {
+ item.setCurrency(newCurrency);
+// for (Item i : items) {
+// if (Currency.equal(i.getCurrency(), oldCurrency))
+// i.setCurrency(newCurrency);
+// }
+ }
+ finally {
+ releaseSubmittableChecks();
+ }
+
+ checkTransactionSubmittable(adapter);
+ }
+ }