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

Commit 25c93f5

Browse files
kunall17niftynei
authored andcommitted
Prevent adding new messages to Main Activity adapter if started from widget
1 parent 2d484b2 commit 25c93f5

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

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

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ public AsyncGetEvents(ZulipApp zulipApp, int interval) {
6969

7070
public void start() {
7171
registeredOrGotEventsThisRun = false;
72-
super.start();
72+
if (!calledFromWidget) {
73+
super.start();
74+
}
7375
}
7476

7577
public void abort() {
@@ -251,15 +253,16 @@ public Void call() throws Exception {
251253
});
252254
watch.stop();
253255
Log.i("perf", "DB people and streams: " + watch.toString());
254-
255-
activity.runOnUiThread(new Runnable() {
256-
@Override
257-
public void run() {
258-
that.activity.getPeopleAdapter().refresh();
259-
activity.onReadyToDisplay(true);
260-
activity.checkAndSetupStreamsDrawer();
261-
}
262-
});
256+
if (!calledFromWidget) {
257+
activity.runOnUiThread(new Runnable() {
258+
@Override
259+
public void run() {
260+
that.activity.getPeopleAdapter().refresh();
261+
activity.onReadyToDisplay(true);
262+
activity.checkAndSetupStreamsDrawer();
263+
}
264+
});
265+
}
263266
} catch (JSONException e) {
264267
ZLog.logException(e);
265268
} catch (SQLException e) {
@@ -326,12 +329,14 @@ private void processMessages(final ArrayList<Message> messages) {
326329
int lastMessageId = messages.get(messages.size() - 1).getID();
327330
MessageRange.updateNewMessagesRange(app, lastMessageId);
328331

329-
activity.runOnUiThread(new Runnable() {
330-
@Override
331-
public void run() {
332-
activity.onNewMessages(messages.toArray(new Message[messages.size()]));
333-
}
334-
});
332+
if (!calledFromWidget) {
333+
activity.runOnUiThread(new Runnable() {
334+
@Override
335+
public void run() {
336+
activity.onNewMessages(messages.toArray(new Message[messages.size()]));
337+
}
338+
});
339+
}
335340
}
336341

337342
}

0 commit comments

Comments
 (0)