aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-01-22 21:52:13 -0800
committerScott Jackson <daneren2005@gmail.com>2014-01-22 21:52:13 -0800
commit0fdfb4a7955b1c212fc9d03cfab22038526d8d5e (patch)
tree8d47c4e5c42d668fb6bda02c9528785cf720795d /src
parent77639dce292246a1a2cb76faad18a709d54d6fc3 (diff)
parent8823b311386d51e840781196b987ffc4af69e578 (diff)
downloaddsub-0fdfb4a7955b1c212fc9d03cfab22038526d8d5e.tar.gz
dsub-0fdfb4a7955b1c212fc9d03cfab22038526d8d5e.tar.bz2
dsub-0fdfb4a7955b1c212fc9d03cfab22038526d8d5e.zip
Merge
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java4
-rw-r--r--src/github/daneren2005/dsub/domain/Genre.java20
-rw-r--r--src/github/daneren2005/dsub/fragments/DownloadFragment.java8
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java3
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceImpl.java10
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java4
-rw-r--r--src/github/daneren2005/dsub/service/parser/GenreParser.java2
-rw-r--r--src/github/daneren2005/dsub/util/Util.java4
-rw-r--r--src/github/daneren2005/dsub/view/GenreView.java30
9 files changed, 59 insertions, 26 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
index 423e1c23..9b1d307a 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
@@ -189,9 +189,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
return null;
}
- if (getDownloadService().getCurrentPlayingIndex() < getDownloadService().size() - 1) {
- getDownloadService().next();
- }
+ getDownloadService().next();
return null;
}
diff --git a/src/github/daneren2005/dsub/domain/Genre.java b/src/github/daneren2005/dsub/domain/Genre.java
index 25d226d7..4ca4c387 100644
--- a/src/github/daneren2005/dsub/domain/Genre.java
+++ b/src/github/daneren2005/dsub/domain/Genre.java
@@ -14,7 +14,9 @@ import github.daneren2005.dsub.util.Util;
public class Genre implements Serializable {
private String name;
private String index;
-
+ private Integer albumCount;
+ private Integer songCount;
+
public String getName() {
return name;
}
@@ -36,6 +38,22 @@ public class Genre implements Serializable {
return name;
}
+ public Integer getAlbumCount() {
+ return albumCount;
+ }
+
+ public void setAlbumCount(Integer albumCount) {
+ this.albumCount = albumCount;
+ }
+
+ public Integer getSongCount() {
+ return songCount;
+ }
+
+ public void setSongCount(Integer songCount) {
+ this.songCount = songCount;
+ }
+
public static class GenreComparator implements Comparator<Genre> {
@Override
public int compare(Genre genre1, Genre genre2) {
diff --git a/src/github/daneren2005/dsub/fragments/DownloadFragment.java b/src/github/daneren2005/dsub/fragments/DownloadFragment.java
index f345334f..ea8e8c3c 100644
--- a/src/github/daneren2005/dsub/fragments/DownloadFragment.java
+++ b/src/github/daneren2005/dsub/fragments/DownloadFragment.java
@@ -1281,11 +1281,9 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
// Right to Left swipe
if (e1.getX() - e2.getX() > swipeDistance && Math.abs(velocityX) > swipeVelocity) {
warnIfNetworkOrStorageUnavailable();
- if (downloadService.getCurrentPlayingIndex() < downloadService.size() - 1) {
- downloadService.next();
- onCurrentChanged();
- onProgressChanged();
- }
+ downloadService.next();
+ onCurrentChanged();
+ onProgressChanged();
return true;
}
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index f88de757..4776295e 100644
--- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -506,6 +506,9 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
result = service.getStarredList(context, this);
} else if(("genres".equals(albumListType) && Util.checkServerVersion(context, "1.10.0")) || "years".equals(albumListType)) {
result = service.getAlbumList(albumListType, albumListExtra, size, 0, context, this);
+ if(result.getChildrenSize() == 0 && "genres".equals(albumListType)) {
+ result = service.getSongsByGenre(albumListExtra, size, 0, context, this);
+ }
} else if("genres".equals(albumListType)) {
result = service.getSongsByGenre(albumListExtra, size, 0, context, this);
} else {
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index 600f2d52..e1ea56ef 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -414,6 +414,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
downloadList.remove(getCurrentPlayingIndex());
downloadList.add(0, currentPlaying);
}
+ currentPlayingIndex = downloadList.indexOf(currentPlaying);
revision++;
lifecycleSupport.serializeDownloadQueue();
updateJukeboxPlaylist();
@@ -557,6 +558,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
@Override
public synchronized void remove(int which) {
downloadList.remove(which);
+ currentPlayingIndex = downloadList.indexOf(currentPlaying);
}
@Override
@@ -570,6 +572,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
setCurrentPlaying(null, false);
}
downloadList.remove(downloadFile);
+ currentPlayingIndex = downloadList.indexOf(currentPlaying);
backgroundDownloadList.remove(downloadFile);
revision++;
lifecycleSupport.serializeDownloadQueue();
@@ -811,9 +814,13 @@ public class DownloadServiceImpl extends Service implements DownloadService {
}
// Restart song if played more than five seconds.
- if (getPlayerPosition() > 5000 || index == 0) {
+ if (getPlayerPosition() > 5000 || (index == 0 && getRepeatMode() != RepeatMode.ALL)) {
play(index);
} else {
+ if(index == 0) {
+ index = size();
+ }
+
play(index - 1);
}
}
@@ -1542,6 +1549,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
revision++;
}
}
+ currentPlayingIndex = downloadList.indexOf(currentPlaying);
if (revisionBefore != revision) {
updateJukeboxPlaylist();
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
index f0b7ceb1..021c214a 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
@@ -323,9 +323,7 @@ public class DownloadServiceLifecycleSupport {
break;
case RemoteControlClient.FLAG_KEY_MEDIA_NEXT:
case KeyEvent.KEYCODE_MEDIA_NEXT:
- if (downloadService.getCurrentPlayingIndex() < downloadService.size() - 1) {
- downloadService.next();
- }
+ downloadService.next();
break;
case RemoteControlClient.FLAG_KEY_MEDIA_STOP:
case KeyEvent.KEYCODE_MEDIA_STOP:
diff --git a/src/github/daneren2005/dsub/service/parser/GenreParser.java b/src/github/daneren2005/dsub/service/parser/GenreParser.java
index f572b564..35913ba9 100644
--- a/src/github/daneren2005/dsub/service/parser/GenreParser.java
+++ b/src/github/daneren2005/dsub/service/parser/GenreParser.java
@@ -97,6 +97,8 @@ public class GenreParser extends AbstractParser {
String name = getElementName();
if ("genre".equals(name)) {
genre = new Genre();
+ genre.setSongCount(getInteger("songCount"));
+ genre.setAlbumCount(getInteger("albumCount"));
} else if ("error".equals(name)) {
handleError();
} else {
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java
index 5dd639c4..28a8c138 100644
--- a/src/github/daneren2005/dsub/util/Util.java
+++ b/src/github/daneren2005/dsub/util/Util.java
@@ -1255,11 +1255,13 @@ public final class Util {
File albumArtFile = FileUtil.getAlbumArtFile(context, song);
intent.putExtra("coverart", albumArtFile.getAbsolutePath());
+ avrcpIntent.putExtra("playing", true);
} else {
intent.putExtra("title", "");
intent.putExtra("artist", "");
intent.putExtra("album", "");
intent.putExtra("coverart", "");
+ avrcpIntent.putExtra("playing", false);
}
addTrackInfo(context, song, avrcpIntent);
@@ -1305,7 +1307,6 @@ public final class Util {
DownloadService downloadService = (DownloadServiceImpl)context;
File albumArtFile = FileUtil.getAlbumArtFile(context, song);
- intent.putExtra("playing", true);
intent.putExtra("track", song.getTitle());
intent.putExtra("artist", song.getArtist());
intent.putExtra("album", song.getAlbum());
@@ -1315,7 +1316,6 @@ public final class Util {
intent.putExtra("position", (long) downloadService.getPlayerPosition());
intent.putExtra("coverart", albumArtFile.getAbsolutePath());
} else {
- intent.putExtra("playing", false);
intent.putExtra("track", "");
intent.putExtra("artist", "");
intent.putExtra("album", "");
diff --git a/src/github/daneren2005/dsub/view/GenreView.java b/src/github/daneren2005/dsub/view/GenreView.java
index 6a8e04ef..cbd5f081 100644
--- a/src/github/daneren2005/dsub/view/GenreView.java
+++ b/src/github/daneren2005/dsub/view/GenreView.java
@@ -21,8 +21,6 @@ package github.daneren2005.dsub.view;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
-import android.widget.ImageButton;
-import android.widget.ImageView;
import android.widget.TextView;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.Genre;
@@ -31,20 +29,30 @@ public class GenreView extends UpdateView {
private static final String TAG = GenreView.class.getSimpleName();
private TextView titleView;
+ private TextView songsView;
+ private TextView albumsView;
public GenreView(Context context) {
super(context);
- LayoutInflater.from(context).inflate(R.layout.basic_list_item, this, true);
-
- titleView = (TextView) findViewById(R.id.item_name);
- starButton = (ImageButton) findViewById(R.id.item_star);
- starButton.setFocusable(false);
- moreButton = (ImageView) findViewById(R.id.item_more);
- moreButton.setVisibility(View.GONE);
- moreButton.setClickable(false);
+ LayoutInflater.from(context).inflate(R.layout.genre_list_item, this, true);
+
+ titleView = (TextView) findViewById(R.id.genre_name);
+ songsView = (TextView) findViewById(R.id.genre_songs);
+ albumsView = (TextView) findViewById(R.id.genre_albums);
}
public void setObjectImpl(Object obj) {
- titleView.setText(((Genre)obj).getName());
+ Genre genre = (Genre) obj;
+ titleView.setText(genre.getName());
+
+ if(genre.getAlbumCount() != null) {
+ songsView.setVisibility(View.VISIBLE);
+ albumsView.setVisibility(View.VISIBLE);
+ songsView.setText(context.getResources().getString(R.string.select_genre_songs, genre.getSongCount()));
+ albumsView.setText(context.getResources().getString(R.string.select_genre_albums, genre.getAlbumCount()));
+ } else {
+ songsView.setVisibility(View.GONE);
+ albumsView.setVisibility(View.GONE);
+ }
}
}