mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-23 04:41:16 +00:00
Attempt to fix NPE when calling SyncthingService.getApi().isConfigLoaded()
This commit is contained in:
parent
8e1dfe875e
commit
94d72d768f
2 changed files with 10 additions and 5 deletions
|
@ -175,10 +175,14 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
|
||||
mSyncthingService = ((SyncthingActivity) getActivity()).getService();
|
||||
mSyncthingService.registerOnApiChangeListener(this);
|
||||
if (mSyncthingService.getApi().isConfigLoaded()) {
|
||||
mGui = mSyncthingService.getApi().getGui();
|
||||
mOptions = mSyncthingService.getApi().getOptions();
|
||||
}
|
||||
// Use callback to make sure getApi() doesn't return null.
|
||||
mSyncthingService.registerOnWebGuiAvailableListener(() -> {
|
||||
if (mSyncthingService.getApi().isConfigLoaded()) {
|
||||
mGui = mSyncthingService.getApi().getGui();
|
||||
mOptions = mSyncthingService.getApi().getOptions();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,6 +15,7 @@ import android.os.Environment;
|
|||
import android.os.IBinder;
|
||||
import android.os.PowerManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
@ -457,7 +458,7 @@ public class SyncthingService extends Service implements
|
|||
return !new File(getFilesDir(), PUBLIC_KEY_FILE).exists();
|
||||
}
|
||||
|
||||
public RestApi getApi() {
|
||||
public @Nullable RestApi getApi() {
|
||||
return mApi;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue