类android.provider.MediaStore.Audio.Genres源码实例Demo

下面列出了怎么用android.provider.MediaStore.Audio.Genres的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Music-Player   文件: GenreLoader.java
@NonNull
private static List<Genre> getGenresFromCursor(@NonNull final Context context, @Nullable final Cursor cursor) {
    final List<Genre> genres = new ArrayList<>();
    if (cursor != null) {
        if (cursor.moveToFirst()) {
            do {
                Genre genre = getGenreFromCursor(context, cursor);
                if (genre.songCount > 0) {
                    genres.add(genre);
                } else {
                    // try to remove the empty genre from the media store
                    try {
                        context.getContentResolver().delete(Genres.EXTERNAL_CONTENT_URI, Genres._ID + " == " + genre.id, null);
                    } catch (Exception e) {
                        e.printStackTrace();
                        // nothing we can do then
                    }
                }
            } while (cursor.moveToNext());
        }
        cursor.close();
    }
    return genres;
}
 
源代码2 项目: MusicPlayer   文件: GenreLoader.java
@NonNull
private static ArrayList<Genre> getGenresFromCursor(@NonNull final Context context, @Nullable final Cursor cursor) {
    final ArrayList<Genre> genres = new ArrayList<>();
    if (cursor != null) {
        if (cursor.moveToFirst()) {
            do {
                Genre genre = getGenreFromCursor(context, cursor);
                if (genre.songCount > 0) {
                    genres.add(genre);
                } else {
                    // try to remove the empty genre from the media store
                    try {
                        context.getContentResolver().delete(Genres.EXTERNAL_CONTENT_URI, Genres._ID + " == " + genre.id, null);
                    } catch (Exception e) {
                        e.printStackTrace();
                        // nothing we can do then
                    }
                }
            } while (cursor.moveToNext());
        }
        cursor.close();
    }
    return genres;
}
 
源代码3 项目: VinylMusicPlayer   文件: GenreLoader.java
@NonNull
private static ArrayList<Genre> getGenresFromCursor(@NonNull final Context context, @Nullable final Cursor cursor) {
    final ArrayList<Genre> genres = new ArrayList<>();
    if (cursor != null) {
        if (cursor.moveToFirst()) {
            do {
                Genre genre = getGenreFromCursor(context, cursor);
                if (genre.songCount > 0) {
                    genres.add(genre);
                } else {
                    // try to remove the empty genre from the media store
                    try {
                        context.getContentResolver().delete(Genres.EXTERNAL_CONTENT_URI, Genres._ID + " == " + genre.id, null);
                    } catch (Exception e) {
                        e.printStackTrace();
                        // nothing we can do then
                    }
                }
            } while (cursor.moveToNext());
        }
        cursor.close();
    }
    return genres;
}
 
源代码4 项目: mobile-manager-tool   文件: GenreListFragment.java
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; 
}
 
源代码5 项目: Phonograph   文件: GenreLoader.java
@NonNull
private static List<Genre> getGenresFromCursor(@NonNull final Context context, @Nullable final Cursor cursor) {
    final List<Genre> genres = new ArrayList<>();
    if (cursor != null) {
        if (cursor.moveToFirst()) {
            do {
                Genre genre = getGenreFromCursor(context, cursor);
                if (genre.songCount > 0) {
                    genres.add(genre);
                } else {
                    // try to remove the empty genre from the media store
                    try {
                        context.getContentResolver().delete(Genres.EXTERNAL_CONTENT_URI, Genres._ID + " == " + genre.id, null);
                    } catch (Exception e) {
                        e.printStackTrace();
                        // nothing we can do then
                    }
                }
            } while (cursor.moveToNext());
        }
        cursor.close();
    }
    return genres;
}
 
源代码6 项目: Music-Player   文件: GenreLoader.java
@Nullable
private static Cursor makeGenreSongCursor(@NonNull final Context context, int genreId) {
    try {
        return context.getContentResolver().query(
                Genres.Members.getContentUri("external", genreId),
                SongLoader.BASE_PROJECTION, SongLoader.BASE_SELECTION, null, PreferenceUtil.getInstance(context).getSongSortOrder());
    } catch (SecurityException e) {
        return null;
    }
}
 
源代码7 项目: Music-Player   文件: GenreLoader.java
@Nullable
private static Cursor makeGenreCursor(@NonNull final Context context) {
    final String[] projection = new String[]{
            Genres._ID,
            Genres.NAME
    };

    try {
        return context.getContentResolver().query(
                Genres.EXTERNAL_CONTENT_URI,
                projection, null, null, PreferenceUtil.getInstance(context).getGenreSortOrder());
    } catch (SecurityException e) {
        return null;
    }
}
 
源代码8 项目: MusicPlayer   文件: GenreLoader.java
@Nullable
private static Cursor makeGenreSongCursor(@NonNull final Context context, int genreId) {
    try {
        return context.getContentResolver().query(
                Genres.Members.getContentUri("external", genreId),
                SongLoader.BASE_PROJECTION, SongLoader.BASE_SELECTION, null, PreferenceUtil.getInstance(context).getSongSortOrder());
    } catch (SecurityException e) {
        return null;
    }
}
 
源代码9 项目: MusicPlayer   文件: GenreLoader.java
@Nullable
private static Cursor makeGenreCursor(@NonNull final Context context) {
    final String[] projection = new String[]{
            Genres._ID,
            Genres.NAME
    };

    try {
        return context.getContentResolver().query(
                Genres.EXTERNAL_CONTENT_URI,
                projection, null, null, PreferenceUtil.getInstance(context).getGenreSortOrder());
    } catch (SecurityException e) {
        return null;
    }
}
 
