aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2017-04-17 17:14:54 -0700
committerScott Jackson <daneren2005@gmail.com>2017-04-17 17:14:54 -0700
commit31bdaabe0da1bddb30983135cd47a8df312325bb (patch)
tree1ed55ae5711fe1d5f06524ea283e7f5dbf44294b
parentd33ada22e7cab7f31178ccb1b318171603964e29 (diff)
downloaddsub-31bdaabe0da1bddb30983135cd47a8df312325bb.tar.gz
dsub-31bdaabe0da1bddb30983135cd47a8df312325bb.tar.bz2
dsub-31bdaabe0da1bddb30983135cd47a8df312325bb.zip
Fixes #788: Only download playlist immediately if we match sync settings
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
index 28cf9911..5cb413fe 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
@@ -1,5 +1,8 @@
package github.daneren2005.dsub.fragments;
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
import android.support.v7.app.AlertDialog;
import android.content.DialogInterface;
import android.content.res.Resources;
@@ -342,7 +345,24 @@ public class SelectPlaylistFragment extends SelectRecyclerFragment<Playlist> {
private void syncPlaylist(Playlist playlist) {
SyncUtil.addSyncedPlaylist(context, playlist.getId());
- downloadPlaylist(playlist.getId(), playlist.getName(), true, true, false, false, true);
+
+ boolean syncImmediately;
+ if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_SYNC_WIFI, true)) {
+ ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo networkInfo = manager.getActiveNetworkInfo();
+
+ if(networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
+ syncImmediately = true;
+ } else {
+ syncImmediately = false;
+ }
+ } else {
+ syncImmediately = true;
+ }
+
+ if(syncImmediately) {
+ downloadPlaylist(playlist.getId(), playlist.getName(), true, true, false, false, true);
+ }
}
private void stopSyncPlaylist(final Playlist playlist) {