diff options
author | ByteHamster <info@bytehamster.com> | 2022-01-22 15:14:44 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2022-01-22 23:09:32 +0100 |
commit | b28a98067f45e541fcc7341226486dbb26c62516 (patch) | |
tree | 0e963c03ee967e6121437512d10c819772a1ad7d | |
parent | e9e1fc14c38737ffd8b85a0fc799b0c4a1893030 (diff) | |
download | antennapod-b28a98067f45e541fcc7341226486dbb26c62516.zip |
Prefer chapter list with more info
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/feed/ChapterMerger.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/ChapterMerger.java b/core/src/main/java/de/danoeh/antennapod/core/feed/ChapterMerger.java index 80e669939..9bbab7251 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/ChapterMerger.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/ChapterMerger.java @@ -37,7 +37,7 @@ public class ChapterMerger { if (Math.abs(chapterTarget.getStart() - chapterOther.getStart()) > 1000) { Log.e(TAG, "Chapter lists are too different. Cancelling merge."); - return chapters1; + return score(chapters1) > score(chapters2) ? chapters1 : chapters2; } if (TextUtils.isEmpty(chapterTarget.getImageUrl())) { @@ -53,4 +53,18 @@ public class ChapterMerger { return chapters2; } } + + /** + * Tries to give a score that can determine which list of chapters a user might want to see. + */ + private static int score(List<Chapter> chapters) { + int score = 0; + for (Chapter chapter : chapters) { + score = score + + (TextUtils.isEmpty(chapter.getTitle()) ? 0 : 1) + + (TextUtils.isEmpty(chapter.getLink()) ? 0 : 1) + + (TextUtils.isEmpty(chapter.getImageUrl()) ? 0 : 1); + } + return score; + } } |