1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-22 20:31:16 +00:00

Fix crash in settings onApiChange call (fixes #1084)

This commit is contained in:
Felix Ableitner 2018-05-10 19:13:49 +02:00 committed by Audrius Butkevicius
parent 49853d77fc
commit 533557c135

View file

@ -93,6 +93,7 @@ public class SyncthingService extends Service {
private EventProcessor mEventProcessor;
private DeviceStateHolder mDeviceStateHolder;
private SyncthingRunnable mSyncthingRunnable;
private Handler mHandler;
private final HashSet<OnApiChangeListener> mOnApiChangeListeners = new HashSet<>();
private final SyncthingServiceBinder mBinder = new SyncthingServiceBinder(this);
@ -180,6 +181,7 @@ public class SyncthingService extends Service {
super.onCreate();
PRNGFixes.apply();
((SyncthingApp) getApplication()).component().inject(this);
mHandler = new Handler();
mDeviceStateHolder = new DeviceStateHolder(SyncthingService.this, this::updateState);
updateState();
@ -354,10 +356,9 @@ public class SyncthingService extends Service {
/**
* Called to notifiy listeners of an API change.
*
* Must only be called from SyncthingService or {@link RestApi} on the main thread.
*/
private void onApiChange(State newState) {
mHandler.post(() -> {
mCurrentState = newState;
mNotificationHandler.updatePersistentNotification(this);
for (Iterator<OnApiChangeListener> i = mOnApiChangeListeners.iterator();
@ -369,6 +370,7 @@ public class SyncthingService extends Service {
i.remove();
}
}
});
}
public URL getWebGuiUrl() {