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

Commit 1c218a0

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

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
@@ -1226,4 +1226,24 @@ public void onNewMessages(Message[] messages) {
12261226
narrowedList.onNewMessages(messages);
12271227
}
12281228
}
1229+
1230+
void switchRealm(final ProgressDialog progressDialog, final int position) {
1231+
if (event_poll != null) {
1232+
event_poll.abort();
1233+
event_poll = null;
1234+
}
1235+
statusUpdateHandler.removeMessages(0);
1236+
unregisterReceiver(onGcmMessage);
1237+
app.clearConnectionState();
1238+
app.switchToRealm(position);
1239+
app.resetDatabase();
1240+
app.setEmail(app.getYou().getEmail());
1241+
event_poll = new AsyncGetEvents(ZulipActivity.this);
1242+
event_poll.start();
1243+
IntentFilter filter = new IntentFilter(GcmBroadcastReceiver.BROADCAST);
1244+
filter.setPriority(2);
1245+
registerReceiver(onGcmMessage, filter);
1246+
progressDialog.dismiss();
1247+
}
1248+
12291249
}

0 commit comments

Comments
 (0)