use of org.moire.ultrasonic.domain.MusicDirectory in project ultrasonic by ultrasonic.
the class OfflineMusicService method getMusicDirectory.
@Override
public MusicDirectory getMusicDirectory(String id, String artistName, boolean refresh, Context context, ProgressListener progressListener) throws Exception {
File dir = new File(id);
MusicDirectory result = new MusicDirectory();
result.setName(dir.getName());
Collection<String> names = new HashSet<String>();
for (File file : FileUtil.listMediaFiles(dir)) {
String name = getName(file);
if (name != null & !names.contains(name)) {
names.add(name);
result.addChild(createEntry(context, file, name));
}
}
return result;
}
use of org.moire.ultrasonic.domain.MusicDirectory in project ultrasonic by ultrasonic.
the class OfflineMusicService method getRandomSongs.
@Override
public MusicDirectory getRandomSongs(int size, Context context, ProgressListener progressListener) throws Exception {
File root = FileUtil.getMusicDirectory(context);
List<File> children = new LinkedList<File>();
listFilesRecursively(root, children);
MusicDirectory result = new MusicDirectory();
if (children.isEmpty()) {
return result;
}
Random random = new java.security.SecureRandom();
for (int i = 0; i < size; i++) {
File file = children.get(random.nextInt(children.size()));
result.addChild(createEntry(context, file, getName(file)));
}
return result;
}
use of org.moire.ultrasonic.domain.MusicDirectory in project ultrasonic by ultrasonic.
the class RESTMusicService method getAlbumList2.
@Override
public MusicDirectory getAlbumList2(String type, int size, int offset, Context context, ProgressListener progressListener) throws Exception {
if (type == null) {
throw new IllegalArgumentException("Type is null!");
}
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetAlbumList2Response> response = subsonicAPIClient.getApi().getAlbumList2(AlbumListType.fromName(type), size, offset, null, null, null, null).execute();
checkResponseSuccessful(response);
MusicDirectory result = new MusicDirectory();
result.addAll(APIAlbumConverter.toDomainEntityList(response.body().getAlbumList()));
return result;
}
use of org.moire.ultrasonic.domain.MusicDirectory in project ultrasonic by ultrasonic.
the class RESTMusicService method getVideos.
@Override
public MusicDirectory getVideos(boolean refresh, Context context, ProgressListener progressListener) throws Exception {
updateProgressListener(progressListener, R.string.parser_reading);
Response<VideosResponse> response = subsonicAPIClient.getApi().getVideos().execute();
checkResponseSuccessful(response);
MusicDirectory musicDirectory = new MusicDirectory();
musicDirectory.addAll(APIMusicDirectoryConverter.toDomainEntityList(response.body().getVideosList()));
return musicDirectory;
}
use of org.moire.ultrasonic.domain.MusicDirectory in project ultrasonic by ultrasonic.
the class RESTMusicService method getAlbumList.
@Override
public MusicDirectory getAlbumList(String type, int size, int offset, Context context, ProgressListener progressListener) throws Exception {
if (type == null) {
throw new IllegalArgumentException("Type is null!");
}
updateProgressListener(progressListener, R.string.parser_reading);
Response<GetAlbumListResponse> response = subsonicAPIClient.getApi().getAlbumList(AlbumListType.fromName(type), size, offset, null, null, null, null).execute();
checkResponseSuccessful(response);
List<MusicDirectory.Entry> childList = APIMusicDirectoryConverter.toDomainEntityList(response.body().getAlbumList());
MusicDirectory result = new MusicDirectory();
result.addAll(childList);
return result;
}
Aggregations