use of com.wm.remusic.info.ArtistInfo in project remusic by aa112901.
the class MusicUtils method getArtistinfo.
public static ArtistInfo getArtistinfo(Context context, long id) {
ContentResolver cr = context.getContentResolver();
Cursor cursor = cr.query(MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, proj_artist, "_id =" + String.valueOf(id), null, null);
if (cursor == null) {
return null;
}
ArtistInfo artistInfo = new ArtistInfo();
while (cursor.moveToNext()) {
artistInfo.artist_name = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Artists.ARTIST));
artistInfo.number_of_tracks = cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Artists.NUMBER_OF_TRACKS));
}
cursor.close();
return artistInfo;
}
use of com.wm.remusic.info.ArtistInfo in project remusic by aa112901.
the class ArtistDetailFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_common, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
artDetailAdapter = new ArtDetailAdapter(null);
recyclerView.setAdapter(artDetailAdapter);
recyclerView.setHasFixedSize(true);
setItemDecoration();
reloadAdapter();
ArtistInfo artistInfo = MusicUtils.getArtistinfo(mContext, artistID);
toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setPadding(0, CommonUtils.getStatusHeight(mContext), 0, 0);
((AppCompatActivity) mContext).setSupportActionBar(toolbar);
ab = ((AppCompatActivity) mContext).getSupportActionBar();
ab.setHomeAsUpIndicator(R.drawable.actionbar_back);
ab.setDisplayHomeAsUpEnabled(true);
ab.setTitle(artistInfo.artist_name);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (getActivity() != null)
getActivity().onBackPressed();
}
});
return view;
}
use of com.wm.remusic.info.ArtistInfo in project remusic by aa112901.
the class MusicUtils method queryArtist.
/**
* 获取歌手信息
*
* @param context
* @return
*/
public static List<ArtistInfo> queryArtist(Context context) {
Uri uri = MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI;
ContentResolver cr = context.getContentResolver();
StringBuilder where = new StringBuilder(MediaStore.Audio.Artists._ID + " in (select distinct " + Media.ARTIST_ID + " from audio_meta where (1=1 )");
where.append(" and " + Media.SIZE + " > " + FILTER_SIZE);
where.append(" and " + Media.DURATION + " > " + FILTER_DURATION);
where.append(")");
List<ArtistInfo> list = getArtistList(cr.query(uri, proj_artist, where.toString(), null, PreferencesUtility.getInstance(context).getArtistSortOrder()));
return list;
}
use of com.wm.remusic.info.ArtistInfo in project remusic by aa112901.
the class MusicUtils method getArtistList.
public static List<ArtistInfo> getArtistList(Cursor cursor) {
List<ArtistInfo> list = new ArrayList<>();
while (cursor.moveToNext()) {
ArtistInfo info = new ArtistInfo();
info.artist_name = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Artists.ARTIST));
info.number_of_tracks = cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Artists.NUMBER_OF_TRACKS));
info.artist_id = cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Artists._ID));
info.artist_sort = Pinyin.toPinyin(info.artist_name.charAt(0)).substring(0, 1).toUpperCase();
list.add(info);
}
cursor.close();
return list;
}
Aggregations