diff --git a/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java b/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java index c1e53cd522..35a93981f1 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java +++ b/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java @@ -349,14 +349,14 @@ public void onRefreshed(final Wallet wallet, boolean full) { Timber.d("onRefreshed(%b)", full); if (adapter.needsTransactionUpdateOnNewBlock()) { - wallet.getHistory().refresh(); + wallet.refreshHistory(); full = true; } if (full) { List list = new ArrayList<>(); final long streetHeight = activityCallback.getStreetModeHeight(); Timber.d("StreetHeight=%d", streetHeight); - wallet.getHistory().refresh(); + wallet.refreshHistory(); for (TransactionInfo info : wallet.getHistory().getAll()) { Timber.d("TxHeight=%d, Label=%s", info.blockheight, info.subaddressLabel); if ((info.isPending || (info.blockheight >= streetHeight)) diff --git a/app/src/main/java/com/m2049r/xmrwallet/layout/TransactionInfoAdapter.java b/app/src/main/java/com/m2049r/xmrwallet/layout/TransactionInfoAdapter.java index da218804a4..f7c4f9361f 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/layout/TransactionInfoAdapter.java +++ b/app/src/main/java/com/m2049r/xmrwallet/layout/TransactionInfoAdapter.java @@ -100,7 +100,7 @@ public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) { return (oldItem.direction == newItem.direction) && (oldItem.isPending == newItem.isPending) && (oldItem.isFailed == newItem.isFailed) - && (oldItem.confirmations == newItem.confirmations) + && ((oldItem.confirmations == newItem.confirmations) || (oldItem.isConfirmed())) && (oldItem.subaddressLabel.equals(newItem.subaddressLabel)) && (Objects.equals(oldItem.notes, newItem.notes)); } diff --git a/app/src/main/java/com/m2049r/xmrwallet/model/TransactionHistory.java b/app/src/main/java/com/m2049r/xmrwallet/model/TransactionHistory.java index c54851d82b..08245f65cc 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/model/TransactionHistory.java +++ b/app/src/main/java/com/m2049r/xmrwallet/model/TransactionHistory.java @@ -43,7 +43,7 @@ public TransactionHistory(long handle, int accountIndex) { this.accountIndex = accountIndex; } - public void loadNotes(Wallet wallet) { + private void loadNotes(Wallet wallet) { for (TransactionInfo info : transactions) { info.notes = wallet.getUserNote(info.hash); } @@ -61,30 +61,22 @@ public List getAll() { private List transactions = new ArrayList<>(); - public void refreshWithNotes(Wallet wallet) { + void refreshWithNotes(Wallet wallet) { refresh(); loadNotes(wallet); } -// public void refresh() { -// transactions = refreshJ(); -// } - - public void refresh() { + private void refresh() { List transactionInfos = refreshJ(); - Timber.d("refreshed %d", transactionInfos.size()); + Timber.d("refresh size=%d", transactionInfos.size()); for (Iterator iterator = transactionInfos.iterator(); iterator.hasNext(); ) { TransactionInfo info = iterator.next(); if (info.accountIndex != accountIndex) { iterator.remove(); - Timber.d("removed %s", info.hash); - } else { - Timber.d("kept %s", info.hash); } } transactions = transactionInfos; } private native List refreshJ(); - } diff --git a/app/src/main/java/com/m2049r/xmrwallet/model/Wallet.java b/app/src/main/java/com/m2049r/xmrwallet/model/Wallet.java index 6653418f51..47df8e08b4 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/model/Wallet.java +++ b/app/src/main/java/com/m2049r/xmrwallet/model/Wallet.java @@ -398,6 +398,10 @@ public TransactionHistory getHistory() { private native long getHistoryJ(); + public void refreshHistory() { + getHistory().refreshWithNotes(this); + } + //virtual AddressBook * addressBook() const = 0; //virtual void setListener(WalletListener *) = 0; @@ -462,7 +466,7 @@ public void setAccountLabel(int accountIndex, String label) { public void setSubaddressLabel(int addressIndex, String label) { setSubaddressLabel(accountIndex, addressIndex, label); - getHistory().refreshWithNotes(this); + refreshHistory(); } public native void setSubaddressLabel(int accountIndex, int addressIndex, String label); diff --git a/app/src/main/java/com/m2049r/xmrwallet/service/WalletService.java b/app/src/main/java/com/m2049r/xmrwallet/service/WalletService.java index 876c944cfc..65bf9ef4b8 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/service/WalletService.java +++ b/app/src/main/java/com/m2049r/xmrwallet/service/WalletService.java @@ -124,7 +124,7 @@ public void newBlock(long height) { if (!wallet.isSynchronized()) { updated = true; // we want to see our transactions as they come in - wallet.getHistory().refresh(); + wallet.refreshHistory(); int txCount = wallet.getHistory().getCount(); if (txCount > lastTxCount) { // update the transaction list only if we have more than before @@ -152,7 +152,7 @@ public void refreshed() { // this means it's synced wallet.setSynchronized(); if (updated) { updateDaemonState(wallet, wallet.getBlockChainHeight()); - wallet.getHistory().refreshWithNotes(wallet); + wallet.refreshHistory(); if (observer != null) { updated = !observer.onRefreshed(wallet, true); }