本文整理汇总了Java中android.provider.MediaStore.Audio.Genres类的典型用法代码示例。如果您正苦于以下问题:Java Genres类的具体用法?Java Genres怎么用?Java Genres使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Genres类属于android.provider.MediaStore.Audio包,在下文中一共展示了Genres类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: getSongsWithNoGenre
import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
@NonNull
private static Observable<ArrayList<Song>> getSongsWithNoGenre(@NonNull final Context context) {
String selection = BaseColumns._ID + " NOT IN " +
"(SELECT " + Genres.Members.AUDIO_ID + " FROM audio_genres_map)";
return SongLoader.getSongs(SongLoader.makeSongCursor(context, selection, null));
}
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:7,代码来源:GenreLoader.java
示例17: onCreateLoader
import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
String[] projection = new String[] {
BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
};
StringBuilder where = new StringBuilder();
String sortOrder = Audio.Media.DEFAULT_SORT_ORDER;
where.append(AudioColumns.IS_MUSIC + "=1").append(" AND " + MediaColumns.TITLE + " != ''");
Uri uri = Audio.Media.EXTERNAL_CONTENT_URI;
if (getArguments() != null) {
mPlaylistId = getArguments().getLong(BaseColumns._ID);
String mimeType = getArguments().getString(MIME_TYPE);
if (Audio.Playlists.CONTENT_TYPE.equals(mimeType)) {
where = new StringBuilder();
where.append(AudioColumns.IS_MUSIC + "=1");
where.append(" AND " + MediaColumns.TITLE + " != ''");
switch ((int)mPlaylistId) {
case (int)PLAYLIST_QUEUE:
uri = Audio.Media.EXTERNAL_CONTENT_URI;
long[] mNowPlaying = MusicUtils.getQueue();
if (mNowPlaying.length == 0)
return null;
where = new StringBuilder();
where.append(BaseColumns._ID + " IN (");
if (mNowPlaying == null || mNowPlaying.length <= 0)
return null;
for (long queue_id : mNowPlaying) {
where.append(queue_id + ",");
}
where.deleteCharAt(where.length() - 1);
where.append(")");
break;
case (int)PLAYLIST_FAVORITES:
long favorites_id = MusicUtils.getFavoritesId(getActivity());
projection = new String[] {
Playlists.Members._ID, Playlists.Members.AUDIO_ID,
MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
};
uri = Playlists.Members.getContentUri(EXTERNAL, favorites_id);
sortOrder = Playlists.Members.DEFAULT_SORT_ORDER;
break;
default:
if (id < 0)
return null;
projection = new String[] {
Playlists.Members._ID, Playlists.Members.AUDIO_ID,
MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST,
AudioColumns.DURATION
};
uri = Playlists.Members.getContentUri(EXTERNAL, mPlaylistId);
sortOrder = Playlists.Members.DEFAULT_SORT_ORDER;
break;
}
} else if (Audio.Genres.CONTENT_TYPE.equals(mimeType)) {
long genreId = getArguments().getLong(BaseColumns._ID);
uri = Genres.Members.getContentUri(EXTERNAL, genreId);
projection = new String[] {
BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM,
AudioColumns.ARTIST
};
where = new StringBuilder();
where.append(AudioColumns.IS_MUSIC + "=1").append(
" AND " + MediaColumns.TITLE + " != ''");
sortOrder = Genres.Members.DEFAULT_SORT_ORDER;
} else {
if (Audio.Albums.CONTENT_TYPE.equals(mimeType)) {
long albumId = getArguments().getLong(BaseColumns._ID);
where.append(" AND " + AudioColumns.ALBUM_ID + "=" + albumId);
sortOrder = Audio.Media.TRACK + ", " + sortOrder;
} else if (Audio.Artists.CONTENT_TYPE.equals(mimeType)) {
sortOrder = MediaColumns.TITLE;
long artist_id = getArguments().getLong(BaseColumns._ID);
where.append(" AND " + AudioColumns.ARTIST_ID + "=" + artist_id);
}
}
}
return new CursorLoader(getActivity(), uri, projection, where.toString(), null, sortOrder);
}
开发者ID:liufeiit,项目名称:itmarry,代码行数:80,代码来源:TracksFragment.java
示例18: onLoadFinished
import android.provider.MediaStore.Audio.Genres; //导入依赖的package包/类
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
// Check for database errors
if (data == null) {
return;
}
if (getArguments() != null
&& Playlists.CONTENT_TYPE.equals(getArguments().getString(MIME_TYPE))
&& (getArguments().getLong(BaseColumns._ID) >= 0 || getArguments().getLong(
BaseColumns._ID) == PLAYLIST_FAVORITES)) {
mMediaIdIndex = data.getColumnIndexOrThrow(Playlists.Members.AUDIO_ID);
mTitleIndex = data.getColumnIndexOrThrow(MediaColumns.TITLE);
mAlbumIndex = data.getColumnIndexOrThrow(AudioColumns.ALBUM);
// FIXME
// mArtistIndex =
// data.getColumnIndexOrThrow(Playlists.Members.ARTIST);
} else if (getArguments() != null
&& Genres.CONTENT_TYPE.equals(getArguments().getString(MIME_TYPE))) {
mMediaIdIndex = data.getColumnIndexOrThrow(BaseColumns._ID);
mTitleIndex = data.getColumnIndexOrThrow(MediaColumns.TITLE);
mArtistIndex = data.getColumnIndexOrThrow(AudioColumns.ARTIST);
mAlbumIndex = data.getColumnIndexOrThrow(AudioColumns.ALBUM);
} else if (getArguments() != null
&& Artists.CONTENT_TYPE.equals(getArguments().getString(MIME_TYPE))) {
mTitleIndex = data.getColumnIndexOrThrow(MediaColumns.TITLE);
// mArtistIndex is "line2" of the ListView
mArtistIndex = data.getColumnIndexOrThrow(AudioColumns.ALBUM);
} else if (getArguments() != null
&& Albums.CONTENT_TYPE.equals(getArguments().getString(MIME_TYPE))) {
mMediaIdIndex = data.getColumnIndexOrThrow(BaseColumns._ID);
mTitleIndex = data.getColumnIndexOrThrow(MediaColumns.TITLE);
mArtistIndex = data.getColumnIndexOrThrow(AudioColumns.ARTIST);
} else {
mMediaIdIndex = data.getColumnIndexOrThrow(BaseColumns._ID);
mTitleIndex = data.getColumnIndexOrThrow(MediaColumns.TITLE);
mArtistIndex = data.getColumnIndexOrThrow(AudioColumns.ARTIST);
mAlbumIndex = data.getColumnIndexOrThrow(AudioColumns.ALBUM);
}
mTrackAdapter.changeCursor(data);
mListView.invalidateViews();
mCursor = data;
}
开发者ID:liufeiit,项目名称:itmarry,代码行数:44,代码来源:TracksFragment.java
注:本文中的android.provider.MediaStore.Audio.Genres类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论