mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-23 04:41:16 +00:00
Fix crash in settings onApiChange call (fixes #1084)
This commit is contained in:
parent
49853d77fc
commit
533557c135
1 changed files with 15 additions and 13 deletions
|
@ -93,6 +93,7 @@ public class SyncthingService extends Service {
|
||||||
private EventProcessor mEventProcessor;
|
private EventProcessor mEventProcessor;
|
||||||
private DeviceStateHolder mDeviceStateHolder;
|
private DeviceStateHolder mDeviceStateHolder;
|
||||||
private SyncthingRunnable mSyncthingRunnable;
|
private SyncthingRunnable mSyncthingRunnable;
|
||||||
|
private Handler mHandler;
|
||||||
|
|
||||||
private final HashSet<OnApiChangeListener> mOnApiChangeListeners = new HashSet<>();
|
private final HashSet<OnApiChangeListener> mOnApiChangeListeners = new HashSet<>();
|
||||||
private final SyncthingServiceBinder mBinder = new SyncthingServiceBinder(this);
|
private final SyncthingServiceBinder mBinder = new SyncthingServiceBinder(this);
|
||||||
|
@ -180,6 +181,7 @@ public class SyncthingService extends Service {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
PRNGFixes.apply();
|
PRNGFixes.apply();
|
||||||
((SyncthingApp) getApplication()).component().inject(this);
|
((SyncthingApp) getApplication()).component().inject(this);
|
||||||
|
mHandler = new Handler();
|
||||||
|
|
||||||
mDeviceStateHolder = new DeviceStateHolder(SyncthingService.this, this::updateState);
|
mDeviceStateHolder = new DeviceStateHolder(SyncthingService.this, this::updateState);
|
||||||
updateState();
|
updateState();
|
||||||
|
@ -354,21 +356,21 @@ public class SyncthingService extends Service {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to notifiy listeners of an API change.
|
* 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) {
|
private void onApiChange(State newState) {
|
||||||
mCurrentState = newState;
|
mHandler.post(() -> {
|
||||||
mNotificationHandler.updatePersistentNotification(this);
|
mCurrentState = newState;
|
||||||
for (Iterator<OnApiChangeListener> i = mOnApiChangeListeners.iterator();
|
mNotificationHandler.updatePersistentNotification(this);
|
||||||
i.hasNext(); ) {
|
for (Iterator<OnApiChangeListener> i = mOnApiChangeListeners.iterator();
|
||||||
OnApiChangeListener listener = i.next();
|
i.hasNext(); ) {
|
||||||
if (listener != null) {
|
OnApiChangeListener listener = i.next();
|
||||||
listener.onApiChange(mCurrentState);
|
if (listener != null) {
|
||||||
} else {
|
listener.onApiChange(mCurrentState);
|
||||||
i.remove();
|
} else {
|
||||||
|
i.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public URL getWebGuiUrl() {
|
public URL getWebGuiUrl() {
|
||||||
|
|
Loading…
Reference in a new issue