android.provider.MediaStore.Audio.AudioColumns Java Examples

The following examples show how to use android.provider.MediaStore.Audio.AudioColumns. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MusicUtil.java    From LLApp with Apache License 2.0 6 votes vote down vote up
public static List<Playlist> getMp3List(Context context) {
    List<Playlist> list = new ArrayList<Playlist>();

    Cursor cursor = new ResolverSer().getResolverSer().getResover(context).query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, media_info, "",
            null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
    if (cursor != null && cursor.getCount() == 0) {
        final AlertDialog xfdialog = new AlertDialog.Builder(context).setTitle("Tips:").setMessage(context.getResources().getString(R.string.music_no_one)).setPositiveButton(context.getResources().getString(R.string.is_positive), null).create();
        xfdialog.show();
        cursor.close();
        return null;
    }
    while (cursor.moveToNext()) {
        int id = cursor.getInt(cursor.getColumnIndex(BaseColumns._ID));
        int album_id = cursor.getInt(cursor.getColumnIndex(AudioColumns.ALBUM_ID));
        String title = cursor.getString(cursor.getColumnIndex(MediaColumns.TITLE));
        String artist = cursor.getString(cursor.getColumnIndex(AudioColumns.ARTIST));
        int duration = cursor.getInt(cursor.getColumnIndex(AudioColumns.DURATION));
        if (duration > 30000) {
            Playlist playlist = new Playlist(id, title, duration, artist, album_id);
            list.add(playlist);
        }
    }
    cursor.close();
    return list;
}
 
Example #2
Source File: GenreListFragment.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
public void setupFragmentData(){
    mAdapter = new GenreListAdapter(getActivity(), R.layout.music_listview_items, null,
            								new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM,
            AudioColumns.ARTIST
    };
    StringBuilder where = new StringBuilder();
    where.append(AudioColumns.IS_MUSIC + "=1").append(
            				" AND " + MediaColumns.TITLE + " != ''");
    mWhere = where.toString();        
    mSortOrder = Genres.Members.DEFAULT_SORT_ORDER;
    mUri = Genres.Members.getContentUri(EXTERNAL, getArguments().getLong(BaseColumns._ID));
    mFragmentGroupId = 3;
    mType = TYPE_GENRE;
    mTitleColumn = MediaColumns.TITLE; 
}
 
Example #3
Source File: AlbumListFragment.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
@Override
public void setupFragmentData() {
       mAdapter = new AlbumListAdapter(getActivity(), R.layout.music_listview_items, null,
               								new String[] {}, new int[] {}, 0);
   	mProjection = new String[] {
               BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
       };
       StringBuilder where = new StringBuilder();
       where.append(AudioColumns.IS_MUSIC + "=1")
       					.append(" AND " + MediaColumns.TITLE + " != ''");
       long albumId = getArguments().getLong(BaseColumns._ID);
       where.append(" AND " + AudioColumns.ALBUM_ID + "=" + albumId);
       mWhere = where.toString();        
       mSortOrder = Audio.Media.TRACK + ", " + Audio.Media.DEFAULT_SORT_ORDER;
       mUri = Audio.Media.EXTERNAL_CONTENT_URI;
       mFragmentGroupId = 89;
       mType = TYPE_ALBUM;
       mTitleColumn = MediaColumns.TITLE; 
}
 
Example #4
Source File: RecentlyAddedFragment.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
public void setupFragmentData(){
    mAdapter = new RecentlyAddedAdapter(getActivity(), R.layout.music_listview_items,
            null, new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
    };
    StringBuilder where = new StringBuilder();
    int X = MusicUtils.getIntPref(getActivity(), NUMWEEKS, 5) * 3600 * 24 * 7;
    where.append(MediaColumns.TITLE + " != ''");
    where.append(" AND " + AudioColumns.IS_MUSIC + "=1");
    where.append(" AND " + MediaColumns.DATE_ADDED + ">"
            + (System.currentTimeMillis() / 1000 - X));
    mWhere = where.toString();
    mSortOrder = MediaColumns.DATE_ADDED + " DESC";
    mUri = Audio.Media.EXTERNAL_CONTENT_URI;
    mTitleColumn = MediaColumns.TITLE;       
}
 
