mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-23 12:51:16 +00:00
Fixed crash when opening SettingsActivity
This commit is contained in:
parent
d6ee33e48e
commit
fa49c796ae
2 changed files with 13 additions and 3 deletions
|
@ -98,7 +98,6 @@ public class SettingsActivity extends SyncthingActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
((SyncthingApp) getActivity().getApplication()).component().inject(this);
|
((SyncthingApp) getActivity().getApplication()).component().inject(this);
|
||||||
((SyncthingActivity) getActivity()).registerOnServiceConnectedListener(this);
|
((SyncthingActivity) getActivity()).registerOnServiceConnectedListener(this);
|
||||||
mPreferences.registerOnSharedPreferenceChangeListener(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -297,7 +296,7 @@ public class SettingsActivity extends SyncthingActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends the updated value to {@link }RestApi}, and sets it as the summary
|
* Sends the updated value to {@link RestApi}, and sets it as the summary
|
||||||
* for EditTextPreference.
|
* for EditTextPreference.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -408,9 +407,17 @@ public class SettingsActivity extends SyncthingActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update notification after that preference changes. We can't use onPreferenceChange() as
|
||||||
|
* the preference value isn't persisted there, and the NotificationHandler accesses the
|
||||||
|
* preference directly.
|
||||||
|
*
|
||||||
|
* This function is called when the activity is opened, so we need to make sure the service
|
||||||
|
* is connected.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
if (key.equals(Constants.PREF_NOTIFICATION_TYPE)) {
|
if (key.equals(Constants.PREF_NOTIFICATION_TYPE) && mSyncthingService != null) {
|
||||||
mNotificationHandler.updatePersistentNotification(mSyncthingService);
|
mNotificationHandler.updatePersistentNotification(mSyncthingService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,6 +146,9 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
});
|
});
|
||||||
new GetRequest(mContext, mUrl, GetRequest.URI_CONFIG, mApiKey, null, result -> {
|
new GetRequest(mContext, mUrl, GetRequest.URI_CONFIG, mApiKey, null, result -> {
|
||||||
mConfig = new Gson().fromJson(result, Config.class);
|
mConfig = new Gson().fromJson(result, Config.class);
|
||||||
|
if (mConfig == null) {
|
||||||
|
throw new RuntimeException("config is null: " + result);
|
||||||
|
}
|
||||||
tryIsAvailable();
|
tryIsAvailable();
|
||||||
});
|
});
|
||||||
getSystemInfo(info -> {
|
getSystemInfo(info -> {
|
||||||
|
|
Loading…
Reference in a new issue