|
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;
|
13 | 14 | import android.app.ProgressDialog;
|
14 | 15 | import android.app.SearchManager;
|
@@ -1248,4 +1249,44 @@ void switchRealm(final ProgressDialog progressDialog, final int position) {
|
1248 | 1249 | progressDialog.dismiss();
|
1249 | 1250 | }
|
1250 | 1251 |
|
| 1252 | + |
| 1253 | + @Override |
| 1254 | + protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 1255 | + if (requestCode == ADDREALM_REQUEST_CODE && resultCode == Activity.RESULT_OK) { |
| 1256 | + this.currentList.adapter.clear(); |
| 1257 | + this.currentList.showLoadIndicatorTop(true); |
| 1258 | + final String realmName = data.getStringExtra("realmName"); |
| 1259 | + final String apiKey = data.getStringExtra("api_key"); |
| 1260 | + final String email = data.getStringExtra("email"); |
| 1261 | + final String serverURL = data.getStringExtra("serverURL"); |
| 1262 | + notifications.logOut(new Runnable() { |
| 1263 | + @Override |
| 1264 | + public void run() { |
| 1265 | + if (event_poll != null) { |
| 1266 | + event_poll.abort(); |
| 1267 | + event_poll = null; |
| 1268 | + } |
| 1269 | + statusUpdateHandler.removeMessages(0); |
| 1270 | + try { |
| 1271 | + unregisterReceiver(onGcmMessage); |
| 1272 | + } catch (IllegalArgumentException e) { |
| 1273 | + ZLog.logException(e); |
| 1274 | + } |
| 1275 | + |
| 1276 | + app.clearConnectionState(); |
| 1277 | + app.createNewRealm(); |
| 1278 | + app.setEmail(email); |
| 1279 | + app.setServerURL(serverURL); |
| 1280 | + app.saveServerName(realmName); |
| 1281 | + app.setLoggedInApiKey(apiKey); |
| 1282 | + IntentFilter filter = new IntentFilter(GcmBroadcastReceiver.BROADCAST); |
| 1283 | + filter.setPriority(2); |
| 1284 | + registerReceiver(onGcmMessage, filter); |
| 1285 | + onRefresh(); |
| 1286 | + } |
| 1287 | + }); |
| 1288 | + |
| 1289 | + } |
| 1290 | + this.currentList.showLoadIndicatorTop(false); |
| 1291 | + } |
1251 | 1292 | }
|
0 commit comments