summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/de/danoeh/antennapod/dialog/StreamingConfirmationDialog.java2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java21
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java21
-rw-r--r--core/src/main/res/values/strings.xml3
5 files changed, 29 insertions, 20 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/StreamingConfirmationDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/StreamingConfirmationDialog.java
index 46095604c..8e5ceece2 100644
--- a/app/src/main/java/de/danoeh/antennapod/dialog/StreamingConfirmationDialog.java
+++ b/app/src/main/java/de/danoeh/antennapod/dialog/StreamingConfirmationDialog.java
@@ -20,7 +20,7 @@ public class StreamingConfirmationDialog {
new AlertDialog.Builder(context)
.setTitle(R.string.stream_label)
.setMessage(R.string.confirm_mobile_streaming_notification_message)
- .setPositiveButton(R.string.stream_label, (dialog, which) -> stream())
+ .setPositiveButton(R.string.confirm_mobile_streaming_button_once, (dialog, which) -> stream())
.setNegativeButton(R.string.confirm_mobile_streaming_button_always, (dialog, which) -> {
UserPreferences.setAllowMobileStreaming(true);
stream();
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
index 8677ea030..92f395d0d 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
@@ -580,7 +580,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setContentIntent(pendingIntentAllowThisTime)
.addAction(R.drawable.ic_stream_white,
- getString(R.string.stream_label),
+ getString(R.string.confirm_mobile_streaming_button_once),
pendingIntentAllowThisTime)
.addAction(R.drawable.ic_stream_white,
getString(R.string.confirm_mobile_streaming_button_always),
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
index fd8ca116d..892254507 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
@@ -852,24 +852,11 @@ public final class DBReader {
}
};
} else {
+ final Map<Long, Long> recentPubDates = adapter.getMostRecentItemDates();
comparator = (lhs, rhs) -> {
- if (lhs.getItems() == null || lhs.getItems().size() == 0) {
- List<FeedItem> items = DBReader.getFeedItemList(lhs);
- lhs.setItems(items);
- }
- if (rhs.getItems() == null || rhs.getItems().size() == 0) {
- List<FeedItem> items = DBReader.getFeedItemList(rhs);
- rhs.setItems(items);
- }
- if (lhs.getMostRecentItem() == null) {
- return 1;
- } else if (rhs.getMostRecentItem() == null) {
- return -1;
- } else {
- Date d1 = lhs.getMostRecentItem().getPubDate();
- Date d2 = rhs.getMostRecentItem().getPubDate();
- return d2.compareTo(d1);
- }
+ long dateLhs = recentPubDates.containsKey(lhs.getId()) ? recentPubDates.get(lhs.getId()) : 0;
+ long dateRhs = recentPubDates.containsKey(rhs.getId()) ? recentPubDates.get(rhs.getId()) : 0;
+ return Long.compare(dateRhs, dateLhs);
};
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
index e552cc180..775485880 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
@@ -21,8 +21,10 @@ import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
import java.util.Set;
import de.danoeh.antennapod.core.feed.Chapter;
@@ -1189,6 +1191,25 @@ public class PodDBAdapter {
return conditionalFeedCounterRead(whereRead, feedIds);
}
+ public final Map<Long, Long> getMostRecentItemDates() {
+ final String query = "SELECT " + KEY_FEED + ","
+ + " MAX(" + TABLE_NAME_FEED_ITEMS + "." + KEY_PUBDATE + ") AS most_recent_pubdate"
+ + " FROM " + TABLE_NAME_FEED_ITEMS
+ + " GROUP BY " + KEY_FEED;
+
+ Cursor c = db.rawQuery(query, null);
+ Map<Long, Long> result = new HashMap<>();
+ if (c.moveToFirst()) {
+ do {
+ long feedId = c.getLong(0);
+ long date = c.getLong(1);
+ result.put(feedId, date);
+ } while (c.moveToNext());
+ }
+ c.close();
+ return result;
+ }
+
public final int getNumberOfDownloadedEpisodes() {
final String query = "SELECT COUNT(DISTINCT " + KEY_ID + ") AS count FROM " + TABLE_NAME_FEED_MEDIA +
" WHERE " + KEY_DOWNLOADED + " > 0";
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index 7f3c40e75..15f114c42 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -268,7 +268,8 @@
<string name="confirm_mobile_download_dialog_message">Downloading over mobile data connection is disabled in the settings.\n\nDo you want to allow downloading temporarily?\n\n<small>Your choice will be remembered for 10 minutes.</small></string>
<string name="confirm_mobile_streaming_notification_title">Confirm Mobile streaming</string>
<string name="confirm_mobile_streaming_notification_message">Streaming over mobile data connection is disabled in the settings. Tap to stream anyway.</string>
- <string name="confirm_mobile_streaming_button_always">Always allow</string>
+ <string name="confirm_mobile_streaming_button_always">Always</string>
+ <string name="confirm_mobile_streaming_button_once">Once</string>
<string name="confirm_mobile_download_dialog_only_add_to_queue">Enqueue</string>
<string name="confirm_mobile_download_dialog_enable_temporarily">Allow temporarily</string>