Skip to content

Commit

Permalink
added event listening to QuickSettingsService in order to properly up…
Browse files Browse the repository at this point in the history
…date tile when server state changes through some other mechanism
  • Loading branch information
wolpi committed Dec 12, 2023
1 parent 3531cec commit d9adbec
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions primitiveFTPd/src/org/primftpd/services/QuickSettingsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.primftpd.R;
import org.primftpd.events.ServerStateChangedEvent;
import org.primftpd.prefs.LoadPrefsUtil;
import org.primftpd.util.ServersRunningBean;
import org.primftpd.util.ServicesStartStopUtil;
Expand Down Expand Up @@ -96,13 +100,21 @@ public void onStartListening() {
logger.debug("onStartListening");
super.onStartListening();
updateTile();
EventBus.getDefault().register(this);
}

@Override
public void onStopListening() {
logger.debug("onStopListening");
super.onStopListening();
updateTile();
EventBus.getDefault().unregister(this);
}

@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
public void onEvent(ServerStateChangedEvent event) {
logger.debug("got ServerStateChangedEvent");
updateTile();
}

/**
Expand Down

0 comments on commit d9adbec

Please sign in to comment.