|
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;
|
@@ -1513,4 +1514,44 @@ void switchRealm(final ProgressDialog progressDialog, final int position) {
|
1513 | 1514 | progressDialog.dismiss();
|
1514 | 1515 | }
|
1515 | 1516 |
|
| 1517 | + |
| 1518 | + @Override |
| 1519 | + protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 1520 | + if (requestCode == ADDREALM_REQUEST_CODE && resultCode == Activity.RESULT_OK) { |
| 1521 | + this.currentList.adapter.clear(); |
| 1522 | + this.currentList.adapter.setHeaderShowing(true); |
| 1523 | + final String realmName = data.getStringExtra("realmName"); |
| 1524 | + final String apiKey = data.getStringExtra("api_key"); |
| 1525 | + final String email = data.getStringExtra("email"); |
| 1526 | + final String serverURL = data.getStringExtra("serverURL"); |
| 1527 | + notifications.logOut(new Runnable() { |
| 1528 | + @Override |
| 1529 | + public void run() { |
| 1530 | + if (event_poll != null) { |
| 1531 | + event_poll.abort(); |
| 1532 | + event_poll = null; |
| 1533 | + } |
| 1534 | + statusUpdateHandler.removeMessages(0); |
| 1535 | + try { |
| 1536 | + unregisterReceiver(onGcmMessage); |
| 1537 | + } catch (IllegalArgumentException e) { |
| 1538 | + ZLog.logException(e); |
| 1539 | + } |
| 1540 | + |
| 1541 | + app.clearConnectionState(); |
| 1542 | + app.createNewRealm(); |
| 1543 | + app.setEmail(email); |
| 1544 | + app.setServerURL(serverURL); |
| 1545 | + app.saveServerName(realmName); |
| 1546 | + app.setLoggedInApiKey(apiKey); |
| 1547 | + IntentFilter filter = new IntentFilter(GcmBroadcastReceiver.getGCMReceiverAction(getApplicationContext())); |
| 1548 | + filter.setPriority(2); |
| 1549 | + registerReceiver(onGcmMessage, filter); |
| 1550 | + onRefresh(); |
| 1551 | + } |
| 1552 | + }); |
| 1553 | + |
| 1554 | + } |
| 1555 | + this.currentList.adapter.setHeaderShowing(false); |
| 1556 | + } |
1516 | 1557 | }
|
0 commit comments