Example #5
Source File: PlaylistSongLoader.java    From Orin with GNU General Public License v3.0 6 votes vote down vote up
public static Cursor makePlaylistSongCursor(@NonNull final Context context, final int playlistId) {
    try {
        return context.getContentResolver().query(
                MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId),
                new String[]{
                        MediaStore.Audio.Playlists.Members.AUDIO_ID,// 0
                        AudioColumns.TITLE,// 1
                        AudioColumns.TRACK,// 2
                        AudioColumns.YEAR,// 3
                        AudioColumns.DURATION,// 4
                        AudioColumns.DATA,// 5
                        AudioColumns.DATE_MODIFIED,// 6
                        AudioColumns.ALBUM_ID,// 7
                        AudioColumns.ALBUM,// 8
                        AudioColumns.ARTIST_ID,// 9
                        AudioColumns.ARTIST,// 10
                        MediaStore.Audio.Playlists.Members._ID // 11
                }, SongLoader.BASE_SELECTION, null,
                MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER);
    } catch (SecurityException e) {
        return null;
    }
}
 
Example #6
Source File: PlaylistSongLoader.java    From MusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
public static Cursor makePlaylistSongCursor(@NonNull final Context context, final int playlistId) {
    try {
        return context.getContentResolver().query(
                MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId),
                new String[]{
                        MediaStore.Audio.Playlists.Members.AUDIO_ID,// 0
                        AudioColumns.TITLE,// 1
                        AudioColumns.TRACK,// 2
                        AudioColumns.YEAR,// 3
                        AudioColumns.DURATION,// 4
                        AudioColumns.DATA,// 5
                        AudioColumns.DATE_MODIFIED,// 6
                        AudioColumns.ALBUM_ID,// 7
                        AudioColumns.ALBUM,// 8
                        AudioColumns.ARTIST_ID,// 9
                        AudioColumns.ARTIST,// 10
                        MediaStore.Audio.Playlists.Members._ID // 11
                }, SongLoader.BASE_SELECTION, null,
                MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER);
    } catch (Exception e) {
        return null;
    }
}
 
Example #7
Source File: LastAddedLoader.java    From Muzesto with GNU General Public License v3.0 6 votes vote down vote up
public static final Cursor makeLastAddedCursor(final Context context) {
    //four weeks ago
    long fourWeeksAgo = (System.currentTimeMillis() / 1000) - (4 * 3600 * 24 * 7);
    long cutoff = 0L;
    // use the most recent of the two timestamps
    if (cutoff < fourWeeksAgo) {
        cutoff = fourWeeksAgo;
    }

    final StringBuilder selection = new StringBuilder();
    selection.append(AudioColumns.IS_MUSIC + "=1");
    selection.append(" AND " + AudioColumns.TITLE + " != ''");
    selection.append(" AND " + MediaStore.Audio.Media.DATE_ADDED + ">");
    selection.append(cutoff);

    return context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
            new String[]{"_id", "title", "artist", "album", "duration", "track", "artist_id", "album_id"}, selection.toString(), null, MediaStore.Audio.Media.DATE_ADDED + " DESC");
}
 
Example #8
Source File: ArtistListFragment.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
@Override
public void setupFragmentData(){
    mAdapter = new ArtistListAdapter(getActivity(), R.layout.music_listview_items, null,
            								new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
    };
    StringBuilder where = new StringBuilder();
    where.append(AudioColumns.IS_MUSIC + "=1")
    					.append(" AND " + MediaColumns.TITLE + " != ''");
    long artist_id = getArguments().getLong(BaseColumns._ID);
    where.append(" AND " + AudioColumns.ARTIST_ID + "=" + artist_id);
    mWhere = where.toString();        
    mSortOrder = MediaColumns.TITLE;
    mUri = Audio.Media.EXTERNAL_CONTENT_URI;
    mFragmentGroupId = 88;
    mType = TYPE_ARTIST;
    mTitleColumn = MediaColumns.TITLE; 
}
 
