mirror of
https://codeberg.org/anoncontributorxmr/mysu.git
synced 2024-11-25 17:02:28 +00:00
Add retry system if connection fails.
This commit is contained in:
parent
a2b7e27e8b
commit
7109442ad0
3 changed files with 25 additions and 4 deletions
|
@ -87,6 +87,11 @@ public class MainActivity extends AppCompatActivity implements MoneroHandlerThre
|
||||||
this.blockchainService.refreshBlockchain();
|
this.blockchainService.refreshBlockchain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnectionFail() {
|
||||||
|
System.out.println("CONNECT FAILED");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPasswordSuccess(String password) {
|
public void onPasswordSuccess(String password) {
|
||||||
File walletFile = new File(getApplicationInfo().dataDir, Constants.WALLET_NAME);
|
File walletFile = new File(getApplicationInfo().dataDir, Constants.WALLET_NAME);
|
||||||
|
|
|
@ -55,9 +55,10 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
WalletManager.getInstance().setDaemon(Node.fromString(DefaultNodes.XMRTW.getUri()));
|
WalletManager.getInstance().setProxy("127.0.0.1:9050");
|
||||||
wallet.init(0);
|
WalletManager.getInstance().setDaemon(Node.fromString(DefaultNodes.MONERUJO_ONION.getUri()));
|
||||||
wallet.setProxy("127.0.0.1:9050");
|
wallet.setProxy("127.0.0.1:9050");
|
||||||
|
wallet.init(0);
|
||||||
wallet.setListener(this);
|
wallet.setListener(this);
|
||||||
wallet.startRefresh();
|
wallet.startRefresh();
|
||||||
}
|
}
|
||||||
|
@ -85,11 +86,24 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int triesLeft = 5;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshed() {
|
public void refreshed() {
|
||||||
|
Wallet.ConnectionStatus status = wallet.getFullStatus().getConnectionStatus();
|
||||||
|
if(status == Wallet.ConnectionStatus.ConnectionStatus_Disconnected || status == null) {
|
||||||
|
if(triesLeft > 0) {
|
||||||
|
wallet.startRefresh();
|
||||||
|
triesLeft--;
|
||||||
|
} else {
|
||||||
|
listener.onConnectionFail();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
BlockchainService.getInstance().setDaemonHeight(wallet.getDaemonBlockChainHeight());
|
||||||
wallet.setSynchronized();
|
wallet.setSynchronized();
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void refresh() {
|
private void refresh() {
|
||||||
wallet.refreshHistory();
|
wallet.refreshHistory();
|
||||||
|
@ -105,5 +119,6 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
|
||||||
|
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
void onRefresh();
|
void onRefresh();
|
||||||
|
void onConnectionFail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
android:layout_marginEnd="24dp"
|
android:layout_marginEnd="24dp"
|
||||||
android:layout_marginBottom="32dp"
|
android:layout_marginBottom="32dp"
|
||||||
android:hint="Password"
|
android:hint="Password"
|
||||||
|
android:inputType="textPassword"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toTopOf="@id/unlock_wallet_button"/>
|
app:layout_constraintBottom_toTopOf="@id/unlock_wallet_button"/>
|
||||||
<ImageButton
|
<ImageButton
|
||||||
|
|
Loading…
Reference in a new issue