源代码10 项目: MusicPlayer   文件: GenreLoader.java
public static Cursor getGenreCursorForArtist(final  Context context, long artistId) {
    String query = " _id in (select genre_id from audio_genres_map where audio_id in (select _id from audio_meta where "+SongLoader.BASE_SELECTION+" AND artist_id = "+artistId+"))" ;
    final String[] projection = new String[]{
            Genres._ID,
            Genres.NAME
    };
    try {
        return context.getContentResolver().query(
                Genres.EXTERNAL_CONTENT_URI,
                projection, query, null, SortOrder.GenreSortOrder.GENRE_A_Z/*PreferenceUtil.getInstance(context).getGenreSortOrder()*/);
    } catch (SecurityException e) {
        return null;
    }
}
 
源代码11 项目: VinylMusicPlayer   文件: GenreLoader.java
@Nullable
private static Cursor makeGenreSongCursor(@NonNull final Context context, int genreId) {
    try {
        return context.getContentResolver().query(
                Genres.Members.getContentUri("external", genreId),
                SongLoader.BASE_PROJECTION, SongLoader.BASE_SELECTION, null, PreferenceUtil.getInstance().getSongSortOrder());
    } catch (SecurityException e) {
        return null;
    }
}
 
源代码12 项目: VinylMusicPlayer   文件: GenreLoader.java
@Nullable
private static Cursor makeGenreCursor(@NonNull final Context context) {
    final String[] projection = new String[]{
            Genres._ID,
            Genres.NAME
    };

    try {
        return context.getContentResolver().query(
                Genres.EXTERNAL_CONTENT_URI,
                projection, null, null, PreferenceUtil.getInstance().getGenreSortOrder());
    } catch (SecurityException e) {
        return null;
    }
}
 
源代码13 项目: mobile-manager-tool   文件: TracksBrowser.java
/**
 * Initiate ViewPager and PagerAdapter
 */
private void initPager() {
    // Initiate PagerAdapter
    PagerAdapter mPagerAdapter = new PagerAdapter(getSupportFragmentManager());
    if (ApolloUtils.isArtist(mimeType))
        // Show all albums for an artist
        mPagerAdapter.addFragment(new ArtistAlbumsFragment(bundle));
    // Show the tracks for an artist or album
    if(Playlists.CONTENT_TYPE.equals(mimeType)){
        mPagerAdapter.addFragment(new PlaylistListFragment(bundle));
    }
    else if(Genres.CONTENT_TYPE.equals(mimeType)){
    	mPagerAdapter.addFragment(new GenreListFragment(bundle));
    }
    else if(ApolloUtils.isArtist(mimeType)){
    	mPagerAdapter.addFragment(new ArtistListFragment(bundle));
    }
    else if(Audio.Albums.CONTENT_TYPE.equals(mimeType)){
    	mPagerAdapter.addFragment(new AlbumListFragment(bundle));
    }

    // Set up ViewPager
    mViewPager = (ViewPager)findViewById(R.id.viewPager);
    mViewPager.setPageMargin(getResources().getInteger(R.integer.viewpager_margin_width));
    mViewPager.setPageMarginDrawable(R.drawable.music_viewpager_margin);
    mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount());
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.setOnPageChangeListener(new PageListener());
}
 
源代码14 项目: mobile-manager-tool   文件: TracksBrowser.java
/**
 * Set the correct title
 */
private void setTitle() {
    String name;
    long id;
    if (Playlists.CONTENT_TYPE.equals(mimeType)) {
        id = bundle.getLong(BaseColumns._ID);
        switch ((int)id) {
            case (int)PLAYLIST_QUEUE:
                setTitle(R.string.nowplaying);
                return;
            case (int)PLAYLIST_FAVORITES:
                setTitle(R.string.favorite);
                return;
            default:
                if (id < 0) {
                    setTitle(R.string.app_name);
                    return;
                }
        }
        name = MusicUtils.getPlaylistName(this, id);
    } else if (Audio.Artists.CONTENT_TYPE.equals(mimeType)) {
        id = bundle.getLong(BaseColumns._ID);
        name =  getString (R.string.artist_page_title)+MusicUtils.getArtistName(this, id, true);
    } else if (Audio.Albums.CONTENT_TYPE.equals(mimeType)) {
        id = bundle.getLong(BaseColumns._ID);
        name =  getString (R.string.album_page_title)+MusicUtils.getAlbumName(this, id, true);
    } else if (Genres.CONTENT_TYPE.equals(mimeType)) {
        id = bundle.getLong(BaseColumns._ID);
        name = MusicUtils.parseGenreName(this, MusicUtils.getGenreName(this, id, true));
    } else {
        setTitle(R.string.app_name);
        return;
    }
    setTitle(name);
}
 
源代码15 项目: Phonograph   文件: GenreLoader.java
@Nullable
private static Cursor makeGenreSongCursor(@NonNull final Context context, int genreId) {
    try {
        return context.getContentResolver().query(
                Genres.Members.getContentUri("external", genreId),
                SongLoader.BASE_PROJECTION, SongLoader.BASE_SELECTION, null, PreferenceUtil.getInstance(context).getSongSortOrder());
    } catch (SecurityException e) {
        return null;
    }
}
 
源代码16 项目: Phonograph   文件: GenreLoader.java
@Nullable
private static Cursor makeGenreCursor(@NonNull final Context context) {
    final String[] projection = new String[]{
            Genres._ID,
            Genres.NAME
    };

    try {
        return context.getContentResolver().query(
                Genres.EXTERNAL_CONTENT_URI,
                projection, null, null, PreferenceUtil.getInstance(context).getGenreSortOrder());
    } catch (SecurityException e) {
        return null;
    }
}
 
 类所在包
 类方法
 同包方法