summaryrefslogtreecommitdiff
path: root/core/src/main/java/de/danoeh
diff options
context:
space:
mode:
authormalockin <malockin@gmail.com>2020-05-03 22:56:31 +0300
committermalockin <malockin@gmail.com>2020-05-03 22:56:31 +0300
commit1cdfd80ca1561ca0f33313424488354ef6349749 (patch)
tree4d8f60e3768263bd1387823aa33b22b6d6ccd340 /core/src/main/java/de/danoeh
parent10e8f7c614d60104ac381c6593116c5bbfb1595a (diff)
downloadAntennaPod-1cdfd80ca1561ca0f33313424488354ef6349749.zip
Updated PR according to comments
Removed unnecessary checks in while loop, and converted it to a do...while loop. Moved favorites export under HTML section. Corrected indentation in resources files. Moved to using a unified template for all HTML exports. Removed unnecessary strings, corrected capitalization.
Diffstat (limited to 'core/src/main/java/de/danoeh')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/export/favorites/FavoritesWriter.java23
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/export/html/HtmlWriter.java1
2 files changed, 9 insertions, 15 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/export/favorites/FavoritesWriter.java b/core/src/main/java/de/danoeh/antennapod/core/export/favorites/FavoritesWriter.java
index 7b4b38265..4d4ad60bb 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/export/favorites/FavoritesWriter.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/export/favorites/FavoritesWriter.java
@@ -30,9 +30,10 @@ public class FavoritesWriter implements ExportWriter {
throws IllegalArgumentException, IllegalStateException, IOException {
Log.d(TAG, "Starting to write document");
- InputStream templateStream = context.getAssets().open("favorites-export-template.html");
+ InputStream templateStream = context.getAssets().open("html-export-template.html");
String template = IOUtils.toString(templateStream, "UTF-8");
- String[] templateParts = template.split("\\{FAVORITES\\}");
+ template = template.replaceAll("\\{TITLE\\}", "Favorites");
+ String[] templateParts = template.split("\\{FEEDS\\}");
Map<Long, List<FeedItem>> favoriteByFeed = getFeedMap(getFavorites());
@@ -45,7 +46,7 @@ public class FavoritesWriter implements ExportWriter {
writer.append("<li><div>");
writeFeed(writer, favorites.get(0).getFeed());
- writer.append("<ul>");
+ writer.append("<ul style=\"text-align:left\">");
for (FeedItem item : favorites) {
writeFavoriteItem(writer, item);
}
@@ -62,21 +63,13 @@ public class FavoritesWriter implements ExportWriter {
private List<FeedItem> getFavorites() {
int page = 0;
- List<FeedItem> favoritesPage = DBReader.getFavoriteItemsList(page, PAGE_LIMIT);
List<FeedItem> favoritesList = new ArrayList<>();
-
- while (!favoritesPage.isEmpty()) {
+ List<FeedItem> favoritesPage;
+ do {
+ favoritesPage = DBReader.getFavoriteItemsList(page * PAGE_LIMIT, PAGE_LIMIT);
favoritesList.addAll(favoritesPage);
-
- // save a DB call if there are no more items to fetch
- if (favoritesPage.size() < PAGE_LIMIT) {
- break;
- }
-
++page;
-
- favoritesPage = DBReader.getFavoriteItemsList(page * PAGE_LIMIT, PAGE_LIMIT);
- }
+ } while (!favoritesPage.isEmpty() && favoritesPage.size() == PAGE_LIMIT);
// sort in descending order
Collections.sort(favoritesList, (lhs, rhs) -> rhs.getPubDate().compareTo(lhs.getPubDate()));
diff --git a/core/src/main/java/de/danoeh/antennapod/core/export/html/HtmlWriter.java b/core/src/main/java/de/danoeh/antennapod/core/export/html/HtmlWriter.java
index 93b66daed..3f34343ee 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/export/html/HtmlWriter.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/export/html/HtmlWriter.java
@@ -25,6 +25,7 @@ public class HtmlWriter implements ExportWriter {
InputStream templateStream = context.getAssets().open("html-export-template.html");
String template = IOUtils.toString(templateStream, "UTF-8");
+ template = template.replaceAll("\\{TITLE\\}", "Subscriptions");
String[] templateParts = template.split("\\{FEEDS\\}");
writer.append(templateParts[0]);