1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-01 16:51:16 +00:00

FolderActivity/DeviceActivity: Fix restApi unavailable in onCreate()

This commit is contained in:
Catfriend1 2019-01-26 18:12:05 +01:00
parent e0dc77d4d1
commit f9927aa603
2 changed files with 9 additions and 8 deletions

View file

@ -223,8 +223,8 @@ public class DeviceActivity extends SyncthingActivity {
// Edit mode. // Edit mode.
String passedId = getIntent().getStringExtra(EXTRA_DEVICE_ID); String passedId = getIntent().getStringExtra(EXTRA_DEVICE_ID);
Log.d(TAG, "Initializing edit mode: deviceID=" + passedId); Log.d(TAG, "Initializing edit mode: deviceID=" + passedId);
RestApi restApi = getApi(); // getApi() is unavailable (onCreate > onPostCreate > onServiceConnected)
List<Device> devices = mConfig.getDevices(restApi, false); List<Device> devices = mConfig.getDevices(null, false);
mDevice = null; mDevice = null;
for (Device currentDevice : devices) { for (Device currentDevice : devices) {
if (currentDevice.deviceID.equals(passedId)) { if (currentDevice.deviceID.equals(passedId)) {
@ -237,9 +237,6 @@ public class DeviceActivity extends SyncthingActivity {
finish(); finish();
return; return;
} }
if (restApi != null) {
restApi.getConnections(this::onReceiveConnections);
}
mDeviceNeedsToUpdate = false; mDeviceNeedsToUpdate = false;
} }
} }
@ -276,6 +273,10 @@ public class DeviceActivity extends SyncthingActivity {
SyncthingServiceBinder syncthingServiceBinder = (SyncthingServiceBinder) iBinder; SyncthingServiceBinder syncthingServiceBinder = (SyncthingServiceBinder) iBinder;
SyncthingService syncthingService = (SyncthingService) syncthingServiceBinder.getService(); SyncthingService syncthingService = (SyncthingService) syncthingServiceBinder.getService();
syncthingService.getNotificationHandler().cancelConsentNotification(getIntent().getIntExtra(EXTRA_NOTIFICATION_ID, 0)); syncthingService.getNotificationHandler().cancelConsentNotification(getIntent().getIntExtra(EXTRA_NOTIFICATION_ID, 0));
RestApi restApi = syncthingService.getApi();
if (restApi != null) {
restApi.getConnections(this::onReceiveConnections);
}
} }
@Override @Override

View file

@ -235,8 +235,8 @@ public class FolderActivity extends SyncthingActivity {
// Edit mode. // Edit mode.
String passedId = getIntent().getStringExtra(EXTRA_FOLDER_ID); String passedId = getIntent().getStringExtra(EXTRA_FOLDER_ID);
Log.d(TAG, "Initializing edit mode: folder.id=" + passedId); Log.d(TAG, "Initializing edit mode: folder.id=" + passedId);
RestApi restApi = getApi(); // getApi() is unavailable (onCreate > onPostCreate > onServiceConnected)
List<Folder> folders = mConfig.getFolders(restApi); List<Folder> folders = mConfig.getFolders(null);
mFolder = null; mFolder = null;
for (Folder currentFolder : folders) { for (Folder currentFolder : folders) {
if (currentFolder.id.equals(passedId)) { if (currentFolder.id.equals(passedId)) {
@ -249,7 +249,7 @@ public class FolderActivity extends SyncthingActivity {
finish(); finish();
return; return;
} }
mConfig.getFolderIgnoreList(restApi, mFolder, this::onReceiveFolderIgnoreList); mConfig.getFolderIgnoreList(null, mFolder, this::onReceiveFolderIgnoreList);
mFolderNeedsToUpdate = false; mFolderNeedsToUpdate = false;
} }