From a7f6af28de52d2023fad84a68634c8ee14e3c597 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Thu, 2 Jul 2020 20:19:14 +0200 Subject: Adding internal storage if no external exists --- .../antennapod/adapter/DataFolderAdapter.java | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DataFolderAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/DataFolderAdapter.java index 64560df56..2c35d5a64 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DataFolderAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DataFolderAdapter.java @@ -78,7 +78,9 @@ public class DataFolderAdapter extends RecyclerView.Adapter entries = new ArrayList<>(mediaDirs.length); for (File dir : mediaDirs) { - if (isNotWritable(dir)) continue; - + if (!isWritable(dir)) { + continue; + } entries.add(new StoragePath(dir.getAbsolutePath())); } + if (entries.isEmpty() && isWritable(context.getFilesDir())) { + entries.add(new StoragePath(context.getFilesDir().getAbsolutePath())); + } return entries; } - private boolean isNotWritable(File dir) { - return dir == null || !dir.exists() || !dir.canRead() || !dir.canWrite(); + private boolean isWritable(File dir) { + return dir != null && dir.exists() && dir.canRead() && dir.canWrite(); } private void selectAndDismiss(StoragePath storagePath) { @@ -103,11 +109,11 @@ public class DataFolderAdapter extends RecyclerView.Adapter