|
9 | 9 |
|
10 | 10 | import android.annotation.SuppressLint;
|
11 | 11 | import android.annotation.TargetApi;
|
| 12 | +import android.app.Activity; |
12 | 13 | import android.app.AlertDialog;
|
| 14 | +import android.app.ProgressDialog; |
13 | 15 | import android.app.SearchManager;
|
14 | 16 | import android.content.BroadcastReceiver;
|
15 | 17 | import android.content.Context;
|
@@ -1095,4 +1097,44 @@ void switchRealm(final ProgressDialog progressDialog, final int position) {
|
1095 | 1097 | progressDialog.dismiss();
|
1096 | 1098 | }
|
1097 | 1099 |
|
| 1100 | + |
| 1101 | + @Override |
| 1102 | + protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 1103 | + if (requestCode == ADDREALM_REQUEST_CODE && resultCode == Activity.RESULT_OK) { |
| 1104 | + this.currentList.adapter.clear(); |
| 1105 | + this.currentList.showLoadIndicatorTop(true); |
| 1106 | + final String realmName = data.getStringExtra("realmName"); |
| 1107 | + final String apiKey = data.getStringExtra("api_key"); |
| 1108 | + final String email = data.getStringExtra("email"); |
| 1109 | + final String serverURL = data.getStringExtra("serverURL"); |
| 1110 | + notifications.logOut(new Runnable() { |
| 1111 | + @Override |
| 1112 | + public void run() { |
| 1113 | + if (event_poll != null) { |
| 1114 | + event_poll.abort(); |
| 1115 | + event_poll = null; |
| 1116 | + } |
| 1117 | + statusUpdateHandler.removeMessages(0); |
| 1118 | + try { |
| 1119 | + unregisterReceiver(onGcmMessage); |
| 1120 | + } catch (IllegalArgumentException e) { |
| 1121 | + ZLog.logException(e); |
| 1122 | + } |
| 1123 | + |
| 1124 | + app.clearConnectionState(); |
| 1125 | + app.createNewRealm(); |
| 1126 | + app.setEmail(email); |
| 1127 | + app.setServerURL(serverURL); |
| 1128 | + app.saveServerName(realmName); |
| 1129 | + app.setLoggedInApiKey(apiKey); |
| 1130 | + IntentFilter filter = new IntentFilter(GcmBroadcastReceiver.BROADCAST); |
| 1131 | + filter.setPriority(2); |
| 1132 | + registerReceiver(onGcmMessage, filter); |
| 1133 | + onRefresh(); |
| 1134 | + } |
| 1135 | + }); |
| 1136 | + |
| 1137 | + } |
| 1138 | + this.currentList.showLoadIndicatorTop(false); |
| 1139 | + } |
1098 | 1140 | }
|
0 commit comments