Example #9
Source File: PlaylistSongLoader.java    From Muzesto with GNU General Public License v3.0 6 votes vote down vote up
public static final Cursor makePlaylistSongCursor(final Context context, final Long playlistID) {
    final StringBuilder mSelection = new StringBuilder();
    mSelection.append(AudioColumns.IS_MUSIC + "=1");
    mSelection.append(" AND " + AudioColumns.TITLE + " != ''");
    return context.getContentResolver().query(
            MediaStore.Audio.Playlists.Members.getContentUri("external", playlistID),
            new String[]{
                    MediaStore.Audio.Playlists.Members._ID,
                    MediaStore.Audio.Playlists.Members.AUDIO_ID,
                    AudioColumns.TITLE,
                    AudioColumns.ARTIST,
                    AudioColumns.ALBUM_ID,
                    AudioColumns.ARTIST_ID,
                    AudioColumns.ALBUM,
                    AudioColumns.DURATION,
                    AudioColumns.TRACK,
                    Playlists.Members.PLAY_ORDER,
            }, mSelection.toString(), null,
            MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER);
}
 
Example #10
Source File: QuickQueueFragment.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
	String[] projection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST,
    };
    StringBuilder selection = new StringBuilder();
    Uri uri = Audio.Media.EXTERNAL_CONTENT_URI;
    String sortOrder = Audio.Media.DEFAULT_SORT_ORDER;
    uri = Audio.Media.EXTERNAL_CONTENT_URI;
    long[] mNowPlaying = MusicUtils.getQueue();
    if (mNowPlaying.length == 0)
        return null;
    selection = new StringBuilder();
    selection.append(BaseColumns._ID + " IN (");
    if (mNowPlaying == null || mNowPlaying.length <= 0)
        return null;
    for (long queue_id : mNowPlaying) {
        selection.append(queue_id + ",");
    }
    selection.deleteCharAt(selection.length() - 1);
    selection.append(")");
	
    return new AddIdCursorLoader(getActivity(), uri, projection, selection.toString(), null,
            sortOrder);
}
 
Example #11
Source File: PlaylistSongLoader.java    From Phonograph with GNU General Public License v3.0 6 votes vote down vote up
public static Cursor makePlaylistSongCursor(@NonNull final Context context, final int playlistId) {
    try {
        return context.getContentResolver().query(
                MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId),
                new String[]{
                        MediaStore.Audio.Playlists.Members.AUDIO_ID,// 0
                        AudioColumns.TITLE,// 1
                        AudioColumns.TRACK,// 2
                        AudioColumns.YEAR,// 3
                        AudioColumns.DURATION,// 4
                        AudioColumns.DATA,// 5
                        AudioColumns.DATE_MODIFIED,// 6
                        AudioColumns.ALBUM_ID,// 7
                        AudioColumns.ALBUM,// 8
                        AudioColumns.ARTIST_ID,// 9
                        AudioColumns.ARTIST,// 10
                        MediaStore.Audio.Playlists.Members._ID // 11
                }, SongLoader.BASE_SELECTION, null,
                MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER);
    } catch (SecurityException e) {
        return null;
    }
}
 
Example #12
Source File: QuickQueueFragment.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
/**
 * Reload the queue after we remove a track
 */
private void reloadQueueCursor() {
    String[] projection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST,
    };
    StringBuilder selection = new StringBuilder();
    Uri uri = Audio.Media.EXTERNAL_CONTENT_URI;
    String sortOrder = Audio.Media.DEFAULT_SORT_ORDER;
    uri = Audio.Media.EXTERNAL_CONTENT_URI;
    long[] mNowPlaying = MusicUtils.getQueue();
    if (mNowPlaying.length == 0)
        return;
    selection = new StringBuilder();
    selection.append(BaseColumns._ID + " IN (");
    if (mNowPlaying == null || mNowPlaying.length <= 0)
        return;
    for (long queue_id : mNowPlaying) {
        selection.append(queue_id + ",");
    }
    selection.deleteCharAt(selection.length() - 1);
    selection.append(")");

    mCursor = MusicUtils.query(getActivity(), uri, projection, selection.toString(), null,
            sortOrder);
    mQuickQueueAdapter.changeCursor(mCursor);
}
 
