aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-11-20 12:27:27 -0800
committerScott Jackson <daneren2005@gmail.com>2014-11-20 12:27:27 -0800
commit44ab1332de5c669848dfa78ba095f5d3f2f69c16 (patch)
tree6b290c11493e1173dc26c7cdb4f5e210fe5adfc8 /src/github
parentd3c772678ba680461cbe17e416b98bacd74eb755 (diff)
downloaddsub-44ab1332de5c669848dfa78ba095f5d3f2f69c16.tar.gz
dsub-44ab1332de5c669848dfa78ba095f5d3f2f69c16.tar.bz2
dsub-44ab1332de5c669848dfa78ba095f5d3f2f69c16.zip
Only warn about network if adding undownloaded to queue
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/fragments/NowPlayingFragment.java14
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java4
-rw-r--r--src/github/daneren2005/dsub/fragments/SubsonicFragment.java8
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java19
4 files changed, 31 insertions, 14 deletions
diff --git a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
index b6daea98..ce5b1281 100644
--- a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
+++ b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
@@ -236,7 +236,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
previousButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- warnIfNetworkOrStorageUnavailable();
+ warnIfStorageUnavailable();
new SilentBackgroundTask<Void>(context) {
@Override
protected Void doInBackground() throws Throwable {
@@ -262,7 +262,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
nextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- warnIfNetworkOrStorageUnavailable();
+ warnIfStorageUnavailable();
new SilentBackgroundTask<Boolean>(context) {
@Override
protected Boolean doInBackground() throws Throwable {
@@ -328,7 +328,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
startButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- warnIfNetworkOrStorageUnavailable();
+ warnIfStorageUnavailable();
new SilentBackgroundTask<Void>(context) {
@Override
protected Void doInBackground() throws Throwable {
@@ -507,7 +507,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
playlistView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
- warnIfNetworkOrStorageUnavailable();
+ warnIfStorageUnavailable();
new SilentBackgroundTask<Void>(context) {
@Override
protected Void doInBackground() throws Throwable {
@@ -543,7 +543,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
DownloadService downloadService = getDownloadService();
if (downloadService != null && context.getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, false)) {
context.getIntent().removeExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE);
- warnIfNetworkOrStorageUnavailable();
+ warnIfStorageUnavailable();
downloadService.setShufflePlayEnabled(true);
}
@@ -1077,7 +1077,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
if (state == PAUSED || state == COMPLETED || state == STOPPED) {
service.start();
} else if (state == STOPPED || state == IDLE) {
- warnIfNetworkOrStorageUnavailable();
+ warnIfStorageUnavailable();
int current = service.getCurrentPlayingIndex();
// TODO: Use play() method.
if (current == -1) {
@@ -1495,7 +1495,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
if(action > 0) {
final int performAction = action;
- warnIfNetworkOrStorageUnavailable();
+ warnIfStorageUnavailable();
new SilentBackgroundTask<Void>(context) {
@Override
protected Void doInBackground() throws Throwable {
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index b04f953c..a71924cf 100644
--- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -863,7 +863,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
}
final List<Entry> songs = getSelectedSongs();
- warnIfNetworkOrStorageUnavailable();
+ warnIfStorageUnavailable();
// Conditions for using play now button
if(!append && !save && autoplay && !playNext && !shuffle) {
@@ -922,7 +922,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
return;
}
- warnIfNetworkOrStorageUnavailable();
+ warnIfStorageUnavailable();
LoadingTask<Void> onValid = new LoadingTask<Void>(context) {
@Override
protected Void doInBackground() throws Throwable {
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
index dd4b0348..1856cc6a 100644
--- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -617,11 +617,9 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
R.color.holo_red_light);
}
- protected void warnIfNetworkOrStorageUnavailable() {
+ protected void warnIfStorageUnavailable() {
if (!Util.isExternalStoragePresent()) {
Util.toast(context, R.string.select_album_no_sdcard);
- } else if (!Util.isOffline(context) && !Util.isNetworkConnected(context)) {
- Util.toast(context, R.string.select_album_no_network);
}
}
@@ -934,13 +932,13 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
@Override
protected void done(Boolean result) {
+ warnIfStorageUnavailable();
+
if(playNowOverride) {
playNow(songs);
return;
}
- warnIfNetworkOrStorageUnavailable();
-
if(result) {
Util.startActivityWithoutTransition(context, DownloadActivity.class);
}
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index b75eeeb5..691a32b2 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -307,6 +307,8 @@ public class DownloadService extends Service {
public synchronized void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle, int start, int position) {
setShufflePlayEnabled(false);
int offset = 1;
+ boolean noNetwork = !Util.isOffline(this) && !Util.isNetworkConnected(this);
+ boolean warnNetwork = false;
if (songs.isEmpty()) {
return;
@@ -319,6 +321,11 @@ public class DownloadService extends Service {
if(song != null) {
DownloadFile downloadFile = new DownloadFile(this, song, save);
addToDownloadList(downloadFile, getCurrentPlayingIndex() + offset);
+ if(noNetwork && !warnNetwork) {
+ if(!downloadFile.isCompleteFileAvailable()) {
+ warnNetwork = true;
+ }
+ }
offset++;
}
}
@@ -330,6 +337,11 @@ public class DownloadService extends Service {
for (MusicDirectory.Entry song : songs) {
DownloadFile downloadFile = new DownloadFile(this, song, save);
addToDownloadList(downloadFile, -1);
+ if(noNetwork && !warnNetwork) {
+ if(!downloadFile.isCompleteFileAvailable()) {
+ warnNetwork = true;
+ }
+ }
}
if(!autoplay && (size - 1) == index) {
setNextPlaying();
@@ -341,6 +353,9 @@ public class DownloadService extends Service {
if(shuffle) {
shuffle();
}
+ if(warnNetwork) {
+ Util.toast(this, R.string.select_album_no_network);
+ }
if (autoplay) {
play(start, true, position);
@@ -376,6 +391,10 @@ public class DownloadService extends Service {
}
revision++;
+ if(!Util.isOffline(this) && !Util.isNetworkConnected(this)) {
+ Util.toast(this, R.string.select_album_no_network);
+ }
+
checkDownloads();
lifecycleSupport.serializeDownloadQueue();
}