aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2012-09-28 20:48:11 -0700
committerScott Jackson <daneren2005@gmail.com>2012-09-28 20:48:11 -0700
commit681584458f9aecf230544d6fbec6e3a3f5167cb2 (patch)
tree2d7a6eb2dfcbac21a01bdf5a2869c1bfa21b2257 /subsonic-android
parent5124419a58bd798c5250d46c1084f4c896e07212 (diff)
downloaddsub-681584458f9aecf230544d6fbec6e3a3f5167cb2.tar.gz
dsub-681584458f9aecf230544d6fbec6e3a3f5167cb2.tar.bz2
dsub-681584458f9aecf230544d6fbec6e3a3f5167cb2.zip
Add background download/cache method to rest of app
Diffstat (limited to 'subsonic-android')
-rw-r--r--subsonic-android/res/menu/select_album_context.xml5
-rw-r--r--subsonic-android/res/menu/select_artist_context.xml5
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java11
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java13
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java11
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java15
6 files changed, 40 insertions, 20 deletions
diff --git a/subsonic-android/res/menu/select_album_context.xml b/subsonic-android/res/menu/select_album_context.xml
index a43ef78a..95ff22ca 100644
--- a/subsonic-android/res/menu/select_album_context.xml
+++ b/subsonic-android/res/menu/select_album_context.xml
@@ -17,6 +17,11 @@
/>
<item
+ android:id="@+id/album_menu_download"
+ android:title="@string/common.download"
+ />
+
+ <item
android:id="@+id/album_menu_pin"
android:title="@string/common.pin"
/>
diff --git a/subsonic-android/res/menu/select_artist_context.xml b/subsonic-android/res/menu/select_artist_context.xml
index c1b201f7..17f12162 100644
--- a/subsonic-android/res/menu/select_artist_context.xml
+++ b/subsonic-android/res/menu/select_artist_context.xml
@@ -15,6 +15,11 @@
android:id="@+id/artist_menu_play_last"
android:title="@string/common.play_last"
/>
+
+ <item
+ android:id="@+id/artist_menu_download"
+ android:title="@string/common.download"
+ />
<item
android:id="@+id/artist_menu_pin"
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java
index 4b9d844f..76054280 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java
@@ -219,16 +219,19 @@ public class SearchActivity extends SubsonicTabActivity {
switch (menuItem.getItemId()) {
case R.id.album_menu_play_now:
- downloadRecursively(id, false, false, true, false);
+ downloadRecursively(id, false, false, true, false, false);
break;
case R.id.album_menu_play_shuffled:
- downloadRecursively(id, false, false, true, true);
+ downloadRecursively(id, false, false, true, true, false);
break;
case R.id.album_menu_play_last:
- downloadRecursively(id, false, true, false, false);
+ downloadRecursively(id, false, true, false, false, false);
+ break;
+ case R.id.album_menu_download:
+ downloadRecursively(id, false, true, false, false, true);
break;
case R.id.album_menu_pin:
- downloadRecursively(id, true, true, false, false);
+ downloadRecursively(id, true, true, false, false, true);
break;
case R.id.song_menu_play_now:
onSongSelected(entry, false, false, true, false);
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
index 12653d3d..3d029db3 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
@@ -205,7 +205,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
String id = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ID);
if (hasSubFolders && id != null) {
- downloadRecursively(id, false, false, true, shuffle);
+ downloadRecursively(id, false, false, true, shuffle, false);
} else {
selectAll(true, false);
download(false, false, true, false, shuffle);
@@ -245,16 +245,19 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
songs.add((MusicDirectory.Entry) entryList.getItemAtPosition(info.position));
switch (menuItem.getItemId()) {
case R.id.album_menu_play_now:
- downloadRecursively(entry.getId(), false, false, true, false);
+ downloadRecursively(entry.getId(), false, false, true, false, false);
break;
case R.id.album_menu_play_shuffled:
- downloadRecursively(entry.getId(), false, false, true, true);
+ downloadRecursively(entry.getId(), false, false, true, true, false);
break;
case R.id.album_menu_play_last:
- downloadRecursively(entry.getId(), false, true, false, false);
+ downloadRecursively(entry.getId(), false, true, false, false, false);
+ break;
+ case R.id.album_menu_download:
+ downloadRecursively(entry.getId(), false, true, false, false, true);
break;
case R.id.album_menu_pin:
- downloadRecursively(entry.getId(), true, true, false, false);
+ downloadRecursively(entry.getId(), true, true, false, false, true);
break;
case R.id.song_menu_play_now:
getDownloadService().download(songs, false, true, true, false);
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java
index bee76641..d9c36515 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java
@@ -216,16 +216,19 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter
if (artist != null) {
switch (menuItem.getItemId()) {
case R.id.artist_menu_play_now:
- downloadRecursively(artist.getId(), false, false, true, false);
+ downloadRecursively(artist.getId(), false, false, true, false, false);
break;
case R.id.artist_menu_play_shuffled:
- downloadRecursively(artist.getId(), false, false, true, true);
+ downloadRecursively(artist.getId(), false, false, true, true, false);
break;
case R.id.artist_menu_play_last:
- downloadRecursively(artist.getId(), false, true, false, false);
+ downloadRecursively(artist.getId(), false, true, false, false, false);
+ break;
+ case R.id.artist_menu_download:
+ downloadRecursively(artist.getId(), false, true, false, false, true);
break;
case R.id.artist_menu_pin:
- downloadRecursively(artist.getId(), true, true, false, false);
+ downloadRecursively(artist.getId(), true, true, false, false, true);
break;
default:
return super.onContextItemSelected(menuItem);
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java
index 9b1ab55e..8bbb1342 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java
@@ -27,7 +27,6 @@ import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
-import android.graphics.Typeface;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
@@ -35,17 +34,14 @@ import android.os.Environment;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
-import android.view.Window;
import android.widget.TextView;
import github.daneren2005.dsub.R;
-import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.service.DownloadServiceImpl;
import github.daneren2005.dsub.service.MusicService;
import github.daneren2005.dsub.service.MusicServiceFactory;
-import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.ImageLoader;
import github.daneren2005.dsub.util.ModalBackgroundTask;
import github.daneren2005.dsub.util.Util;
@@ -241,7 +237,7 @@ public class SubsonicTabActivity extends SherlockActivity {
return IMAGE_LOADER;
}
- protected void downloadRecursively(final String id, final boolean save, final boolean append, final boolean autoplay, final boolean shuffle) {
+ protected void downloadRecursively(final String id, final boolean save, final boolean append, final boolean autoplay, final boolean shuffle, final boolean background) {
ModalBackgroundTask<List<MusicDirectory.Entry>> task = new ModalBackgroundTask<List<MusicDirectory.Entry>>(this, false) {
private static final int MAX_SONGS = 500;
@@ -279,8 +275,13 @@ public class SubsonicTabActivity extends SherlockActivity {
downloadService.clear();
}
warnIfNetworkOrStorageUnavailable();
- downloadService.download(songs, save, autoplay, false, shuffle);
- Util.startActivityWithoutTransition(SubsonicTabActivity.this, DownloadActivity.class);
+ if(!background) {
+ downloadService.download(songs, save, autoplay, false, shuffle);
+ Util.startActivityWithoutTransition(SubsonicTabActivity.this, DownloadActivity.class);
+ }
+ else {
+ downloadService.downloadBackground(songs, save);
+ }
}
}
};