use of net.osmand.plus.backup.ExportBackupTask.ItemProgressInfo in project Osmand by osmandapp.
the class ImportBackupTask method onProgressUpdate.
@Override
protected void onProgressUpdate(ItemProgressInfo... progressInfos) {
if (importListener != null) {
for (ItemProgressInfo info : progressInfos) {
ItemProgressInfo prevInfo = getItemProgressInfo(info.type, info.fileName);
if (prevInfo != null) {
info.setWork(prevInfo.getWork());
}
itemsProgress.put(info.type + info.fileName, info);
if (info.isFinished()) {
importListener.onImportItemFinished(info.type, info.fileName);
} else if (info.getValue() == 0) {
importListener.onImportItemStarted(info.type, info.fileName, info.getWork());
} else {
importListener.onImportItemProgress(info.type, info.fileName, info.getValue());
}
}
}
}
use of net.osmand.plus.backup.ExportBackupTask.ItemProgressInfo in project Osmand by osmandapp.
the class ItemViewHolder method setupItemView.
protected void setupItemView(@NonNull String exportKey, @NonNull SettingsItem item, boolean deleteItem) {
OsmandApplication app = getApplication();
String publicName = item.getPublicName(app);
if (item instanceof FileSettingsItem) {
FileSettingsItem settingsItem = (FileSettingsItem) item;
if (settingsItem.getSubtype() == FileSubtype.VOICE) {
publicName += " (" + app.getString(R.string.shared_string_recorded) + ")";
} else if (settingsItem.getSubtype() == FileSubtype.TTS_VOICE) {
publicName += " (" + app.getString(R.string.tts_title) + ")";
}
}
title.setText(publicName);
String fileName = BackupHelper.getItemFileName(item);
String summary = app.getString(R.string.last_backup);
UploadedFileInfo info = app.getBackupHelper().getDbHelper().getUploadedFileInfo(item.getType().name(), fileName);
if (info != null) {
String time = OsmAndFormatter.getFormattedPassedTime(app, info.getUploadTime(), app.getString(R.string.shared_string_never));
description.setText(app.getString(R.string.ltr_or_rtl_combine_via_colon, summary, time));
} else {
description.setText(app.getString(R.string.ltr_or_rtl_combine_via_colon, summary, app.getString(R.string.shared_string_never)));
}
icon.setImageDrawable(getItemIcon(item));
NetworkSettingsHelper settingsHelper = app.getNetworkSettingsHelper();
ImportBackupTask importTask = settingsHelper.getImportTask(exportKey);
ExportBackupTask exportTask = settingsHelper.getExportTask(exportKey);
if (exportTask == null && importTask == null) {
AndroidUiHelper.updateVisibility(secondIcon, deleteItem);
AndroidUiHelper.updateVisibility(progressBar, false);
secondIcon.setImageDrawable(getContentIcon(deleteItem ? R.drawable.ic_action_delete_dark : R.drawable.ic_action_cloud_done));
} else {
ItemProgressInfo progressInfo = null;
if (exportTask != null) {
progressInfo = exportTask.getItemProgressInfo(item.getType().name(), fileName);
}
if (importTask != null) {
progressInfo = importTask.getItemProgressInfo(item.getType().name(), fileName);
}
setupProgress(progressInfo);
}
itemView.setTag(item);
}
Aggregations