aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src/github/daneren2005
diff options
context:
space:
mode:
Diffstat (limited to 'subsonic-android/src/github/daneren2005')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java62
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java29
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java25
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/MusicService.java10
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java25
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java50
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/view/SongView.java2
7 files changed, 202 insertions, 1 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 4d9ebafd..547eb0f3 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -224,6 +224,12 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
if(!entry.isVideo() && !Util.isOffline(context) && playlistId == null && podcastId != null) {
menu.removeItem(R.id.song_menu_remove_playlist);
}
+ if(podcastId != null) {
+ String status = ((PodcastEpisode)entry).getStatus();
+ if("completed".equals(status)) {
+ menu.removeItem(R.id.song_menu_server_download);
+ }
+ }
}
@Override
@@ -243,6 +249,12 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
case R.id.song_menu_remove_playlist:
removeFromPlaylist(playlistId, playlistName, Arrays.<Integer>asList(info.position - 1));
break;
+ case R.id.song_menu_server_download:
+ downloadPodcastEpisode((PodcastEpisode)selectedItem);
+ break;
+ case R.id.song_menu_server_delete:
+ deletePodcastEpisode((PodcastEpisode)selectedItem);
+ break;
}
return true;
@@ -279,7 +291,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
if("error".equals(status)) {
Util.toast(context, R.string.select_podcasts_error);
return;
- } else if("skipped".equals(status)) {
+ } else if(!"completed".equals(status)) {
Util.toast(context, R.string.select_podcasts_skipped);
return;
}
@@ -633,6 +645,54 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
}
}.execute();
}
+
+ public void downloadPodcastEpisode(final PodcastEpisode episode) {
+ new LoadingTask<Void>(context, true) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ musicService.downloadPodcastEpisode(episode.getEpisodeId(), context, null);
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ Util.toast(context, context.getResources().getString(R.string.select_podcasts_downloading, episode.getTitle()));
+ }
+
+ @Override
+ protected void error(Throwable error) {
+ Util.toast(context, getErrorMessage(error), false);
+ }
+ }.execute();
+ }
+
+ public void deletePodcastEpisode(final PodcastEpisode episode) {
+ Util.confirmDialog(context, R.string.common_delete, episode.getTitle(), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ new LoadingTask<Void>(context, true) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ musicService.deletePodcastEpisode(episode.getEpisodeId(), context, null);
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ entries.remove(episode);
+ entryAdapter.notifyDataSetChanged();
+ }
+
+ @Override
+ protected void error(Throwable error) {
+ Util.toast(context, getErrorMessage(error), false);
+ }
+ }.execute();
+ }
+ });
+ }
private void checkLicenseAndTrialPeriod(Runnable onValid) {
if (licenseValid) {
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
index 3c9ba7c7..dc563135 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
@@ -34,7 +34,9 @@ import github.daneren2005.dsub.service.MusicService;
import github.daneren2005.dsub.service.MusicServiceFactory;
import github.daneren2005.dsub.util.BackgroundTask;
import github.daneren2005.dsub.util.Constants;
+import github.daneren2005.dsub.util.SilentBackgroundTask;
import github.daneren2005.dsub.util.TabBackgroundTask;
+import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.PodcastChannelAdapter;
import java.util.ArrayList;
import java.util.List;
@@ -80,6 +82,12 @@ public class SelectPodcastsFragment extends SubsonicFragment implements AdapterV
if(super.onOptionsItemSelected(item)) {
return true;
}
+
+ switch (item.getItemId()) {
+ case R.id.menu_check:
+ refreshPodcasts();
+ break;
+ }
return false;
}
@@ -130,4 +138,25 @@ public class SelectPodcastsFragment extends SubsonicFragment implements AdapterV
replaceFragment(fragment, R.id.select_podcasts_layout);
}
+
+ public void refreshPodcasts() {
+ new SilentBackgroundTask<Void>(context) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ musicService.refreshPodcasts(context, null);
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ Util.toast(context, R.string.select_podcasts_refreshing);
+ }
+
+ @Override
+ protected void error(Throwable error) {
+ Util.toast(context, getErrorMessage(error), false);
+ }
+ }.execute();
+ }
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
index e06f3372..0074e29b 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -323,6 +323,31 @@ public class CachedMusicService implements MusicService {
}
@Override
+ public void refreshPodcasts(Context context, ProgressListener progressListener) throws Exception {
+ musicService.refreshPodcasts(context, progressListener);
+ }
+
+ @Override
+ public void createPodcastChannel(String url, Context context, ProgressListener progressListener) throws Exception{
+ musicService.createPodcastChannel(url, context, progressListener);
+ }
+
+ @Override
+ public void deletePodcastChannel(String id, Context context, ProgressListener progressListener) throws Exception{
+ musicService.deletePodcastChannel(id, context, progressListener);
+ }
+
+ @Override
+ public void downloadPodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception{
+ musicService.downloadPodcastEpisode(id, context, progressListener);
+ }
+
+ @Override
+ public void deletePodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception{
+ musicService.deletePodcastEpisode(id, context, progressListener);
+ }
+
+ @Override
public int processOfflineSyncs(final Context context, final ProgressListener progressListener) throws Exception{
return musicService.processOfflineSyncs(context, progressListener);
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
index 57deff8f..537ee2c2 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
@@ -124,5 +124,15 @@ public interface MusicService {
MusicDirectory getPodcastEpisodes(String id, Context context, ProgressListener progressListener) throws Exception;
+ void refreshPodcasts(Context context, ProgressListener progressListener) throws Exception;
+
+ void createPodcastChannel(String url, Context context, ProgressListener progressListener) throws Exception;
+
+ void deletePodcastChannel(String id, Context context, ProgressListener progressListener) throws Exception;
+
+ void downloadPodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception;
+
+ void deletePodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception;
+
int processOfflineSyncs(final Context context, final ProgressListener progressListener) throws Exception;
} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
index 395ad6b6..f72f83c4 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
@@ -607,6 +607,31 @@ public class OfflineMusicService extends RESTMusicService {
public MusicDirectory getPodcastEpisodes(String id, Context context, ProgressListener progressListener) throws Exception {
throw new OfflineException("Getting Podcasts not available in offline mode");
}
+
+ @Override
+ public void refreshPodcasts(Context context, ProgressListener progressListener) throws Exception {
+ throw new OfflineException("Getting Podcasts not available in offline mode");
+ }
+
+ @Override
+ public void createPodcastChannel(String url, Context context, ProgressListener progressListener) throws Exception{
+ throw new OfflineException("Getting Podcasts not available in offline mode");
+ }
+
+ @Override
+ public void deletePodcastChannel(String id, Context context, ProgressListener progressListener) throws Exception{
+ throw new OfflineException("Getting Podcasts not available in offline mode");
+ }
+
+ @Override
+ public void downloadPodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception{
+ throw new OfflineException("Getting Podcasts not available in offline mode");
+ }
+
+ @Override
+ public void deletePodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception{
+ throw new OfflineException("Getting Podcasts not available in offline mode");
+ }
@Override
public int processOfflineSyncs(final Context context, final ProgressListener progressListener) throws Exception{
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
index 22e7f8e9..2cd45335 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -907,6 +907,56 @@ public class RESTMusicService implements MusicService {
}
@Override
+ public void refreshPodcasts(Context context, ProgressListener progressListener) throws Exception {
+ Reader reader = getReader(context, progressListener, "refreshPodcasts", null);
+ try {
+ new ErrorParser(context).parse(reader);
+ } finally {
+ Util.close(reader);
+ }
+ }
+
+ @Override
+ public void createPodcastChannel(String url, Context context, ProgressListener progressListener) throws Exception{
+ Reader reader = getReader(context, progressListener, "createPodcastChannel", null, "url", url);
+ try {
+ new ErrorParser(context).parse(reader);
+ } finally {
+ Util.close(reader);
+ }
+ }
+
+ @Override
+ public void deletePodcastChannel(String id, Context context, ProgressListener progressListener) throws Exception{
+ Reader reader = getReader(context, progressListener, "deletePodcastChannel", null, "id", id);
+ try {
+ new ErrorParser(context).parse(reader);
+ } finally {
+ Util.close(reader);
+ }
+ }
+
+ @Override
+ public void downloadPodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception{
+ Reader reader = getReader(context, progressListener, "downloadPodcastEpisode", null, "id", id);
+ try {
+ new ErrorParser(context).parse(reader);
+ } finally {
+ Util.close(reader);
+ }
+ }
+
+ @Override
+ public void deletePodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception{
+ Reader reader = getReader(context, progressListener, "deletePodcastEpisode", null, "id", id);
+ try {
+ new ErrorParser(context).parse(reader);
+ } finally {
+ Util.close(reader);
+ }
+ }
+
+ @Override
public int processOfflineSyncs(final Context context, final ProgressListener progressListener) throws Exception{
return processOfflineScrobbles(context, progressListener) + processOfflineStars(context, progressListener);
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/view/SongView.java b/subsonic-android/src/github/daneren2005/dsub/view/SongView.java
index 130663b5..7c7f5ae6 100644
--- a/subsonic-android/src/github/daneren2005/dsub/view/SongView.java
+++ b/subsonic-android/src/github/daneren2005/dsub/view/SongView.java
@@ -103,6 +103,8 @@ public class SongView extends UpdateView implements Checkable {
artist.append(getContext().getString(R.string.song_details_error));
} else if("skipped".equals(status)) {
artist.append(getContext().getString(R.string.song_details_skipped));
+ } else if("downloading".equals(status)) {
+ artist.append(getContext().getString(R.string.song_details_downloading));
} else {
artist.append(String.format(getContext().getString(R.string.song_details_all), bitRate == null ? "" : bitRate, fileFormat));
}