diff options
author | ByteHamster <info@bytehamster.com> | 2020-07-02 20:19:14 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2020-07-02 20:19:14 +0200 |
commit | a7f6af28de52d2023fad84a68634c8ee14e3c597 (patch) | |
tree | 091d08e8e3a2162e0bd0fe676ee3a682e915292b /app/src | |
parent | 148b86a3e84a65cade4765c6224918f57109b5b3 (diff) | |
download | AntennaPod-a7f6af28de52d2023fad84a68634c8ee14e3c597.zip |
Adding internal storage if no external exists
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/adapter/DataFolderAdapter.java | 26 |
1 files changed, 16 insertions, 10 deletions
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<DataFolderAdapter.Vi private String getCurrentPath() { File dataFolder = UserPreferences.getDataFolder(null); - if (dataFolder != null) return dataFolder.getAbsolutePath(); + if (dataFolder != null) { + return dataFolder.getAbsolutePath(); + } return null; } @@ -86,15 +88,19 @@ public class DataFolderAdapter extends RecyclerView.Adapter<DataFolderAdapter.Vi File[] mediaDirs = ContextCompat.getExternalFilesDirs(context, null); final List<StoragePath> 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<DataFolderAdapter.Vi } static class ViewHolder extends RecyclerView.ViewHolder { - private View root; - private TextView path; - private TextView size; - private RadioButton radioButton; - private ProgressBar progressBar; + private final View root; + private final TextView path; + private final TextView size; + private final RadioButton radioButton; + private final ProgressBar progressBar; ViewHolder(View itemView) { super(itemView); |