Search in sources :

Example 6 with MusicDirectory

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;
}
Also used : MusicDirectory(org.moire.ultrasonic.domain.MusicDirectory) File(java.io.File) HashSet(java.util.HashSet)

Example 7 with MusicDirectory

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;
}
Also used : MusicDirectory(org.moire.ultrasonic.domain.MusicDirectory) Random(java.util.Random) File(java.io.File) LinkedList(java.util.LinkedList)

Example 8 with MusicDirectory

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;
}
Also used : MusicDirectory(org.moire.ultrasonic.domain.MusicDirectory) GetAlbumList2Response(org.moire.ultrasonic.api.subsonic.response.GetAlbumList2Response)

Example 9 with MusicDirectory

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;
}
Also used : MusicDirectory(org.moire.ultrasonic.domain.MusicDirectory) VideosResponse(org.moire.ultrasonic.api.subsonic.response.VideosResponse)

Example 10 with 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;
}
Also used : MusicDirectory(org.moire.ultrasonic.domain.MusicDirectory) GetAlbumListResponse(org.moire.ultrasonic.api.subsonic.response.GetAlbumListResponse)

Aggregations

MusicDirectory (org.moire.ultrasonic.domain.MusicDirectory)23 MusicService (org.moire.ultrasonic.service.MusicService)8 LinkedList (java.util.LinkedList)5 File (java.io.File)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Intent (android.content.Intent)2 View (android.view.View)2 AbsListView (android.widget.AbsListView)2 AdapterView (android.widget.AdapterView)2 ImageView (android.widget.ImageView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 PullToRefreshListView (com.handmark.pulltorefresh.library.PullToRefreshListView)2 Collection (java.util.Collection)2 Share (org.moire.ultrasonic.domain.Share)2 AlbumView (org.moire.ultrasonic.view.AlbumView)2 SongView (org.moire.ultrasonic.view.SongView)2 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1