|
10 | 10 | import android.animation.Animator;
|
11 | 11 | import android.annotation.SuppressLint;
|
12 | 12 | import android.annotation.TargetApi;
|
| 13 | +import android.app.Activity; |
13 | 14 | import android.app.AlertDialog;
|
14 | 15 | import android.app.ProgressDialog;
|
15 | 16 | import android.app.SearchManager;
|
@@ -1398,4 +1399,44 @@ void switchRealm(final ProgressDialog progressDialog, final int position) {
|
1398 | 1399 | progressDialog.dismiss();
|
1399 | 1400 | }
|
1400 | 1401 |
|
| 1402 | + |
| 1403 | + @Override |
| 1404 | + protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 1405 | + if (requestCode == ADDREALM_REQUEST_CODE && resultCode == Activity.RESULT_OK) { |
| 1406 | + this.currentList.adapter.clear(); |
| 1407 | + this.currentList.adapter.setHeaderShowing(true); |
| 1408 | + final String realmName = data.getStringExtra("realmName"); |
| 1409 | + final String apiKey = data.getStringExtra("api_key"); |
| 1410 | + final String email = data.getStringExtra("email"); |
| 1411 | + final String serverURL = data.getStringExtra("serverURL"); |
| 1412 | + notifications.logOut(new Runnable() { |
| 1413 | + @Override |
| 1414 | + public void run() { |
| 1415 | + if (event_poll != null) { |
| 1416 | + event_poll.abort(); |
| 1417 | + event_poll = null; |
| 1418 | + } |
| 1419 | + statusUpdateHandler.removeMessages(0); |
| 1420 | + try { |
| 1421 | + unregisterReceiver(onGcmMessage); |
| 1422 | + } catch (IllegalArgumentException e) { |
| 1423 | + ZLog.logException(e); |
| 1424 | + } |
| 1425 | + |
| 1426 | + app.clearConnectionState(); |
| 1427 | + app.createNewRealm(); |
| 1428 | + app.setEmail(email); |
| 1429 | + app.setServerURL(serverURL); |
| 1430 | + app.saveServerName(realmName); |
| 1431 | + app.setLoggedInApiKey(apiKey); |
| 1432 | + IntentFilter filter = new IntentFilter(GcmBroadcastReceiver.BROADCAST); |
| 1433 | + filter.setPriority(2); |
| 1434 | + registerReceiver(onGcmMessage, filter); |
| 1435 | + onRefresh(); |
| 1436 | + } |
| 1437 | + }); |
| 1438 | + |
| 1439 | + } |
| 1440 | + this.currentList.adapter.setHeaderShowing(false); |
| 1441 | + } |
1401 | 1442 | }
|
0 commit comments