aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-08-22 19:10:26 -0700
committerScott Jackson <daneren2005@gmail.com>2014-08-22 19:10:26 -0700
commit67c94f2bd63c65937386991f7232aa053acc101d (patch)
treeed4ae2bd450f4f9176df655dbe6f244b23ce4c17 /src/github
parentfc7a3df5f7036626b2031d4b5ddf12474f652e8c (diff)
downloaddsub-67c94f2bd63c65937386991f7232aa053acc101d.tar.gz
dsub-67c94f2bd63c65937386991f7232aa053acc101d.tar.bz2
dsub-67c94f2bd63c65937386991f7232aa053acc101d.zip
More work on auto bookmark logic
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java7
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java1
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java16
-rw-r--r--src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java6
4 files changed, 25 insertions, 5 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
index 033f5f3d..3d1f8aab 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
@@ -44,6 +44,7 @@ import java.util.concurrent.TimeUnit;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.PlayerState;
+import github.daneren2005.dsub.domain.ServerInfo;
import github.daneren2005.dsub.fragments.AdminFragment;
import github.daneren2005.dsub.fragments.ChatFragment;
import github.daneren2005.dsub.fragments.DownloadFragment;
@@ -58,6 +59,8 @@ import github.daneren2005.dsub.fragments.SelectShareFragment;
import github.daneren2005.dsub.fragments.SubsonicFragment;
import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.service.DownloadService;
+import github.daneren2005.dsub.service.MusicService;
+import github.daneren2005.dsub.service.MusicServiceFactory;
import github.daneren2005.dsub.updates.Updater;
import github.daneren2005.dsub.util.BackgroundTask;
import github.daneren2005.dsub.util.Constants;
@@ -518,9 +521,11 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
final Context context = this;
new SilentBackgroundTask<Void>(context) {
@Override
- public Void doInBackground() {
+ public Void doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
musicService.getBookmarks(true, context, null);
+
+ return null;
}
@Override
diff --git a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
index 0e22efe4..f9ab0cc9 100644
--- a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
@@ -107,6 +107,7 @@ public class SelectBookmarkFragment extends SelectListFragment<MusicDirectory.En
new SilentBackgroundTask<Void>(context) {
@Override
protected Void doInBackground() throws Throwable {
+ downloadService.clear();
downloadService.download(Arrays.asList(bookmark), false, true, false, false, 0, bookmark.getBookmark().getPosition());
return null;
}
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index 4e22bf75..05503c10 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -1852,13 +1852,21 @@ public class DownloadService extends Service {
}
final MusicDirectory.Entry entry = currentPlaying.getSong();
+ int duration = getPlayerDuration();
- // If song is podcast go ahead and auto add a bookmark
- if(entry instanceof PodcastEpisode) {
- Context context = this;
+ // If song is podcast or long go ahead and auto add a bookmark
+ if(entry instanceof PodcastEpisode || duration > (10L * 60L * 1000L)) {
+ final Context context = this;
+ final int position = getPlayerPosition();
+
+ // Don't bother when at beginning
+ if(position < 5000L) {
+ return;
+ }
+
new SilentBackgroundTask<Void>(context) {
@Override
- public Void doInBackground() {
+ public Void doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
musicService.createBookmark(entry.getId(), Util.getParentFromEntry(context, entry), position, "Auto created by DSub", context, null);
diff --git a/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java b/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java
index 0ccac3a3..afd861f0 100644
--- a/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java
+++ b/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java
@@ -20,6 +20,7 @@ package github.daneren2005.dsub.service.parser;
import android.content.Context;
import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.Bookmark;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.PodcastEpisode;
import github.daneren2005.dsub.util.FileUtil;
@@ -87,6 +88,11 @@ public class PodcastEntryParser extends AbstractParser {
} else if(episode.getPath().indexOf("Podcasts/") == 0) {
episode.setPath(episode.getPath().substring("Podcasts/".length()));
}
+
+ Integer bookmark = getInteger("bookmarkPosition");
+ if(bookmark != null) {
+ episode.setBookmark(new Bookmark(bookmark));
+ }
if(episode.getId() == null) {
episode.setId(String.valueOf(bogusId));