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

Commit 32faaeb

Browse files
kunall17niftynei
authored andcommitted
Fix: multiple asyncGetEvents
1 parent aa15fc3 commit 32faaeb

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,7 @@ private void startRequests() {
13941394

13951395
if (event_poll != null) {
13961396
event_poll.abort();
1397+
event_poll = null;
13971398
}
13981399

13991400
event_poll = new AsyncGetEvents(this);

app/src/main/java/com/zulip/android/networking/AsyncGetEvents.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class AsyncGetEvents extends Thread {
3434
private ZulipActivity activity;
3535
private ZulipApp app;
3636

37+
private boolean keepThisRunning = true;
3738
private HTTPRequest request;
3839

3940
private AsyncGetEvents that = this;
@@ -56,6 +57,7 @@ public void abort() {
5657
// TODO: does this have race conditions? (if the thread is not in a
5758
// request when called)
5859
Log.i(ASYNC_GET_EVENTS, "Interrupting thread");
60+
keepThisRunning = false;
5961
request.abort();
6062
}
6163

@@ -98,7 +100,7 @@ private void register() throws JSONException, IOException {
98100

99101
public void run() {
100102
try {
101-
while (true) {
103+
while (keepThisRunning) {
102104
try {
103105
request.clearProperties();
104106
if (app.getEventQueueId() == null) {

0 commit comments

Comments
 (0)