diff options
author | Herbert Reiter <46045854+damoasda@users.noreply.github.com> | 2021-01-13 21:11:17 +0100 |
---|---|---|
committer | Herbert Reiter <46045854+damoasda@users.noreply.github.com> | 2021-01-13 21:11:17 +0100 |
commit | 5d1ef31a4ace38bf33a9c609cd48d755929ba327 (patch) | |
tree | a29c724981e860c7d14260bbad594e8f93c612ac /core/src/main | |
parent | 1f329cdde06000e8cfca295db48bdb447be9fe51 (diff) | |
download | AntennaPod-5d1ef31a4ace38bf33a9c609cd48d755929ba327.zip |
Refactor method: Use early return instead of late return to make the code more readable
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java b/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java index 7eb6618b5..d0e15d591 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java @@ -116,33 +116,24 @@ public class LocalFeedUpdater { */ @NonNull static String getImageUrl(@NonNull Context context, @NonNull DocumentFile documentFolder) { - String imageUrl = null; - // look for special file names for (String iconLocation : PREFERRED_FEED_IMAGE_FILENAMES) { DocumentFile image = documentFolder.findFile(iconLocation); if (image != null) { - imageUrl = image.getUri().toString(); - break; + return image.getUri().toString(); } } // use the first image in the folder if existing - if (imageUrl == null) { - for (DocumentFile file : documentFolder.listFiles()) { - String mime = file.getType(); - if (mime != null && (mime.startsWith("image/jpeg") || mime.startsWith("image/png"))) { - imageUrl = file.getUri().toString(); - break; - } + for (DocumentFile file : documentFolder.listFiles()) { + String mime = file.getType(); + if (mime != null && (mime.startsWith("image/jpeg") || mime.startsWith("image/png"))) { + return file.getUri().toString(); } } // use default icon as fallback - if (imageUrl == null) { - imageUrl = getDefaultIconUrl(context); - } - return imageUrl; + return getDefaultIconUrl(context); } /** |