public static final MutableLiveData<Date> lastUpdateDate = new MutableLiveData<>(null);
public static final MutableLiveData<Integer> lastUpdateTransactionCount =
new MutableLiveData<>(0);
- public static final ObservableValue<String> lastUpdateText = new ObservableValue<>();
+ public static final MutableLiveData<Integer> lastUpdateAccountCount = new MutableLiveData<>(0);
+ public static final ObservableValue<String> lastTransactionsUpdateText =
+ new ObservableValue<>();
+ public static final ObservableValue<String> lastAccountsUpdateText = new ObservableValue<>();
private static final MutableLiveData<MobileLedgerProfile> profile =
new InertMutableLiveData<>();
private static final AtomicInteger backgroundTaskCount = new AtomicInteger(0);
Logger.debug("dFilter", String.format(Locale.US,
"entered synchronized block (about to examine %d accounts)", list.size()));
newDisplayed.add(new AccountListItem()); // header
+
+ int count = 0;
for (LedgerAccount a : list) {
if (isInterrupted())
return;
- if (a.isVisible())
+ if (a.isVisible()) {
newDisplayed.add(new AccountListItem(a));
+ count++;
+ }
}
if (!isInterrupted()) {
model.displayedAccounts.postValue(newDisplayed);
+ Data.lastUpdateAccountCount.postValue(count);
}
Logger.debug("dFilter", "left synchronized block");
}
break;
case HEADER:
- setLastUpdateText(Data.lastUpdateText.get());
+ setLastUpdateText(Data.lastAccountsUpdateText.get());
break;
default:
throw new IllegalStateException("Unexpected value: " + newType);
if (lastUpdateObserver != null)
return;
- lastUpdateObserver = (o, arg) -> setLastUpdateText(Data.lastUpdateText.get());
+ lastUpdateObserver = (o, arg) -> setLastUpdateText(Data.lastAccountsUpdateText.get());
- Data.lastUpdateText.addObserver(lastUpdateObserver);
+ Data.lastAccountsUpdateText.addObserver(lastUpdateObserver);
}
private void dropLastUpdateObserver() {
if (lastUpdateObserver == null)
return;
- Data.lastUpdateText.deleteObserver(lastUpdateObserver);
+ Data.lastAccountsUpdateText.deleteObserver(lastUpdateObserver);
lastUpdateObserver = null;
}
private void setType(AccountListItem.Type newType) {
Data.locale.observe(this, l -> refreshLastUpdateInfo());
Data.lastUpdateDate.observe(this, date -> refreshLastUpdateInfo());
Data.lastUpdateTransactionCount.observe(this, date -> refreshLastUpdateInfo());
+ Data.lastUpdateAccountCount.observe(this, date -> refreshLastUpdateInfo());
}
private void scheduleDataRetrievalIfStale(long lastUpdate) {
long now = new Date().getTime();
Data.removeProfileObservers(this);
Data.profiles.removeObservers(this);
Data.lastUpdateTransactionCount.removeObservers(this);
+ Data.lastUpdateAccountCount.removeObservers(this);
Data.lastUpdateDate.removeObservers(this);
recreate();
private void refreshLastUpdateInfo() {
final int formatFlags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR |
DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_NUMERIC_DATE;
- String template = getResources().getString(R.string.transaction_count_summary);
+ String templateForTransactions =
+ getResources().getString(R.string.transaction_count_summary);
+ String templateForAccounts = getResources().getString(R.string.account_count_summary);
+ Integer accountCount = Data.lastUpdateAccountCount.getValue();
Integer transactionCount = Data.lastUpdateTransactionCount.getValue();
Date lastUpdate = Data.lastUpdateDate.getValue();
- Data.lastUpdateText.set((lastUpdate == null) ? "----" : String.format(
- Objects.requireNonNull(Data.locale.getValue()), template,
- (transactionCount == null) ? 0 : transactionCount,
- DateUtils.formatDateTime(this, lastUpdate.getTime(), formatFlags)));
+ if (lastUpdate == null) {
+ Data.lastTransactionsUpdateText.set("----");
+ Data.lastAccountsUpdateText.set("----");
+ }
+ else {
+ Data.lastTransactionsUpdateText.set(
+ String.format(Objects.requireNonNull(Data.locale.getValue()),
+ templateForTransactions,
+ transactionCount == null ? 0 : transactionCount,
+ DateUtils.formatDateTime(this, lastUpdate.getTime(), formatFlags)));
+ Data.lastAccountsUpdateText.set(
+ String.format(Objects.requireNonNull(Data.locale.getValue()),
+ templateForAccounts, accountCount == null ? 0 : accountCount,
+ DateUtils.formatDateTime(this, lastUpdate.getTime(), formatFlags)));
+ }
}
public void onStopTransactionRefreshClick(View view) {
Logger.debug("interactive", "Cancelling transactions refresh");
}
break;
case HEADER:
- holder.setLastUpdateText(Data.lastUpdateText.get());
+ holder.setLastUpdateText(Data.lastTransactionsUpdateText.get());
break;
default:
if (lastUpdateObserver != null)
return;
- lastUpdateObserver = (o, arg) -> setLastUpdateText(Data.lastUpdateText.get());
+ lastUpdateObserver = (o, arg) -> setLastUpdateText(Data.lastTransactionsUpdateText.get());
- Data.lastUpdateText.addObserver(lastUpdateObserver);
+ Data.lastTransactionsUpdateText.addObserver(lastUpdateObserver);
}
void setLastUpdateText(String text) {
tvLastUpdate.setText(text);
if (lastUpdateObserver == null)
return;
- Data.lastUpdateText.deleteObserver(lastUpdateObserver);
+ Data.lastTransactionsUpdateText.deleteObserver(lastUpdateObserver);
lastUpdateObserver = null;
}
void setType(TransactionListItem.Type newType) {
<string name="navigation_drawer_close">Затваряне на страничния панел</string>
<string name="nav_header_desc">Заглавна част на страничния панел</string>
<string name="transaction_count_summary">%,d движения към %s</string>
+ <string name="account_count_summary">%,d сметки към %s</string>
</resources>
<string name="splash_icon_description">Main app icon</string>
<string name="sub_accounts_expand_collapse_trigger_description">Sub-accounts expand/collapse trigger</string>
<string name="transaction_count_summary">%,d transactions as of %s</string>
+ <string name="account_count_summary">%,d accounts as of %s</string>
</resources>