diff --git a/app/src/main/cpp/monerujo.cpp b/app/src/main/cpp/monerujo.cpp index 77231f2e..1c460992 100644 --- a/app/src/main/cpp/monerujo.cpp +++ b/app/src/main/cpp/monerujo.cpp @@ -914,7 +914,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_refreshAsync(JNIEnv *env, jobject instanc //virtual void rescanBlockchainAsync() = 0; JNIEXPORT void JNICALL -Java_com_m2049r_xmrwallet_model_Wallet_rescanBlockchainAsync(JNIEnv *env, jobject instance) { +Java_com_m2049r_xmrwallet_model_Wallet_rescanBlockchainAsyncJ(JNIEnv *env, jobject instance) { Bitmonero::Wallet *wallet = getHandle(env, instance); wallet->rescanBlockchainAsync(); } diff --git a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java index a35ced44..caff0f05 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java +++ b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java @@ -578,7 +578,6 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste try { final WalletFragment walletFragment = getWalletFragment(); if (wallet.isSynchronized()) { - Timber.d("onRefreshed() synced"); releaseWakeLock(RELEASE_WAKE_LOCK_DELAY); // the idea is to stay awake until synced if (!synced) { // first sync onProgress(-1); 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 103a50a3..6653418f 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/model/Wallet.java +++ b/app/src/main/java/com/m2049r/xmrwallet/model/Wallet.java @@ -273,12 +273,14 @@ public class Wallet { public native long getDaemonBlockChainTargetHeight(); - public native boolean isSynchronizedJ(); + boolean synced = false; public boolean isSynchronized() { - final long daemonHeight = getDaemonBlockChainHeight(); - if (daemonHeight == 0) return false; - return isSynchronizedJ() && (getBlockChainHeight() == daemonHeight); + return synced; + } + + public void setSynchronized() { + this.synced = true; } public static native String getDisplayAmount(long amount); @@ -309,7 +311,12 @@ public class Wallet { public native void refreshAsync(); - public native void rescanBlockchainAsync(); + public native void rescanBlockchainAsyncJ(); + + public void rescanBlockchainAsync() { + synced = false; + rescanBlockchainAsyncJ(); + } //TODO virtual void setAutoRefreshInterval(int millis) = 0; //TODO virtual int autoRefreshInterval() const = 0; 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 9598a4b2..4d1a3d30 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/service/WalletService.java +++ b/app/src/main/java/com/m2049r/xmrwallet/service/WalletService.java @@ -112,7 +112,7 @@ public class WalletService extends Service { int lastTxCount = 0; public void newBlock(long height) { - Wallet wallet = getWallet(); + final Wallet wallet = getWallet(); if (wallet == null) throw new IllegalStateException("No wallet!"); // don't flood with an update for every block ... if (lastBlockTime < System.currentTimeMillis() - 2000) { @@ -145,17 +145,16 @@ public class WalletService extends Service { updated = true; } - public void refreshed() { + public void refreshed() { // this means it's synced Timber.d("refreshed()"); - Wallet wallet = getWallet(); + final Wallet wallet = getWallet(); if (wallet == null) throw new IllegalStateException("No wallet!"); + wallet.setSynchronized(); if (updated) { + updateDaemonState(wallet, wallet.getBlockChainHeight()); + wallet.getHistory().refreshWithNotes(wallet); if (observer != null) { - updateDaemonState(wallet, 0); - wallet.getHistory().refreshWithNotes(wallet); - if (observer != null) { - updated = !observer.onRefreshed(wallet, true); - } + updated = !observer.onRefreshed(wallet, true); } } }