Search in sources :

Example 1 with ImportItemsListener

use of net.osmand.plus.backup.ImportBackupItemsTask.ImportItemsListener in project Osmand by osmandapp.

the class ImportBackupTask method onPostExecute.

@Override
protected void onPostExecute(@Nullable List<SettingsItem> items) {
    if (items != null && importType != ImportType.CHECK_DUPLICATES) {
        this.items = items;
    } else {
        selectedItems = items;
    }
    switch(importType) {
        case COLLECT:
        case COLLECT_AND_READ:
            collectListener.onBackupCollectFinished(items != null, false, this.items, remoteFiles);
            helper.importAsyncTasks.remove(key);
            break;
        case CHECK_DUPLICATES:
            if (duplicatesListener != null) {
                duplicatesListener.onDuplicatesChecked(duplicates, selectedItems);
            }
            helper.importAsyncTasks.remove(key);
            break;
        case IMPORT:
        case IMPORT_FORCE_READ:
            if (items != null && items.size() > 0) {
                boolean forceReadData = importType == ImportType.IMPORT_FORCE_READ;
                ImportItemsListener itemsListener = (succeed, needRestart) -> {
                    helper.importAsyncTasks.remove(key);
                    helper.finishImport(importListener, succeed, items, needRestart);
                };
                new ImportBackupItemsTask(app, importer, items, itemsListener, forceReadData).executeOnExecutor(app.getBackupHelper().getExecutor());
            }
            break;
    }
}
Also used : ImportType(net.osmand.plus.settings.backend.backup.SettingsHelper.ImportType) ImportListener(net.osmand.plus.settings.backend.backup.SettingsHelper.ImportListener) AsyncTask(android.os.AsyncTask) BackupCollectListener(net.osmand.plus.backup.NetworkSettingsHelper.BackupCollectListener) NonNull(androidx.annotation.NonNull) CollectItemsResult(net.osmand.plus.backup.BackupImporter.CollectItemsResult) FileSettingsItem(net.osmand.plus.settings.backend.backup.items.FileSettingsItem) IOException(java.io.IOException) HashMap(java.util.HashMap) SettingsItem(net.osmand.plus.settings.backend.backup.items.SettingsItem) OsmandApplication(net.osmand.plus.OsmandApplication) ArrayList(java.util.ArrayList) CollectionSettingsItem(net.osmand.plus.settings.backend.backup.items.CollectionSettingsItem) List(java.util.List) Nullable(androidx.annotation.Nullable) Map(java.util.Map) CheckDuplicatesListener(net.osmand.plus.settings.backend.backup.SettingsHelper.CheckDuplicatesListener) NetworkImportProgressListener(net.osmand.plus.backup.BackupImporter.NetworkImportProgressListener) ProfileSettingsItem(net.osmand.plus.settings.backend.backup.items.ProfileSettingsItem) ItemProgressInfo(net.osmand.plus.backup.ExportBackupTask.ItemProgressInfo) ImportItemsListener(net.osmand.plus.backup.ImportBackupItemsTask.ImportItemsListener) ImportItemsListener(net.osmand.plus.backup.ImportBackupItemsTask.ImportItemsListener)

Aggregations

AsyncTask (android.os.AsyncTask)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 CollectItemsResult (net.osmand.plus.backup.BackupImporter.CollectItemsResult)1 NetworkImportProgressListener (net.osmand.plus.backup.BackupImporter.NetworkImportProgressListener)1 ItemProgressInfo (net.osmand.plus.backup.ExportBackupTask.ItemProgressInfo)1 ImportItemsListener (net.osmand.plus.backup.ImportBackupItemsTask.ImportItemsListener)1 BackupCollectListener (net.osmand.plus.backup.NetworkSettingsHelper.BackupCollectListener)1 CheckDuplicatesListener (net.osmand.plus.settings.backend.backup.SettingsHelper.CheckDuplicatesListener)1 ImportListener (net.osmand.plus.settings.backend.backup.SettingsHelper.ImportListener)1 ImportType (net.osmand.plus.settings.backend.backup.SettingsHelper.ImportType)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