lastDateString = dateString;
odd = !odd;
}
- Data.transactions.set(newList);
+ Data.transactions.setList(newList);
Log.d("UTT", "transaction list value updated");
}
import java.util.List;
public final class Data {
- public static TransactionList transactions = new TransactionList();
+ public static ObservableList<TransactionListItem> transactions = new ObservableList<>(new ArrayList<>());
public static ObservableList<LedgerAccount> accounts =
new ObservableList<>(new ArrayList<>());
public static ObservableAtomicInteger backgroundTaskCount = new ObservableAtomicInteger(0);
import android.widget.TextView;
import net.ktnx.mobileledger.R;
+import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.model.LedgerTransaction;
import net.ktnx.mobileledger.model.LedgerTransactionAccount;
import net.ktnx.mobileledger.model.TransactionListItem;
@Override
public int getItemCount() {
- return TransactionListViewModel.getTransactionCount() + 1;
+ return Data.transactions.size() + 1;
}
public void setBoldAccountName(String boldAccountName) {
this.boldAccountName = boldAccountName;
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, filter);
}
public static TransactionListItem getTransactionListItem(int position) {
- List<TransactionListItem> transactions = Data.transactions.get();
- if (transactions == null) return null;
- if (position >= transactions.size() + 1) return null;
- if (position == transactions.size()) return new TransactionListItem();
- return transactions.get(position);
+ try(LockHolder lh = Data.transactions.lockForReading()) {
+ if (Data.transactions == null) return null;
+ if (position >= Data.transactions.size() + 1) return null;
+ if (position == Data.transactions.size()) return new TransactionListItem();
+ return Data.transactions.get(position);
+ }
}
public static int getTransactionCount() {
List<TransactionListItem> transactions = Data.transactions.get();