Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix bug with redundant notification message.

  • Loading branch information...
commit 91036f405fb8a8ae9c9123b836aa4579c52e8c6e 1 parent 735a516
@tdudziak authored
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/com/github/tdudziak/gps_lock_lock/NotificationUi.java
View
8 src/com/github/tdudziak/gps_lock_lock/NotificationUi.java
@@ -22,6 +22,7 @@
private BroadcastReceiver mReceiver;
private Service mService;
private boolean mServiceIsForeground = false;
+ private boolean mIsEnabled = false;
public NotificationUi(Service service) {
mService = service;
@@ -50,18 +51,25 @@ public void onReceive(Context context, Intent intent) {
public void enable() {
IntentFilter filter = new IntentFilter(LockService.ACTION_UI_UPDATE);
LocalBroadcastManager.getInstance(mService).registerReceiver(mReceiver, filter);
+ mIsEnabled = true;
Log.i(TAG, "enable()");
}
public void disable() {
LocalBroadcastManager.getInstance(mService).unregisterReceiver(mReceiver);
mServiceIsForeground = false;
+ mIsEnabled = false;
Log.i(TAG, "disable()");
}
private void redraw(int remaining, int last_fix) {
String title, text;
+ if(!mIsEnabled) {
+ // this sometimes happens when disabled while some messages are still pending
+ return;
+ }
+
if(remaining <= 0) {
// This *must* be the last message; hide the notification.
mNotificationManager.cancel(NOTIFICATION_ID);
Please sign in to comment.
Something went wrong with that request. Please try again.