Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit b8fb68b

Browse files
committed
Switch realm method in ZulipActivity
Abort current connections, handlers and establish new ones.
1 parent 21c0d2a commit b8fb68b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

app/src/main/java/com/zulip/android/activities/ZulipActivity.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,4 +1419,24 @@ public void onNewMessages(Message[] messages) {
14191419
narrowedList.onNewMessages(messages);
14201420
}
14211421
}
1422+
1423+
void switchRealm(final ProgressDialog progressDialog, final int position) {
1424+
if (event_poll != null) {
1425+
event_poll.abort();
1426+
event_poll = null;
1427+
}
1428+
statusUpdateHandler.removeMessages(0);
1429+
unregisterReceiver(onGcmMessage);
1430+
app.clearConnectionState();
1431+
app.switchToRealm(position);
1432+
app.resetDatabase();
1433+
app.setEmail(app.getYou().getEmail());
1434+
event_poll = new AsyncGetEvents(ZulipActivity.this);
1435+
event_poll.start();
1436+
IntentFilter filter = new IntentFilter(GcmBroadcastReceiver.BROADCAST);
1437+
filter.setPriority(2);
1438+
registerReceiver(onGcmMessage, filter);
1439+
progressDialog.dismiss();
1440+
}
1441+
14221442
}

0 commit comments

Comments
 (0)