Search in sources :

Example 1 with CollectItemsResult

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;
}
Also used : FileSettingsItem(net.osmand.plus.settings.backend.backup.items.FileSettingsItem) SettingsItem(net.osmand.plus.settings.backend.backup.items.SettingsItem) CollectionSettingsItem(net.osmand.plus.settings.backend.backup.items.CollectionSettingsItem) ProfileSettingsItem(net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem) CollectItemsResult(net.osmand.plus.backup.BackupImporter.CollectItemsResult) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 CollectItemsResult (net.osmand.plus.backup.BackupImporter.CollectItemsResult)1 CollectionSettingsItem (net.osmand.plus.settings.backend.backup.items.CollectionSettingsItem)1 FileSettingsItem (net.osmand.plus.settings.backend.backup.items.FileSettingsItem)1 ProfileSettingsItem (net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem)1 SettingsItem (net.osmand.plus.settings.backend.backup.items.SettingsItem)1