Skip to content

Commit

Permalink
FolderActivity/DeviceActivity: Fix restApi unavailable in onCreate()
Browse files Browse the repository at this point in the history
  • Loading branch information
Catfriend1 committed Jan 26, 2019
1 parent 2b38fed commit f1218a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ public void onCreate(Bundle savedInstanceState) {
// Edit mode.
String passedId = getIntent().getStringExtra(EXTRA_DEVICE_ID);
Log.d(TAG, "Initializing edit mode: deviceID=" + passedId);
RestApi restApi = getApi();
List<Device> devices = mConfig.getDevices(restApi, false);
// getApi() is unavailable (onCreate > onPostCreate > onServiceConnected)
List<Device> devices = mConfig.getDevices(null, false);
mDevice = null;
for (Device currentDevice : devices) {
if (currentDevice.deviceID.equals(passedId)) {
Expand All @@ -237,9 +237,6 @@ public void onCreate(Bundle savedInstanceState) {
finish();
return;
}
if (restApi != null) {
restApi.getConnections(this::onReceiveConnections);
}
mDeviceNeedsToUpdate = false;
}
}
Expand Down Expand Up @@ -276,6 +273,10 @@ public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
SyncthingServiceBinder syncthingServiceBinder = (SyncthingServiceBinder) iBinder;
SyncthingService syncthingService = (SyncthingService) syncthingServiceBinder.getService();
syncthingService.getNotificationHandler().cancelConsentNotification(getIntent().getIntExtra(EXTRA_NOTIFICATION_ID, 0));
RestApi restApi = syncthingService.getApi();
if (restApi != null) {
restApi.getConnections(this::onReceiveConnections);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ public void onCreate(Bundle savedInstanceState) {
// Edit mode.
String passedId = getIntent().getStringExtra(EXTRA_FOLDER_ID);
Log.d(TAG, "Initializing edit mode: folder.id=" + passedId);
RestApi restApi = getApi();
List<Folder> folders = mConfig.getFolders(restApi);
// getApi() is unavailable (onCreate > onPostCreate > onServiceConnected)
List<Folder> folders = mConfig.getFolders(null);
mFolder = null;
for (Folder currentFolder : folders) {
if (currentFolder.id.equals(passedId)) {
Expand All @@ -249,7 +249,7 @@ public void onCreate(Bundle savedInstanceState) {
finish();
return;
}
mConfig.getFolderIgnoreList(restApi, mFolder, this::onReceiveFolderIgnoreList);
mConfig.getFolderIgnoreList(null, mFolder, this::onReceiveFolderIgnoreList);
mFolderNeedsToUpdate = false;
}

Expand Down

0 comments on commit f1218a6

Please sign in to comment.