当前位置: 首页>>代码示例>>Java>>正文


Java Genres类代码示例

本文整理汇总了Java中android.provider.MediaStore.Audio.Genres的典型用法代码示例。如果您正苦于以下问题:Java Genres类的具体用法?Java Genres怎么用?Java Genres使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Genres类属于android.provider.MediaStore.Audio包,在下文中一共展示了Genres类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeGenreCursor

import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
@Nullable
private static Cursor makeGenreCursor(@NonNull final Context context) {
    final String[] projection = new String[]{
            Genres._ID,
            Genres.NAME
    };
    // Genres that actually have songs
    final String selection = Genres._ID + " IN" +
            " (SELECT " + Genres.Members.GENRE_ID + " FROM audio_genres_map WHERE " + Genres.Members.AUDIO_ID + " IN" +
            " (SELECT " + Genres._ID + " FROM audio_meta WHERE " + SongLoader.BASE_SELECTION + "))";

    try {
        return context.getContentResolver().query(
                Genres.EXTERNAL_CONTENT_URI,
                projection, selection, null, PreferenceUtil.getInstance(context).getGenreSortOrder());
    } catch (SecurityException e) {
        return null;
    }
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:20,代码来源:GenreLoader.java

示例2: setupFragmentData

import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
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; 
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:18,代码来源:GenreListFragment.java

示例3: getGenresFromCursor

import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
@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;
}
 
开发者ID:kabouzeid,项目名称:Phonograph,代码行数:25,代码来源:GenreLoader.java

示例4: getSongListForGenre

import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
/**
 * @param context
 * @param id
 * @return
 */
public static long[] getSongListForGenre(Context context, long id) {
    String[] projection = new String[] {
        BaseColumns._ID
    };
    StringBuilder selection = new StringBuilder();
    selection.append(AudioColumns.IS_MUSIC + "=1");
    selection.append(" AND " + MediaColumns.TITLE + "!=''");
    Uri uri = Genres.Members.getContentUri(EXTERNAL, id);
    Cursor cursor = context.getContentResolver().query(uri, projection, selection.toString(),
            null, null);
    if (cursor != null) {
        long[] list = getSongListForCursor(cursor);
        cursor.close();
        return list;
    }
    return sEmptyList;
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:23,代码来源:MusicUtils.java

示例5: setupFragmentData

import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
public void setupFragmentData(){
    mAdapter = new GenreListAdapter(getActivity(), R.layout.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; 
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:18,代码来源:GenreListFragment.java

示例6: makeAllSongsWithGenreCursor

import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
@Nullable
private static Cursor makeAllSongsWithGenreCursor(@NonNull final Context context) {
    try {
        return context.getContentResolver().query(
                Uri.parse("content://media/external/audio/genres/all/members"),
                new String[]{Genres.Members.AUDIO_ID}, null, null, null);
    } catch (SecurityException e) {
        return null;
    }
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:11,代码来源:GenreLoader.java

示例7: makeGenreSongCursor

import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:11,代码来源:GenreLoader.java

示例8: getGenresFromCursor

import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
@NonNull
private static Observable<ArrayList<Genre>> getGenresFromCursor(@NonNull final Context context, @Nullable final Cursor cursor) {
    return Observable.create(e -> {
        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 e1) {
                            e1.printStackTrace();
                            // nothing we can do then
                        }
                    }
                } while (cursor.moveToNext());
            }
            cursor.close();
        }
        e.onNext(genres);
        e.onComplete();
    });
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:28,代码来源:GenreLoader.java

示例9: initPager

import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:32,代码来源:TracksBrowser.java

示例10: setTitle

import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:38,代码来源:TracksBrowser.java

示例11: makeGenreCursor

import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:kabouzeid,项目名称:Phonograph,代码行数:16,代码来源:GenreLoader.java

示例12: getGenreName

import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
/**
 * @param mContext
 * @param genre_id
 * @param default_name
 * @return genre name
 */
public static String getGenreName(Context mContext, long genre_id, boolean default_name) {
    String where = BaseColumns._ID + "=" + genre_id;
    String[] cols = new String[] {
        GenresColumns.NAME
    };
    Uri uri = Audio.Genres.EXTERNAL_CONTENT_URI;
    Cursor cursor = mContext.getContentResolver().query(uri, cols, where, null, null);
    if (cursor == null){
        return MediaStore.UNKNOWN_STRING;
    }
    if (cursor.getCount() <= 0) {
        if (default_name)
            return mContext.getString(R.string.unknown);
        else
            return MediaStore.UNKNOWN_STRING;
    } else {
        cursor.moveToFirst();
        String name = cursor.getString(0);
        cursor.close();
        if (name == null || MediaStore.UNKNOWN_STRING.equals(name)) {
            if (default_name)
                return mContext.getString(R.string.unknown);
            else
                return MediaStore.UNKNOWN_STRING;
        }
        return name;
    }
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:35,代码来源:MusicUtils.java

示例13: initPager

import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
/**
 * 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.viewpager_margin);
    mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount());
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.setOnPageChangeListener(new PageListener());
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:32,代码来源:TracksBrowser.java

示例14: setTitle

import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
/**
 * Set the correct title
 */
private void setTitle() {
    String name;
    long id;
    if (Audio.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 (Audio.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);
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:38,代码来源:TracksBrowser.java

示例15: initPager

import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
/**
 * 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.viewpager_margin);
    mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount());
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.setOnPageChangeListener(new PageListener());
}
 
开发者ID:C-Aniruddh,项目名称:xPlodMusic,代码行数:32,代码来源:TracksBrowser.java


注:本文中的android.provider.MediaStore.Audio.Genres类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。