use of org.moire.ultrasonic.domain.MusicDirectory in project ultrasonic by ultrasonic.
the class RESTMusicService method getRandomSongs.
@Override
public MusicDirectory getRandomSongs(int size, Context context, ProgressListener progressListener) throws Exception {
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetRandomSongsResponse> response = subsonicAPIClient.getApi().getRandomSongs(size, null, null, null, null).execute();
checkResponseSuccessful(response);
MusicDirectory result = new MusicDirectory();
result.addAll(APIMusicDirectoryConverter.toDomainEntityList(response.body().getSongsList()));
return result;
}
use of org.moire.ultrasonic.domain.MusicDirectory in project ultrasonic by ultrasonic.
the class SelectAlbumActivity method getAlbumList.
private void getAlbumList(final String albumListType, final int albumListTitle, final int size, final int offset) {
showHeader = false;
setActionBarSubtitle(albumListTitle);
new LoadTask() {
@Override
protected MusicDirectory load(MusicService service) throws Exception {
return Util.getShouldUseId3Tags(SelectAlbumActivity.this) ? service.getAlbumList2(albumListType, size, offset, SelectAlbumActivity.this, this) : service.getAlbumList(albumListType, size, offset, SelectAlbumActivity.this, this);
}
@Override
protected void done(Pair<MusicDirectory, Boolean> result) {
if (!result.getFirst().getChildren().isEmpty()) {
pinButton.setVisibility(View.GONE);
unpinButton.setVisibility(View.GONE);
downloadButton.setVisibility(View.GONE);
deleteButton.setVisibility(View.GONE);
// Hide more button when results are less than album list size
if (result.getFirst().getChildren().size() < getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0)) {
moreButton.setVisibility(View.GONE);
} else {
moreButton.setVisibility(View.VISIBLE);
moreButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(SelectAlbumActivity.this, SelectAlbumActivity.class);
int albumListTitle = getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TITLE, 0);
String type = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE);
int size = getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0);
int offset = getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0) + size;
intent.putExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TITLE, albumListTitle);
intent.putExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE, type);
intent.putExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, size);
intent.putExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, offset);
startActivityForResultWithoutTransition(SelectAlbumActivity.this, intent);
}
});
}
} else {
moreButton.setVisibility(View.GONE);
}
super.done(result);
}
}.execute();
}
use of org.moire.ultrasonic.domain.MusicDirectory in project ultrasonic by ultrasonic.
the class SelectAlbumActivity method getSongsForGenre.
private void getSongsForGenre(final String genre, final int count, final int offset) {
setActionBarSubtitle(genre);
new LoadTask() {
@Override
protected MusicDirectory load(MusicService service) throws Exception {
return service.getSongsByGenre(genre, count, offset, SelectAlbumActivity.this, this);
}
@Override
protected void done(Pair<MusicDirectory, Boolean> result) {
// Hide more button when results are less than album list size
if (result.getFirst().getChildren().size() < getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0)) {
moreButton.setVisibility(View.GONE);
} else {
moreButton.setVisibility(View.VISIBLE);
}
moreButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(SelectAlbumActivity.this, SelectAlbumActivity.class);
String genre = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_GENRE_NAME);
int size = getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0);
int offset = getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0) + size;
intent.putExtra(Constants.INTENT_EXTRA_NAME_GENRE_NAME, genre);
intent.putExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, size);
intent.putExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, offset);
startActivityForResultWithoutTransition(SelectAlbumActivity.this, intent);
}
});
super.done(result);
}
}.execute();
}
use of org.moire.ultrasonic.domain.MusicDirectory in project ultrasonic by ultrasonic.
the class SelectAlbumActivity method getArtist.
private void getArtist(final String id, final String name) {
setActionBarSubtitle(name);
new LoadTask() {
@Override
protected MusicDirectory load(MusicService service) throws Exception {
MusicDirectory root = new MusicDirectory();
boolean refresh = getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_REFRESH, false);
MusicDirectory musicDirectory = service.getArtist(id, name, refresh, SelectAlbumActivity.this, this);
if (Util.getShouldShowAllSongsByArtist(SelectAlbumActivity.this) && musicDirectory.findChild(allSongsId) == null && musicDirectory.getChildren(true, false).size() == musicDirectory.getChildren(true, true).size()) {
MusicDirectory.Entry allSongs = new MusicDirectory.Entry();
allSongs.setDirectory(true);
allSongs.setArtist(name);
allSongs.setParent(id);
allSongs.setId(allSongsId);
allSongs.setTitle(String.format(getResources().getString(R.string.select_album_all_songs), name));
root.addFirst(allSongs);
List<MusicDirectory.Entry> children = musicDirectory.getChildren();
if (children != null) {
root.addAll(children);
}
} else {
root = musicDirectory;
}
return root;
}
}.execute();
}
use of org.moire.ultrasonic.domain.MusicDirectory in project ultrasonic by ultrasonic.
the class SelectAlbumActivity method getAlbum.
private void getAlbum(final String id, final String name, final String parentId) {
setActionBarSubtitle(name);
new LoadTask() {
@Override
protected MusicDirectory load(MusicService service) throws Exception {
MusicDirectory musicDirectory;
boolean refresh = getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_REFRESH, false);
if (allSongsId.equals(id)) {
MusicDirectory root = new MusicDirectory();
Collection<MusicDirectory.Entry> songs = new LinkedList<MusicDirectory.Entry>();
getSongsForArtist(parentId, songs);
for (MusicDirectory.Entry song : songs) {
if (!song.isDirectory()) {
root.addChild(song);
}
}
musicDirectory = root;
} else {
musicDirectory = service.getAlbum(id, name, refresh, SelectAlbumActivity.this, this);
}
return musicDirectory;
}
private void getSongsForArtist(String id, Collection<MusicDirectory.Entry> songs) throws Exception {
MusicService musicService = MusicServiceFactory.getMusicService(SelectAlbumActivity.this);
MusicDirectory artist = musicService.getArtist(id, "", false, SelectAlbumActivity.this, this);
for (MusicDirectory.Entry album : artist.getChildren()) {
if (!allSongsId.equals(album.getId())) {
MusicDirectory albumDirectory = musicService.getAlbum(album.getId(), "", false, SelectAlbumActivity.this, this);
for (MusicDirectory.Entry song : albumDirectory.getChildren()) {
if (!song.isVideo()) {
songs.add(song);
}
}
}
}
}
}.execute();
}
Aggregations