Example #13
Source File: PlaylistSongLoader.java    From Music-Player with GNU General Public License v3.0 6 votes vote down vote up
public static Cursor makePlaylistSongCursor(@NonNull final Context context, final int playlistId) {
    try {
        return context.getContentResolver().query(
                MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId),
                new String[]{
                        MediaStore.Audio.Playlists.Members.AUDIO_ID,// 0
                        AudioColumns.TITLE,// 1
                        AudioColumns.TRACK,// 2
                        AudioColumns.YEAR,// 3
                        AudioColumns.DURATION,// 4
                        AudioColumns.DATA,// 5
                        AudioColumns.DATE_MODIFIED,// 6
                        AudioColumns.ALBUM_ID,// 7
                        AudioColumns.ALBUM,// 8
                        AudioColumns.ARTIST_ID,// 9
                        AudioColumns.ARTIST,// 10
                        MediaStore.Audio.Playlists.Members._ID // 11
                }, SongLoader.BASE_SELECTION, null,
                MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER);
    } catch (SecurityException e) {
        return null;
    }
}
 
Example #14
Source File: PlaylistSongsLoader.java    From RetroMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
public static Cursor makePlaylistSongCursor(@NonNull final Context context, final int playlistId) {
    try {
        return context.getContentResolver().query(
                MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId),
                new String[]{
                        MediaStore.Audio.Playlists.Members.AUDIO_ID,// 0
                        AudioColumns.TITLE,// 1
                        AudioColumns.TRACK,// 2
                        AudioColumns.YEAR,// 3
                        AudioColumns.DURATION,// 4
                        AudioColumns.DATA,// 5
                        AudioColumns.DATE_MODIFIED,// 6
                        AudioColumns.ALBUM_ID,// 7
                        AudioColumns.ALBUM,// 8
                        AudioColumns.ARTIST_ID,// 9
                        AudioColumns.ARTIST,// 10
                        MediaStore.Audio.Playlists.Members._ID // 11
                }, SongLoader.BASE_SELECTION, null,
                MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER);
    } catch (SecurityException e) {
        return null;
    }
}
 
Example #15
Source File: ArtistLoader.java    From RetroMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
@NonNull
public static Observable<ArrayList<Artist>> getArtists(@NonNull final Context context, String query) {
    return Observable.create(e -> SongLoader.getSongs(SongLoader.makeSongCursor(
            context,
            AudioColumns.ARTIST + " LIKE ?",
            new String[]{"%" + query + "%"},
            getSongLoaderSortOrder(context))
    ).subscribe(songs -> {
        e.onNext(splitIntoArtists(AlbumLoader.splitIntoAlbums(songs)));
        e.onComplete();
    }));

    /*ArrayList<Song> songs = SongLoader.getSongs(SongLoader.makeSongCursor(
            context,
            AudioColumns.ARTIST + " LIKE ?",
            new String[]{"%" + query + "%"},
            getSongLoaderSortOrder(context))
    );
    return splitIntoArtists(AlbumLoader.splitIntoAlbums(songs));*/
}
 
Example #16
Source File: AlbumLoader.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
public static List<Album> getAlbums(@NonNull final Context context, String query) {
    List<Song> songs = SongLoader.getSongs(SongLoader.makeSongCursor(
            context,
            AudioColumns.ALBUM + " LIKE ?",
            new String[]{"%" + query + "%"},
            getSongLoaderSortOrder(context))
    );
    return splitIntoAlbums(songs);
}
 
