summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2014-10-17 20:56:28 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2014-10-17 20:56:28 +0200
commitaa535ac240bc1dfae0db7e85f54747f3cabeb96d (patch)
tree776c17aa4217c9cccc284ba89fb3dbab32cf3c77 /core
parent1995a18a21002a578d2ca22ddcbef8ffe5d3c686 (diff)
downloadAntennaPod-aa535ac240bc1dfae0db7e85f54747f3cabeb96d.zip
Added more callbacks for SP
Diffstat (limited to 'core')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java16
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/PlaybackServiceCallbacks.java7
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java4
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java10
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java19
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java14
7 files changed, 58 insertions, 14 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java b/core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java
index 55b69fdec..286e830c5 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java
@@ -3,6 +3,7 @@ package de.danoeh.antennapod.core;
import android.app.PendingIntent;
import android.content.Context;
+import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.service.download.DownloadRequest;
/**
@@ -37,8 +38,21 @@ public interface DownloadServiceCallbacks {
* <p/>
* The PendingIntent takes users to an activity where they can look at all successful and failed downloads.
*
- * @return A non-null PendingIntent for the notification.
+ * @return A non-null PendingIntent for the notification or null if shouldCreateReport()==false
*/
public PendingIntent getReportNotificationContentIntent(Context context);
+
+ /**
+ * Called by the FeedSyncThread after a feed has been downloaded and parsed.
+ *
+ * @param feed The non-null feed that has been parsed.
+ */
+ public void onFeedParsed(Context context, Feed feed);
+
+ /**
+ * Returns true if the DownloadService should create a report that shows the number of failed
+ * downloads when the service shuts down.
+ * */
+ public boolean shouldCreateReport();
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/PlaybackServiceCallbacks.java b/core/src/main/java/de/danoeh/antennapod/core/PlaybackServiceCallbacks.java
index e37c8fcfd..7aa99dcef 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/PlaybackServiceCallbacks.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/PlaybackServiceCallbacks.java
@@ -18,4 +18,11 @@ public interface PlaybackServiceCallbacks {
* @return A non-null activity intent.
*/
public Intent getPlayerActivityIntent(Context context, MediaType mediaType);
+
+ /**
+ * Returns true if the PlaybackService should load new episodes from the queue when playback ends
+ * and false if the PlaybackService should ignore the queue and load no more episodes when playback
+ * finishes.
+ * */
+ public boolean useQueue();
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java
index 8a513de43..d056917e1 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItem.java
@@ -263,7 +263,9 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
@Override
public Uri getImageUri() {
- if (hasMedia()) {
+ if (hasItemImageDownloaded()) {
+ return image.getImageUri();
+ } else if (hasMedia()) {
return media.getImageUri();
} else if (feed != null) {
return feed.getImageUri();
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java
index 37186ee79..defcfd598 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java
@@ -395,6 +395,8 @@ public class FeedMedia extends FeedFile implements Playable {
builder.appendQueryParameter(PARAM_FALLBACK, feedImgUri.toString());
}
return builder.build();
+ } else if (item.hasItemImageDownloaded()) {
+ return item.getImage().getImageUri();
} else {
return feedImgUri;
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
index 9229622ed..b8db5a387 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
@@ -305,7 +305,10 @@ public class DownloadService extends Service {
if (BuildConfig.DEBUG)
Log.d(TAG, "Service shutting down");
isRunning = false;
- updateReport();
+
+ if (ClientConfig.downloadServiceCallbacks.shouldCreateReport()) {
+ updateReport();
+ }
stopForeground(true);
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
@@ -813,6 +816,9 @@ public class DownloadService extends Service {
}
}
+ ClientConfig.downloadServiceCallbacks.onFeedParsed(DownloadService.this,
+ savedFeed);
+
numberOfDownloads.decrementAndGet();
}
@@ -833,6 +839,8 @@ public class DownloadService extends Service {
}
}
+
+
if (BuildConfig.DEBUG) Log.d(TAG, "Shutting down");
}
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 5123e40c7..bbf0bfb38 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
@@ -521,9 +521,14 @@ public class PlaybackService extends Service {
// is an episode in the queue left.
// Start playback immediately if continuous playback is enabled
Playable nextMedia = null;
- boolean loadNextItem = isInQueue && nextItem != null;
- playNextEpisode = playNextEpisode && loadNextItem
- && UserPreferences.isFollowQueue();
+ boolean loadNextItem = ClientConfig.playbackServiceCallbacks.useQueue() &&
+ isInQueue &&
+ nextItem != null;
+
+ playNextEpisode = playNextEpisode &&
+ loadNextItem &&
+ UserPreferences.isFollowQueue();
+
if (loadNextItem) {
if (BuildConfig.DEBUG)
Log.d(TAG, "Loading next item in queue");
@@ -699,6 +704,10 @@ public class PlaybackService extends Service {
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
+ if (mediaPlayer == null) {
+ return;
+ }
+ PlaybackServiceMediaPlayer.PSMPInfo newInfo = mediaPlayer.getPSMPInfo();
if (!isCancelled() && info.playerStatus == PlayerStatus.PLAYING
&& info.playable != null) {
String contentText = info.playable.getFeedTitle();
@@ -735,7 +744,9 @@ public class PlaybackService extends Service {
.setSmallIcon(R.drawable.ic_stat_antenna);
notification = notificationBuilder.getNotification();
}
- startForeground(NOTIFICATION_ID, notification);
+ if (newInfo.playerStatus == PlayerStatus.PLAYING) {
+ startForeground(NOTIFICATION_ID, notification);
+ }
if (BuildConfig.DEBUG)
Log.d(TAG, "Notification set up");
}
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 1407080dc..6b6e09369 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
@@ -158,7 +158,7 @@ public class PodDBAdapter {
private static final String TABLE_PRIMARY_KEY = KEY_ID
+ " INTEGER PRIMARY KEY AUTOINCREMENT ,";
- private static final String CREATE_TABLE_FEEDS = "CREATE TABLE "
+ public static final String CREATE_TABLE_FEEDS = "CREATE TABLE "
+ TABLE_NAME_FEEDS + " (" + TABLE_PRIMARY_KEY + KEY_TITLE
+ " TEXT," + KEY_FILE_URL + " TEXT," + KEY_DOWNLOAD_URL + " TEXT,"
+ KEY_DOWNLOADED + " INTEGER," + KEY_LINK + " TEXT,"
@@ -170,7 +170,7 @@ public class PodDBAdapter {
+ KEY_USERNAME + " TEXT,"
+ KEY_PASSWORD + " TEXT)";
- private static final String CREATE_TABLE_FEED_ITEMS = "CREATE TABLE "
+ public static final String CREATE_TABLE_FEED_ITEMS = "CREATE TABLE "
+ TABLE_NAME_FEED_ITEMS + " (" + TABLE_PRIMARY_KEY + KEY_TITLE
+ " TEXT," + KEY_CONTENT_ENCODED + " TEXT," + KEY_PUBDATE
+ " INTEGER," + KEY_READ + " INTEGER," + KEY_LINK + " TEXT,"
@@ -180,12 +180,12 @@ public class PodDBAdapter {
+ KEY_FLATTR_STATUS + " INTEGER,"
+ KEY_IMAGE + " INTEGER)";
- private static final String CREATE_TABLE_FEED_IMAGES = "CREATE TABLE "
+ public static final String CREATE_TABLE_FEED_IMAGES = "CREATE TABLE "
+ TABLE_NAME_FEED_IMAGES + " (" + TABLE_PRIMARY_KEY + KEY_TITLE
+ " TEXT," + KEY_FILE_URL + " TEXT," + KEY_DOWNLOAD_URL + " TEXT,"
+ KEY_DOWNLOADED + " INTEGER)";
- private static final String CREATE_TABLE_FEED_MEDIA = "CREATE TABLE "
+ public static final String CREATE_TABLE_FEED_MEDIA = "CREATE TABLE "
+ TABLE_NAME_FEED_MEDIA + " (" + TABLE_PRIMARY_KEY + KEY_DURATION
+ " INTEGER," + KEY_FILE_URL + " TEXT," + KEY_DOWNLOAD_URL
+ " TEXT," + KEY_DOWNLOADED + " INTEGER," + KEY_POSITION
@@ -194,18 +194,18 @@ public class PodDBAdapter {
+ KEY_FEEDITEM + " INTEGER,"
+ KEY_PLAYED_DURATION + " INTEGER)";
- private static final String CREATE_TABLE_DOWNLOAD_LOG = "CREATE TABLE "
+ public static final String CREATE_TABLE_DOWNLOAD_LOG = "CREATE TABLE "
+ TABLE_NAME_DOWNLOAD_LOG + " (" + TABLE_PRIMARY_KEY + KEY_FEEDFILE
+ " INTEGER," + KEY_FEEDFILETYPE + " INTEGER," + KEY_REASON
+ " INTEGER," + KEY_SUCCESSFUL + " INTEGER," + KEY_COMPLETION_DATE
+ " INTEGER," + KEY_REASON_DETAILED + " TEXT,"
+ KEY_DOWNLOADSTATUS_TITLE + " TEXT)";
- private static final String CREATE_TABLE_QUEUE = "CREATE TABLE "
+ public static final String CREATE_TABLE_QUEUE = "CREATE TABLE "
+ TABLE_NAME_QUEUE + "(" + KEY_ID + " INTEGER PRIMARY KEY,"
+ KEY_FEEDITEM + " INTEGER," + KEY_FEED + " INTEGER)";
- private static final String CREATE_TABLE_SIMPLECHAPTERS = "CREATE TABLE "
+ public static final String CREATE_TABLE_SIMPLECHAPTERS = "CREATE TABLE "
+ TABLE_NAME_SIMPLECHAPTERS + " (" + TABLE_PRIMARY_KEY + KEY_TITLE
+ " TEXT," + KEY_START + " INTEGER," + KEY_FEEDITEM + " INTEGER,"
+ KEY_LINK + " TEXT," + KEY_CHAPTER_TYPE + " INTEGER)";