use of de.geeksfactory.opacclient.webservice.WebService in project opacclient by opacapp.
the class SyncAccountJob method updateLibraryConfig.
private void updateLibraryConfig() {
PreferenceDataSource prefs = new PreferenceDataSource(getContext());
if (prefs.getLastLibraryConfigUpdate() != null && prefs.getLastLibraryConfigUpdate().isAfter(DateTime.now().minus(Hours.ONE))) {
Log.d(TAG, "Do not run updateLibraryConfig as last run was less than an hour ago.");
return;
}
WebService service = WebServiceManager.getInstance();
File filesDir = new File(getContext().getFilesDir(), LibraryConfigUpdateService.LIBRARIES_DIR);
filesDir.mkdirs();
try {
int count = getApp().getUpdateHandler().updateConfig(service, prefs, new LibraryConfigUpdateService.FileOutput(filesDir), new JsonSearchFieldDataSource(getContext()));
Log.d(TAG, "updated config for " + String.valueOf(count) + " libraries");
getApp().resetCache();
if (!BuildConfig.DEBUG) {
ACRA.getErrorReporter().putCustomData("data_version", prefs.getLastLibraryConfigUpdate().toString());
}
} catch (IOException | JSONException ignore) {
}
}
Aggregations