Example #17
Source File: ArtistLoader.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
public static Artist getArtist(@NonNull final Context context, int artistId) {
    ArrayList<Song> songs = SongLoader.getSongs(SongLoader.makeSongCursor(
            context,
            AudioColumns.ARTIST_ID + "=?",
            new String[]{String.valueOf(artistId)},
            getSongLoaderSortOrder(context))
    );
    return new Artist(AlbumLoader.splitIntoAlbums(songs));
}
 
Example #18
Source File: ApolloService.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
private void saveBookmarkIfNeeded() {
    try {
        if (isPodcast()) {
            long pos = position();
            long bookmark = getBookmark();
            long duration = duration();
            if ((pos < bookmark && (pos + 10000) > bookmark)
                    || (pos > bookmark && (pos - 10000) < bookmark)) {
                // The existing bookmark is close to the current
                // position, so don't update it.
                return;
            }
            if (pos < 15000 || (pos + 10000) > duration) {
                // if we're near the start or end, clear the bookmark
                pos = 0;
            }

            // write 'pos' to the bookmark field
            ContentValues values = new ContentValues();
            values.put(AudioColumns.BOOKMARK, pos);
            Uri uri = ContentUris.withAppendedId(Audio.Media.EXTERNAL_CONTENT_URI,
                    mCursor.getLong(IDCOLIDX));
            getContentResolver().update(uri, values, null, null);
        }
    } catch (SQLiteException ex) {
    }
}
 
Example #19
Source File: ApolloService.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
public String getArtistName() {
    synchronized (this) {
        if (mCursor == null) {
            return getString(R.string.unknown);
        }
        return mCursor.getString(mCursor.getColumnIndexOrThrow(AudioColumns.ARTIST));
    }
}
 
Example #20
Source File: ArtistLoader.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
public static List<Artist> getArtists(@NonNull final Context context, String query) {
    List<Song> songs = SongLoader.getSongs(SongLoader.makeSongCursor(
            context,
            AudioColumns.ARTIST + " LIKE ?",
            new String[]{"%" + query + "%"},
            getSongLoaderSortOrder(context))
    );
    return splitIntoArtists(AlbumLoader.splitIntoAlbums(songs));
}
 
Example #21
Source File: RecentlyAddedAdapter.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
public void setupViewData( Cursor mCursor ){
	mLineOneText = mCursor.getString(mCursor.getColumnIndexOrThrow(MediaColumns.TITLE));

	mLineTwoText = mCursor.getString(mCursor.getColumnIndexOrThrow(AudioColumns.ARTIST));

    String albumName = mCursor.getString(mCursor.getColumnIndexOrThrow(AudioColumns.ALBUM));
    String albumId = mCursor.getString(mCursor.getColumnIndexOrThrow(AudioColumns.ALBUM_ID));
    mImageData = new String[]{ albumId , mLineTwoText, albumName };
    
    mPlayingId = MusicUtils.getCurrentAudioId();
    mCurrentId = mCursor.getLong(mCursor.getColumnIndexOrThrow(BaseColumns._ID));

    mListType = TYPE_ALBUM;
	showContextEnabled = false;    	
}
 
Example #22
Source File: ApolloService.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
public String getAlbumName() {
    synchronized (this) {
        if (mCursor == null) {
            return getString(R.string.unknown);
        }
        return mCursor.getString(mCursor.getColumnIndexOrThrow(AudioColumns.ALBUM));
    }
}
 
Example #23
Source File: ArtistLoader.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
public static Artist getArtist(@NonNull final Context context, int artistId) {
    List<Song> songs = SongLoader.getSongs(SongLoader.makeSongCursor(
            context,
            AudioColumns.ARTIST_ID + "=?",
            new String[]{String.valueOf(artistId)},
            getSongLoaderSortOrder(context))
    );
    return new Artist(AlbumLoader.splitIntoAlbums(songs));
}
 
