aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-09-06 09:49:43 -0700
committerScott Jackson <daneren2005@gmail.com>2014-09-06 09:49:43 -0700
commit85cb808de5638f883a781d04bebde5a36c2d624d (patch)
tree448c2b8721114f281fbfe428813827efcda614f7 /src
parent34ed769e6e766e9c6ef9ad6c267f1be998f4a0f5 (diff)
parentc329348ef586424258c87a36d2b06a88ab8e1018 (diff)
downloaddsub-85cb808de5638f883a781d04bebde5a36c2d624d.tar.gz
dsub-85cb808de5638f883a781d04bebde5a36c2d624d.tar.bz2
dsub-85cb808de5638f883a781d04bebde5a36c2d624d.zip
Merge branch 'master' into RepeatedSongs
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/fragments/NowPlayingFragment.java24
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java7
-rw-r--r--src/github/daneren2005/dsub/fragments/SubsonicFragment.java3
-rw-r--r--src/github/daneren2005/dsub/view/AlbumCell.java1
-rw-r--r--src/github/daneren2005/dsub/view/AlbumView.java1
-rw-r--r--src/github/daneren2005/dsub/view/SongView.java7
-rw-r--r--src/github/daneren2005/dsub/view/UpdateView.java16
7 files changed, 47 insertions, 12 deletions
diff --git a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
index b77f02c9..82f82064 100644
--- a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
+++ b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
@@ -31,6 +31,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.MediaRouteButton;
+import android.util.Log;
import android.view.ContextMenu;
import android.view.Display;
import android.view.GestureDetector;
@@ -61,6 +62,8 @@ 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.service.OfflineException;
+import github.daneren2005.dsub.service.ServerTooOldException;
import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.SilentBackgroundTask;
import github.daneren2005.dsub.view.DownloadFileAdapter;
@@ -374,8 +377,12 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
if(downloadService == null) {
return;
}
-
- Entry entry = downloadService.getCurrentPlaying().getSong();
+
+ DownloadFile downloadFile = downloadService.getCurrentPlaying();
+ if(downloadFile == null) {
+ return;
+ }
+ Entry entry = downloadFile.getSong();
// If rating == 1, already set so unset
if(entry.getRating() == 1) {
@@ -406,7 +413,16 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
rateGoodButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- Entry entry = getDownloadService().getCurrentPlaying().getSong();
+ DownloadService downloadService = getDownloadService();
+ if(downloadService == null) {
+ return;
+ }
+
+ DownloadFile downloadFile = downloadService.getCurrentPlaying();
+ if(downloadFile == null) {
+ return;
+ }
+ Entry entry = downloadFile.getSong();
// If rating == 5, already set so unset
if(entry.getRating() == 5) {
@@ -1404,7 +1420,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
currentSong.setBookmark(oldBookmark);
String msg;
- if(error instanceof OfflineException || error instance of ServerTooOldException) {
+ if(error instanceof OfflineException || error instanceof ServerTooOldException) {
msg = getErrorMessage(error);
} else {
msg = context.getResources().getString(R.string.download_save_bookmark_failed) + getErrorMessage(error);
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 9ea84d41..aaaeebfd 100644
--- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -1064,7 +1064,12 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
musicService.setStarred(entries, artists, albums, false, this, context);
for(MusicDirectory.Entry entry: unstar) {
- setEntryStarred(entry, false);
+ new EntryInstanceUpdater(entry) {
+ @Override
+ public void update(MusicDirectory.Entry found) {
+ found.setStarred(false);
+ }
+ }.execute();
}
return null;
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
index 30369bd4..b259987d 100644
--- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -51,6 +51,7 @@ import github.daneren2005.dsub.activity.DownloadActivity;
import github.daneren2005.dsub.activity.SubsonicActivity;
import github.daneren2005.dsub.activity.SubsonicFragmentActivity;
import github.daneren2005.dsub.domain.Artist;
+import github.daneren2005.dsub.domain.Bookmark;
import github.daneren2005.dsub.domain.Genre;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.Playlist;
@@ -1589,7 +1590,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
public void execute() {
DownloadService downloadService = getDownloadService();
if(downloadService != null && !entry.isDirectory()) {
- private boolean serializeChanges = false;
+ boolean serializeChanges = false;
List<DownloadFile> downloadFiles = downloadService.getDownloads();
for(DownloadFile file: downloadFiles) {
Entry check = file.getSong();
diff --git a/src/github/daneren2005/dsub/view/AlbumCell.java b/src/github/daneren2005/dsub/view/AlbumCell.java
index 522834d1..e50aad32 100644
--- a/src/github/daneren2005/dsub/view/AlbumCell.java
+++ b/src/github/daneren2005/dsub/view/AlbumCell.java
@@ -92,5 +92,6 @@ public class AlbumCell extends UpdateView {
exists = file.exists();
isStarred = album.isStarred();
+ isRated = album.getRating();
}
}
diff --git a/src/github/daneren2005/dsub/view/AlbumView.java b/src/github/daneren2005/dsub/view/AlbumView.java
index e28eeadd..c499763f 100644
--- a/src/github/daneren2005/dsub/view/AlbumView.java
+++ b/src/github/daneren2005/dsub/view/AlbumView.java
@@ -92,5 +92,6 @@ public class AlbumView extends UpdateView {
exists = file.exists();
isStarred = album.isStarred();
+ isRated = album.getRating();
}
}
diff --git a/src/github/daneren2005/dsub/view/SongView.java b/src/github/daneren2005/dsub/view/SongView.java
index 5ce3f5ec..3354b58b 100644
--- a/src/github/daneren2005/dsub/view/SongView.java
+++ b/src/github/daneren2005/dsub/view/SongView.java
@@ -67,8 +67,6 @@ public class SongView extends UpdateView implements Checkable {
private boolean loaded = false;
private boolean isBookmarked = false;
private boolean bookmarked = false;
- private int isRated = 0;
- private int rating = 0;
public SongView(Context context) {
super(context);
@@ -267,10 +265,7 @@ public class SongView extends UpdateView implements Checkable {
if(isRated != rating) {
// Color the entire row based on rating
- if(isRated > 3) {
- this.setBackgroundColor(Color.GREEN);
- this.getBackground().setAlpha(5 * (isRated - 3));
- } else if(isRated < 3 && isRated > 0) {
+ if(isRated < 3 && isRated > 0) {
this.setBackgroundColor(Color.RED);
// Use darker colors the lower the rating goes
this.getBackground().setAlpha(10 * (3 - isRated));
diff --git a/src/github/daneren2005/dsub/view/UpdateView.java b/src/github/daneren2005/dsub/view/UpdateView.java
index 5f34a765..87d065b8 100644
--- a/src/github/daneren2005/dsub/view/UpdateView.java
+++ b/src/github/daneren2005/dsub/view/UpdateView.java
@@ -20,6 +20,7 @@ package github.daneren2005.dsub.view;
import android.content.Context;
import android.content.res.TypedArray;
+import android.graphics.Color;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
@@ -56,6 +57,8 @@ public class UpdateView extends LinearLayout {
protected boolean shaded = false;
protected boolean starred = false;
protected boolean isStarred = false;
+ protected int isRated = 0;
+ protected int rating = 0;
protected SilentBackgroundTask<Void> imageTask = null;
protected final boolean autoUpdate;
@@ -259,5 +262,18 @@ public class UpdateView extends LinearLayout {
}
}
}
+
+ if(isRated != rating) {
+ // Color the entire row based on rating
+ if(isRated < 3 && isRated > 0) {
+ this.setBackgroundColor(Color.RED);
+ // Use darker colors the lower the rating goes
+ this.getBackground().setAlpha(10 * (3 - isRated));
+ } else {
+ this.setBackgroundColor(0x00000000);
+ }
+
+ rating = isRated;
+ }
}
}