Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/src/main/java/com/greenaddress/abcore/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ else if (mDaemonStatus == DaemonStatus.STARTING || mDaemonStatus == DaemonStatus
}
//for mDaemonStatus = STOPPED we don't have to do anything
break;
case "stopped":
mDaemonStatus = DaemonStatus.STOPPED;
mTvStatus.setText(getString(R.string.status_header, mDaemonStatus.toString()));
break;
case "localonion":
if (mDaemonStatus == DaemonStatus.STARTING || mDaemonStatus == DaemonStatus.UNKNOWN){
mDaemonStatus = DaemonStatus.RUNNING;
Expand Down Expand Up @@ -318,6 +322,9 @@ else if (mDaemonStatus == DaemonStatus.STOPPED ){
pb.setMax(max);
pb.setProgress(percent);
textStatus.setText(getString(R.string.progress_bar_message, percent, blocks));
break;
default:
Log.e(TAG, "Unexpected broadcast result - " + text);
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/greenaddress/abcore/RPCIntentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ private void broadcastError(final Exception e) {
sendBroadcast(broadcastIntent);
}

private void broadcastStop() {
Log.e(TAG, "broadcastStop");
final Intent broadcastIntent = new Intent();
broadcastIntent.setAction(MainActivity.RPCResponseReceiver.ACTION_RESP);
broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
broadcastIntent.putExtra(PARAM_OUT_MSG, "stopped");
sendBroadcast(broadcastIntent);
}

@Override
protected void onHandleIntent(final Intent intent) {
Expand All @@ -175,8 +183,15 @@ protected void onHandleIntent(final Intent intent) {
while (true) {
try {
getRpc().stop();
broadcastStop();
break;
} catch (final BitcoinRPCException | IOException e) {
if (e instanceof BitcoinRPCException && ((BitcoinRPCException) e).getResponse() == null) {
Log.e(TAG, "daemon not responding, already stopped");
broadcastError(e);
break;
}
Log.v(TAG, "stop failed, looping back");
try {
Thread.sleep(200);
} catch (final InterruptedException e1) {
Expand Down