Search in sources :

Example 1 with AlbumInfo

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;
}
Also used : AlbumInfo(com.wm.remusic.info.AlbumInfo) AppCompatActivity(android.support.v7.app.AppCompatActivity) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.wm.remusic.widget.DividerItemDecoration) ImageView(android.widget.ImageView) TintImageView(com.bilibili.magicasakura.widgets.TintImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Toolbar(android.support.v7.widget.Toolbar)

Example 2 with AlbumInfo

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;
}
Also used : AlbumInfo(com.wm.remusic.info.AlbumInfo) Cursor(android.database.Cursor) ContentResolver(android.content.ContentResolver)

Example 3 with 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;
}
Also used : AlbumInfo(com.wm.remusic.info.AlbumInfo) ContentResolver(android.content.ContentResolver)

Example 4 with AlbumInfo

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;
}
Also used : AlbumInfo(com.wm.remusic.info.AlbumInfo) ArrayList(java.util.ArrayList)

Aggregations

AlbumInfo (com.wm.remusic.info.AlbumInfo)4 ContentResolver (android.content.ContentResolver)2 Cursor (android.database.Cursor)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 TintImageView (com.bilibili.magicasakura.widgets.TintImageView)1 DividerItemDecoration (com.wm.remusic.widget.DividerItemDecoration)1 ArrayList (java.util.ArrayList)1