Code cleanup.

This commit is contained in:
Dennis Guse
2020-11-01 08:38:47 +01:00
parent 0f92a37146
commit 0209a90e01
6 changed files with 19 additions and 62 deletions
@@ -21,10 +21,10 @@ public class ImportViewModel extends AndroidViewModel implements ImportServiceRe
private static final String TAG = ImportViewModel.class.getSimpleName();
private MutableLiveData<Summary> importData;
private ImportServiceResultReceiver resultReceiver;
private Summary summary;
private final ImportServiceResultReceiver resultReceiver;
private final Summary summary;
private boolean cancel = false;
private List<DocumentFile> filesToImport = new ArrayList<>();
private final List<DocumentFile> filesToImport = new ArrayList<>();
public ImportViewModel(@NonNull Application application) {
super(application);
@@ -47,9 +47,7 @@ public class ImportViewModel extends AndroidViewModel implements ImportServiceRe
private void loadData(DocumentFile documentFile) {
List<DocumentFile> fileList = FileUtils.getFiles(documentFile);
summary.totalCount = fileList.size();
for (DocumentFile df : fileList) {
filesToImport.add(df);
}
filesToImport.addAll(fileList);
importNextFile();
}
@@ -89,12 +87,12 @@ public class ImportViewModel extends AndroidViewModel implements ImportServiceRe
importNextFile();
}
public class Summary {
public static class Summary {
private int totalCount;
private int successCount;
private int existsCount;
private int errorCount;
private ArrayList<String> fileErrors = new ArrayList<>();
private final ArrayList<String> fileErrors = new ArrayList<>();
public int getTotalCount() {
return totalCount;
@@ -190,10 +190,7 @@ public class KmzTrackImporter implements TrackImporter {
zipInputStream.closeEntry();
}
return trackId;
} catch (ImportParserException e) {
Log.e(TAG, "Unable to import file", e);
throw e;
} catch (ImportAlreadyExistsException e) {
} catch (ImportParserException | ImportAlreadyExistsException e) {
Log.e(TAG, "Unable to import file", e);
throw e;
} catch (IOException e) {
@@ -259,9 +256,7 @@ public class KmzTrackImporter implements TrackImporter {
try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(getKml(zipInputStream))) {
return kmlFileTrackImporter.importFile(byteArrayInputStream);
} catch (ImportParserException e) {
throw e;
} catch (ImportAlreadyExistsException e) {
} catch (ImportParserException | ImportAlreadyExistsException e) {
throw e;
} catch (Exception e) {
throw new ImportParserException(e);