Search in sources :

Example 1 with ArtistInfo

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

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

Example 3 with ArtistInfo

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;
}
Also used : Uri(android.net.Uri) ArtistInfo(com.wm.remusic.info.ArtistInfo) ContentResolver(android.content.ContentResolver)

Example 4 with ArtistInfo

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

Aggregations

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