use of net.osmand.plus.backup.BackupImporter.CollectItemsResult in project Osmand by osmandapp.
the class ImportBackupTask method doInBackground.
@Override
protected List<SettingsItem> doInBackground(Void... voids) {
switch(importType) {
case COLLECT:
case COLLECT_AND_READ:
try {
CollectItemsResult result = importer.collectItems(importType == ImportType.COLLECT_AND_READ);
remoteFiles = result.remoteFiles;
return result.items;
} catch (IllegalArgumentException e) {
NetworkSettingsHelper.LOG.error("Failed to collect items for backup", e);
} catch (IOException e) {
NetworkSettingsHelper.LOG.error("Failed to collect items for backup", e);
}
break;
case CHECK_DUPLICATES:
this.duplicates = getDuplicatesData(selectedItems);
return selectedItems;
case IMPORT:
case IMPORT_FORCE_READ:
if (items != null && items.size() > 0) {
BackupHelper backupHelper = app.getBackupHelper();
PrepareBackupResult backup = backupHelper.getBackup();
for (SettingsItem item : items) {
item.apply();
String fileName = item.getFileName();
if (fileName != null) {
RemoteFile remoteFile = backup.getRemoteFile(item.getType().name(), fileName);
if (remoteFile != null) {
backupHelper.updateFileUploadTime(remoteFile.getType(), remoteFile.getName(), remoteFile.getClienttimems());
}
}
}
}
return items;
}
return null;
}
Aggregations