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

Commit 5e4a1e6

Browse files
committed
Switch realm method in ZulipActivity
Abort current connections, handlers and establish new ones.
1 parent f7716ce commit 5e4a1e6

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
@@ -1074,4 +1074,24 @@ public void onNewMessages(Message[] messages) {
10741074
narrowedList.onNewMessages(messages);
10751075
}
10761076
}
1077+
1078+
void switchRealm(final ProgressDialog progressDialog, final int position) {
1079+
if (event_poll != null) {
1080+
event_poll.abort();
1081+
event_poll = null;
1082+
}
1083+
statusUpdateHandler.removeMessages(0);
1084+
unregisterReceiver(onGcmMessage);
1085+
app.clearConnectionState();
1086+
app.switchToRealm(position);
1087+
app.resetDatabase();
1088+
app.setEmail(app.getYou().getEmail());
1089+
event_poll = new AsyncGetEvents(ZulipActivity.this);
1090+
event_poll.start();
1091+
IntentFilter filter = new IntentFilter(GcmBroadcastReceiver.BROADCAST);
1092+
filter.setPriority(2);
1093+
registerReceiver(onGcmMessage, filter);
1094+
progressDialog.dismiss();
1095+
}
1096+
10771097
}

0 commit comments

Comments
 (0)