1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 19:31:30 +00:00

Dont crash when rotating screen in settings (fixes #806)

This commit is contained in:
Felix Ableitner 2016-12-12 15:38:50 +09:00
parent 8bcf33b051
commit 92bf84915c

View file

@ -160,6 +160,9 @@ public class SettingsActivity extends SyncthingActivity {
@Override @Override
public void onServiceConnected() { public void onServiceConnected() {
if (getActivity() == null)
return;
mSyncthingService = ((SyncthingActivity) getActivity()).getService(); mSyncthingService = ((SyncthingActivity) getActivity()).getService();
mSyncthingService.registerOnApiChangeListener(this); mSyncthingService.registerOnApiChangeListener(this);
if (mSyncthingService.getApi().isConfigLoaded()) { if (mSyncthingService.getApi().isConfigLoaded()) {
@ -205,7 +208,8 @@ public class SettingsActivity extends SyncthingActivity {
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
mSyncthingService.unregisterOnApiChangeListener(this); if (mSyncthingService != null)
mSyncthingService.unregisterOnApiChangeListener(this);
} }
private void setPreferenceCategoryChangeListener( private void setPreferenceCategoryChangeListener(