Merge pull request #1512 from nextcloud/fix-npe

Fix NPE
This commit is contained in:
Tobias Kaminsky 2017-09-11 08:52:33 +02:00 committed by GitHub
commit 620d18d7a8
4 changed files with 12 additions and 11 deletions

View file

@ -186,7 +186,7 @@ public class MainApp extends MultiDexApplication {
initiateExistingAutoUploadEntries();
FilesSyncHelper.scheduleFilesSyncIfNeeded();
FilesSyncHelper.scheduleFilesSyncIfNeeded(mContext);
FilesSyncHelper.restartJobsIfNeeded();
ReceiversHelper.registerNetworkChangeReceiver();

View file

@ -56,7 +56,7 @@ public class NContentObserverJob extends JobService {
.schedule();
}
FilesSyncHelper.scheduleNJobs(true);
FilesSyncHelper.scheduleNJobs(true, getApplicationContext());
}
return true;

View file

@ -502,7 +502,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + syncedFolderDisplayItem.getId();
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
}
FilesSyncHelper.scheduleNJobs(false);
FilesSyncHelper.scheduleNJobs(false, getApplicationContext());
}
@ -555,7 +555,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + newCustomFolder.getId();
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
}
FilesSyncHelper.scheduleNJobs(false);
FilesSyncHelper.scheduleNJobs(false, getApplicationContext());
}
mAdapter.addSyncFolderItem(newCustomFolder);
} else {
@ -575,7 +575,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + item.getId();
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
}
FilesSyncHelper.scheduleNJobs(false);
FilesSyncHelper.scheduleNJobs(false, getApplicationContext());
}
} else {
// existing synced folder setup to be updated
@ -586,7 +586,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
String syncedFolderInitiatedKey = "syncedFolderIntitiated_" + item.getId();
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey);
}
FilesSyncHelper.scheduleNJobs(false);
FilesSyncHelper.scheduleNJobs(false, getApplicationContext());
}
mAdapter.setSyncFolderItem(syncedFolder.getSection(), item);

View file

@ -253,9 +253,8 @@ public class FilesSyncHelper {
return false;
}
public static void scheduleNJobs(boolean force) {
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(MainApp.getAppContext().
getContentResolver());
public static void scheduleNJobs(boolean force, Context context) {
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(context.getContentResolver());
boolean hasVideoFolders = false;
@ -282,7 +281,7 @@ public class FilesSyncHelper {
}
}
public static void scheduleFilesSyncIfNeeded() {
public static void scheduleFilesSyncIfNeeded(Context context) {
// always run this because it also allows us to perform retries of manual uploads
new JobRequest.Builder(FilesSyncJob.TAG)
.setPeriodic(900000L, 300000L)
@ -290,7 +289,9 @@ public class FilesSyncHelper {
.build()
.schedule();
scheduleNJobs(false);
if (context != null) {
scheduleNJobs(false, context);
}
}
@RequiresApi(api = Build.VERSION_CODES.N)