|
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;
|
@@ -1441,4 +1442,44 @@ void switchRealm(final ProgressDialog progressDialog, final int position) {
|
1441 | 1442 | progressDialog.dismiss();
|
1442 | 1443 | }
|
1443 | 1444 |
|
| 1445 | + |
| 1446 | + @Override |
| 1447 | + protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 1448 | + if (requestCode == ADDREALM_REQUEST_CODE && resultCode == Activity.RESULT_OK) { |
| 1449 | + this.currentList.adapter.clear(); |
| 1450 | + this.currentList.adapter.setHeaderShowing(true); |
| 1451 | + final String realmName = data.getStringExtra("realmName"); |
| 1452 | + final String apiKey = data.getStringExtra("api_key"); |
| 1453 | + final String email = data.getStringExtra("email"); |
| 1454 | + final String serverURL = data.getStringExtra("serverURL"); |
| 1455 | + notifications.logOut(new Runnable() { |
| 1456 | + @Override |
| 1457 | + public void run() { |
| 1458 | + if (event_poll != null) { |
| 1459 | + event_poll.abort(); |
| 1460 | + event_poll = null; |
| 1461 | + } |
| 1462 | + statusUpdateHandler.removeMessages(0); |
| 1463 | + try { |
| 1464 | + unregisterReceiver(onGcmMessage); |
| 1465 | + } catch (IllegalArgumentException e) { |
| 1466 | + ZLog.logException(e); |
| 1467 | + } |
| 1468 | + |
| 1469 | + app.clearConnectionState(); |
| 1470 | + app.createNewRealm(); |
| 1471 | + app.setEmail(email); |
| 1472 | + app.setServerURL(serverURL); |
| 1473 | + app.saveServerName(realmName); |
| 1474 | + app.setLoggedInApiKey(apiKey); |
| 1475 | + IntentFilter filter = new IntentFilter(GcmBroadcastReceiver.BROADCAST); |
| 1476 | + filter.setPriority(2); |
| 1477 | + registerReceiver(onGcmMessage, filter); |
| 1478 | + onRefresh(); |
| 1479 | + } |
| 1480 | + }); |
| 1481 | + |
| 1482 | + } |
| 1483 | + this.currentList.adapter.setHeaderShowing(false); |
| 1484 | + } |
1444 | 1485 | }
|
0 commit comments