mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-16 11:41:16 +01:00
Fix play all and play now when using ID3 and when offline
This commit is contained in:
parent
fd82b195e1
commit
b44f249cd5
@ -2,8 +2,8 @@
|
||||
<manifest xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
package="com.thejoshwa.ultrasonic.androidapp"
|
||||
a:installLocation="auto"
|
||||
a:versionCode="31"
|
||||
a:versionName="1.2.0.4" >
|
||||
a:versionCode="32"
|
||||
a:versionName="1.2.0.5" >
|
||||
|
||||
<uses-permission a:name="android.permission.INTERNET" />
|
||||
<uses-permission a:name="android.permission.READ_PHONE_STATE" />
|
||||
|
@ -188,7 +188,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
||||
|
||||
String id = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ID);
|
||||
boolean isAlbum = getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_IS_ALBUM, false);
|
||||
|
||||
boolean isArtist = getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_ARTIST, false);
|
||||
String name = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_NAME);
|
||||
String playlistId = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID);
|
||||
String playlistName = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME);
|
||||
@ -268,6 +268,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
||||
|
||||
private void playAll(final boolean shuffle, final boolean append) {
|
||||
boolean hasSubFolders = false;
|
||||
|
||||
for (int i = 0; i < albumListView.getCount(); i++) {
|
||||
MusicDirectory.Entry entry = (MusicDirectory.Entry) albumListView.getItemAtPosition(i);
|
||||
if (entry != null && entry.isDirectory()) {
|
||||
@ -276,9 +277,11 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
||||
}
|
||||
}
|
||||
|
||||
boolean isArtist = getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_ARTIST, false);
|
||||
String id = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ID);
|
||||
|
||||
if (hasSubFolders && id != null) {
|
||||
downloadRecursively(id, false, append, !append, shuffle, false, false, false, false);
|
||||
downloadRecursively(id, false, append, !append, shuffle, false, false, false, isArtist);
|
||||
} else {
|
||||
selectAll(true, false);
|
||||
download(append, false, !append, false, shuffle, getSelectedSongs(albumListView));
|
||||
@ -565,18 +568,21 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
||||
private void selectAllOrNone() {
|
||||
boolean someUnselected = false;
|
||||
int count = albumListView.getCount();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (!albumListView.isItemChecked(i) && albumListView.getItemAtPosition(i) instanceof MusicDirectory.Entry) {
|
||||
someUnselected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
selectAll(someUnselected, true);
|
||||
}
|
||||
|
||||
private void selectAll(boolean selected, boolean toast) {
|
||||
int count = albumListView.getCount();
|
||||
int selectedCount = 0;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
MusicDirectory.Entry entry = (MusicDirectory.Entry) albumListView.getItemAtPosition(i);
|
||||
if (entry != null && !entry.isDirectory() && !entry.isVideo()) {
|
||||
@ -630,7 +636,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
||||
private void downloadBackground(final boolean save) {
|
||||
List<MusicDirectory.Entry> songs = getSelectedSongs(albumListView);
|
||||
|
||||
if(songs.isEmpty()) {
|
||||
if (songs.isEmpty()) {
|
||||
selectAll(true, false);
|
||||
songs = getSelectedSongs(albumListView);
|
||||
}
|
||||
@ -662,10 +668,12 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
||||
|
||||
private void delete() {
|
||||
List<MusicDirectory.Entry> songs = getSelectedSongs(albumListView);
|
||||
if(songs.isEmpty()) {
|
||||
|
||||
if (songs.isEmpty()) {
|
||||
selectAll(true, false);
|
||||
songs = getSelectedSongs(albumListView);
|
||||
}
|
||||
|
||||
if (getDownloadService() != null) {
|
||||
getDownloadService().delete(songs);
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ import com.thejoshwa.ultrasonic.androidapp.service.MusicServiceFactory;
|
||||
import com.thejoshwa.ultrasonic.androidapp.service.OfflineException;
|
||||
import com.thejoshwa.ultrasonic.androidapp.service.ServerTooOldException;
|
||||
import com.thejoshwa.ultrasonic.androidapp.util.Constants;
|
||||
import com.thejoshwa.ultrasonic.androidapp.util.EntryByDiscAndTrackComparator;
|
||||
import com.thejoshwa.ultrasonic.androidapp.util.ImageLoader;
|
||||
import com.thejoshwa.ultrasonic.androidapp.util.ModalBackgroundTask;
|
||||
import com.thejoshwa.ultrasonic.androidapp.util.SilentBackgroundTask;
|
||||
@ -71,6 +72,7 @@ import net.simonvt.menudrawer.Position;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@ -659,11 +661,11 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
|
||||
List<MusicDirectory.Entry> songs = new LinkedList<MusicDirectory.Entry>();
|
||||
MusicDirectory root;
|
||||
|
||||
if (isArtist && Util.getShouldUseId3Tags(SubsonicTabActivity.this)) {
|
||||
if (!Util.isOffline(SubsonicTabActivity.this) && isArtist && Util.getShouldUseId3Tags(SubsonicTabActivity.this)) {
|
||||
getSongsForArtist(id, songs);
|
||||
} else {
|
||||
if (isDirectory) {
|
||||
if (Util.getShouldUseId3Tags(SubsonicTabActivity.this)) {
|
||||
if (!Util.isOffline(SubsonicTabActivity.this) && Util.getShouldUseId3Tags(SubsonicTabActivity.this)) {
|
||||
root = musicService.getAlbum(id, name, false, SubsonicTabActivity.this, this);
|
||||
} else {
|
||||
root = musicService.getMusicDirectory(id, name, false, SubsonicTabActivity.this, this);
|
||||
@ -694,7 +696,7 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
|
||||
for (MusicDirectory.Entry dir : parent.getChildren(true, false)) {
|
||||
MusicDirectory root;
|
||||
|
||||
if (Util.getShouldUseId3Tags(SubsonicTabActivity.this)) {
|
||||
if (!Util.isOffline(SubsonicTabActivity.this) && Util.getShouldUseId3Tags(SubsonicTabActivity.this)) {
|
||||
root = musicService.getAlbum(dir.getId(), dir.getTitle(), false, SubsonicTabActivity.this, this);
|
||||
} else {
|
||||
root = musicService.getMusicDirectory(dir.getId(), dir.getTitle(), false, SubsonicTabActivity.this, this);
|
||||
@ -725,7 +727,11 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
|
||||
|
||||
@Override
|
||||
protected void done(List<MusicDirectory.Entry> songs) {
|
||||
DownloadService downloadService = getDownloadService();
|
||||
if (Util.getShouldSortByDisc(SubsonicTabActivity.this)){
|
||||
Collections.sort(songs, new EntryByDiscAndTrackComparator());
|
||||
}
|
||||
|
||||
DownloadService downloadService = getDownloadService();
|
||||
if (!songs.isEmpty() && downloadService != null) {
|
||||
if (!append && !playNext && !unpin && !background) {
|
||||
downloadService.clear();
|
||||
|
@ -11,9 +11,30 @@ public class EntryByDiscAndTrackComparator implements Comparator<MusicDirectory.
|
||||
Integer discY = y.getDiscNumber();
|
||||
Integer trackX = x.getTrack();
|
||||
Integer trackY = y.getTrack();
|
||||
// String parentX = x.getParent();
|
||||
// String parentY = y.getParent();
|
||||
String albumX = x.getAlbum();
|
||||
String albumY = y.getAlbum();
|
||||
|
||||
int startComparison = compare(discX == null ? 0 : discX, discY == null ? 0 : discY);
|
||||
return startComparison != 0 ? startComparison : compare(trackX == null ? 0 : trackX, trackY == null ? 0 : trackY);
|
||||
// int parentComparison = compare(parentX, parentY);
|
||||
//
|
||||
// if (parentComparison != 0) {
|
||||
// return parentComparison;
|
||||
// }
|
||||
|
||||
int albumComparison = compare(albumX, albumY);
|
||||
|
||||
if (albumComparison != 0) {
|
||||
return albumComparison;
|
||||
}
|
||||
|
||||
int discComparison = compare(discX == null ? 0 : discX, discY == null ? 0 : discY);
|
||||
|
||||
if (discComparison != 0) {
|
||||
return discComparison;
|
||||
}
|
||||
|
||||
return compare(trackX == null ? 0 : trackX, trackY == null ? 0 : trackY);
|
||||
}
|
||||
|
||||
private int compare(long a, long b) {
|
||||
@ -21,4 +42,20 @@ public class EntryByDiscAndTrackComparator implements Comparator<MusicDirectory.
|
||||
: a > b ? 1
|
||||
: 0;
|
||||
}
|
||||
|
||||
private int compare(String a, String b) {
|
||||
if (a == null && b == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (a == null && b != null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (a != null && b == null) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return a.compareTo(b);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user