Skip to content

Commit 314e088

Browse files
committed
Don't send repetitive notifications.
1 parent f7dde3d commit 314e088

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app/src/main/java/org/leyfer/thesis/touchlogger_dirty/notification/ControlNotification.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public class ControlNotification {
2929
private final NotificationCompat.Action resumeAction;
3030
private final NotificationManager notificationManager;
3131

32+
private StatusEvent.Status currentStatus = StatusEvent.Status.STATUS_OFFLINE;
33+
3234
public ControlNotification(Context context) {
3335
this.context = context;
3436

@@ -114,9 +116,13 @@ public void onResumed() {
114116
@Subscribe(threadMode = ThreadMode.MAIN)
115117
public void onStatusEvent(StatusEvent statusEvent) {
116118
if (statusEvent.getStatus() == StatusEvent.Status.STATUS_ONLINE) {
117-
setOnline(statusEvent.getStatusString());
119+
if (currentStatus != StatusEvent.Status.STATUS_ONLINE) {
120+
setOnline(statusEvent.getStatusString());
121+
}
118122
} else if (statusEvent.getStatus() == StatusEvent.Status.STATUS_OFFLINE) {
119-
setOffline(statusEvent.getStatusString());
123+
if (currentStatus != StatusEvent.Status.STATUS_OFFLINE) {
124+
setOffline(statusEvent.getStatusString());
125+
}
120126
}
121127
}
122128

0 commit comments

Comments
 (0)