Disconnect

This commit is contained in:
Dan Ballard 2017-09-23 09:04:47 -07:00
parent 14fc595760
commit 9b1e768226
1 changed files with 22 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package im.ricochet.androidod; package im.ricochet.androidod;
import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
@ -66,6 +67,13 @@ public class RemoteActivity extends AppCompatActivity {
} }
}); });
disconnectButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
DisconnectTask disconnectTask = new DisconnectTask();
disconnectTask.execute();
}
});
if (savedInstanceState != null) { if (savedInstanceState != null) {
deviceText.setText(savedInstanceState.getString(DEVICE_NAME_KEY)); deviceText.setText(savedInstanceState.getString(DEVICE_NAME_KEY));
@ -159,4 +167,18 @@ public class RemoteActivity extends AppCompatActivity {
setVibeLevel(newVibeLevel); setVibeLevel(newVibeLevel);
} }
} }
private class DisconnectTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void ...params) {
GoRicochetMobile.odClientDisconnect();
return null;
}
@Override
protected void onPostExecute(Void nothing) {
Intent i = new Intent(getApplicationContext(), ConnectActivity.class);
startActivity(i);
}
}
} }