Example #24
Source File: SongLoader.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
public static Cursor makeSongCursorFromPaths(@NonNull final Context context, @NonNull ArrayList<String> paths) {
    // Exclude blacklist
    paths.removeAll(BlacklistStore.getInstance(context).getPaths());

    int remaining = paths.size();
    int processed = 0;

    ArrayList<Cursor> cursors = new ArrayList<>();
    final String sortOrder = PreferenceUtil.getInstance().getSongSortOrder();
    while (remaining > 0) {
        final int currentBatch = Math.min(BATCH_SIZE, remaining);

        StringBuilder selection = new StringBuilder();
        selection.append(BASE_SELECTION + " AND " + MediaStore.Audio.AudioColumns.DATA + " IN (?");
        for (int i = 1; i < currentBatch; i++) {
            selection.append(",?");
        }
        selection.append(")");

        try {
            Cursor cursor = context.getContentResolver().query(
                MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                BASE_PROJECTION,
                selection.toString(),
                paths.subList(processed, processed + currentBatch).toArray(new String[currentBatch]),
                sortOrder
            );
            if (cursor != null) {cursors.add(cursor);};
        } catch (SecurityException ignored) {
        }

        remaining -= currentBatch;
        processed += currentBatch;
    }
    if (cursors.isEmpty()) {return null;}
    return new MergeCursor(cursors.toArray(new Cursor[cursors.size()]));
}
 
Example #25
Source File: ArtistLoader.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
public static Artist getArtist(@NonNull final Context context, String artistName) {
    ArrayList<Song> songs = SongLoader.getSongs(SongLoader.makeSongCursor(
            context,
            AudioColumns.ARTIST + "=?",
            new String[]{artistName},
            getSongLoaderSortOrder(context))
    );
    return new Artist(AlbumLoader.splitIntoAlbums(songs));
}
 
Example #26
Source File: MusicService.java    From Muzesto with GNU General Public License v3.0 5 votes vote down vote up
public String getTrackName() {
    synchronized (this) {
        if (mCursor == null) {
            return null;
        }
        return mCursor.getString(mCursor.getColumnIndexOrThrow(AudioColumns.TITLE));
    }
}
 
Example #27
Source File: AlbumLoader.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
public static Observable<Album> getAlbum(@NonNull final Context context, int albumId) {
    return Observable.create(e -> {
        Observable<ArrayList<Song>> songs = SongLoader.getSongs(SongLoader.makeSongCursor(context, AudioColumns.ALBUM_ID + "=?", new String[]{String.valueOf(albumId)}, getSongLoaderSortOrder(context)));
        songs.subscribe(songs1 -> {
            e.onNext(new Album(songs1));
            e.onComplete();
        });
    });
}
 
Example #28
Source File: ArtistListAdapter.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
@Override
public void setupViewData(Cursor mCursor) {
   	mLineOneText = mCursor.getString(mCursor.getColumnIndexOrThrow(MediaColumns.TITLE));    	
   	mLineTwoText = mCursor.getString(mCursor.getColumnIndexOrThrow(AudioColumns.ALBUM));    	
       mImageData = new String[]{ mLineTwoText };        
       mPlayingId = MusicUtils.getCurrentAudioId();
       mCurrentId = mCursor.getLong(mCursor.getColumnIndexOrThrow(BaseColumns._ID));
       mListType = TYPE_ARTIST;
}
 
Example #29
Source File: SongLoader.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
private static String generateBlacklistSelection(String selection, int pathCount) {
    String newSelection = selection != null && !selection.trim().equals("") ? selection + " AND " : "";
    newSelection += AudioColumns.DATA + " NOT LIKE ?";
    for (int i = 0; i < pathCount - 1; i++) {
        newSelection += " AND " + AudioColumns.DATA + " NOT LIKE ?";
    }
    return newSelection;
}
 
Example #30
Source File: ArtistLoader.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
public static List<Artist> getArtists(@NonNull final Context context, String query) {
    List<Song> songs = SongLoader.getSongs(SongLoader.makeSongCursor(
            context,
            AudioColumns.ARTIST + " LIKE ?",
            new String[]{"%" + query + "%"},
            getSongLoaderSortOrder(context))
    );
    return splitIntoArtists(AlbumLoader.splitIntoAlbums(songs));
}