use of com.wm.remusic.info.AlbumInfo in project remusic by aa112901.
the class AlbumDetailFragment method onCreateView.
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);
mAdapter = new AlbumDetailAdapter(null);
recyclerView.setAdapter(mAdapter);
itemDecoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST);
recyclerView.addItemDecoration(itemDecoration);
recyclerView.setHasFixedSize(true);
reloadAdapter();
AlbumInfo albumInfo = MusicUtils.getAlbumInfo(mContext, albumID);
Toolbar 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(albumInfo.album_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.AlbumInfo in project remusic by aa112901.
the class MusicUtils method getAlbumInfo.
public static AlbumInfo getAlbumInfo(Context context, long albumId) {
ContentResolver cr = context.getContentResolver();
Cursor cursor = cr.query(Albums.EXTERNAL_CONTENT_URI, proj_album, "_id =" + String.valueOf(albumId), null, null);
if (cursor == null) {
return null;
}
AlbumInfo albumInfo = new AlbumInfo();
while (cursor.moveToNext()) {
albumInfo.album_name = cursor.getString(cursor.getColumnIndex(Albums.ALBUM));
albumInfo.album_art = cursor.getString(cursor.getColumnIndex(Albums.ALBUM_ART));
}
cursor.close();
return albumInfo;
}
use of com.wm.remusic.info.AlbumInfo in project remusic by aa112901.
the class MusicUtils method queryAlbums.
/**
* 获取专辑信息
*
* @param context
* @return
*/
public static List<AlbumInfo> queryAlbums(Context context) {
ContentResolver cr = context.getContentResolver();
StringBuilder where = new StringBuilder(Albums._ID + " in (select distinct " + Media.ALBUM_ID + " from audio_meta where (1=1)");
where.append(" and " + Media.SIZE + " > " + FILTER_SIZE);
where.append(" and " + Media.DURATION + " > " + FILTER_DURATION);
where.append(" )");
// Media.ALBUM_KEY 按专辑名称排序
List<AlbumInfo> list = getAlbumList(cr.query(Albums.EXTERNAL_CONTENT_URI, proj_album, where.toString(), null, PreferencesUtility.getInstance(context).getAlbumSortOrder()));
return list;
}
use of com.wm.remusic.info.AlbumInfo in project remusic by aa112901.
the class MusicUtils method getAlbumList.
public static List<AlbumInfo> getAlbumList(Cursor cursor) {
List<AlbumInfo> list = new ArrayList<>();
while (cursor.moveToNext()) {
AlbumInfo info = new AlbumInfo();
info.album_name = cursor.getString(cursor.getColumnIndex(Albums.ALBUM));
info.album_id = cursor.getInt(cursor.getColumnIndex(Albums._ID));
info.number_of_songs = cursor.getInt(cursor.getColumnIndex(Albums.NUMBER_OF_SONGS));
info.album_art = getAlbumArtUri(info.album_id) + "";
info.album_artist = cursor.getString(cursor.getColumnIndex(Albums.ARTIST));
info.album_sort = Pinyin.toPinyin(info.album_name.charAt(0)).substring(0, 1).toUpperCase();
list.add(info);
}
cursor.close();
return list;
}
Aggregations