+
+ swiper = findViewById(R.id.transaction_swipe);
+ if (swiper == null) throw new RuntimeException("Can't get hold on the swipe layout");
+ root = findViewById(R.id.transaction_root);
+ if (root == null) throw new RuntimeException("Can't get hold on the transaction list view");
+ progressBar = findViewById(R.id.transaction_progress_bar);
+ if (progressBar == null)
+ throw new RuntimeException("Can't get hold on the transaction list progress bar");
+ tvLastUpdate = findViewById(R.id.transactions_last_update);
+ {
+ long last_update = (new MobileLedgerDatabase(this))
+ .get_option_value("transaction_list_last_update", 0);
+ if (last_update == 0) tvLastUpdate.setText("never");
+ else {
+ Date date = new Date(last_update);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ tvLastUpdate.setText(date.toInstant().atZone(ZoneId.systemDefault())
+ .format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
+ }
+ else {
+ tvLastUpdate.setText(date.toLocaleString());
+ }
+ }
+ }
+ model = ViewModelProviders.of(this).get(TransactionListViewModel.class);
+ List<LedgerTransaction> transactions =
+ model.getTransactions(new MobileLedgerDatabase(this));
+ modelAdapter = new TransactionListAdapter(transactions);
+
+ RecyclerView root = findViewById(R.id.transaction_root);
+ root.setAdapter(modelAdapter);
+
+ LinearLayoutManager llm = new LinearLayoutManager(this);
+ llm.setOrientation(LinearLayoutManager.VERTICAL);
+ root.setLayoutManager(llm);
+
+ ((SwipeRefreshLayout) findViewById(R.id.transaction_swipe)).setOnRefreshListener(() -> {
+ Log.d("ui", "refreshing transactions via swipe");
+ update_transactions();
+ });
+
+// update_transactions();