Java 类android.provider.MediaStore.Audio.ArtistColumns 实例源码

项目:KomaMusic    文件:MusicUtils.java   
/**
 * Returns the Id for an artist.
 *
 * @param context The {@link Context} to use.
 * @param name    The name of the artist.
 * @return The ID for an artist.
 */
public static final long getIdForArtist(final Context context, final String name) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, new String[]{
                    BaseColumns._ID
            }, ArtistColumns.ARTIST + "=?", new String[]{
                    name
            }, ArtistColumns.ARTIST);
    int id = -1;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            id = cursor.getInt(0);
        }
        cursor.close();
        cursor = null;
    }
    return id;
}
项目:com.cp.monsterMod    文件:MusicUtils.java   
/**
 * Create a Search Chooser
 */
public static void doSearch(Context mContext, Cursor mCursor, String Type) {
    CharSequence title = null;
    Intent i = new Intent();
    i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    String query = "";

    if ( Type == TYPE_ALBUM ){
        query = mCursor.getString(mCursor.getColumnIndexOrThrow(AlbumColumns.ALBUM));
    }
    else if( Type == TYPE_ARTIST ){
        query = mCursor.getString(mCursor.getColumnIndexOrThrow(ArtistColumns.ARTIST));
    }
    else if( Type == TYPE_GENRE ||  Type == TYPE_PLAYLIST ||  Type == TYPE_SONG ){
        query = mCursor.getString(mCursor.getColumnIndexOrThrow(MediaColumns.TITLE));
    }
    title = "";
    i.putExtra("", query);
    title = title + " " + query;
    title = "Search " + title;
    i.putExtra(SearchManager.QUERY, query);
    mContext.startActivity(Intent.createChooser(i, title));
}
项目:Orpheus    文件:MusicUtils.java   
/**
 * Returns the Id for an artist.
 *
 * @param context The {@link Context} to use.
 * @param name The name of the artist.
 * @return The ID for an artist.
 */
public static long getIdForArtist(final Context context, final String name) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, new String[] {
                BaseColumns._ID
            }, ArtistColumns.ARTIST + "=?", new String[] {
                name
            }, ArtistColumns.ARTIST);
    int id = -1;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            id = cursor.getInt(0);
        }
        cursor.close();
        cursor = null;
    }
    return id;
}
项目:Player-by-TweekProject    文件:MusicUtils.java   
/**
 * Returns the Id for an artist.
 * 
 * @param context The {@link Context} to use.
 * @param name The name of the artist.
 * @return The ID for an artist.
 */
public static final long getIdForArtist(final Context context, final String name) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, new String[] {
                BaseColumns._ID
            }, ArtistColumns.ARTIST + "=?", new String[] {
                name
            }, ArtistColumns.ARTIST);
    int id = -1;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            id = cursor.getInt(0);
        }
        cursor.close();
        cursor = null;
    }
    return id;
}
项目:xPlodMusic    文件:MusicUtils.java   
/**
 * Create a Search Chooser
 */
public static void doSearch(Context mContext, Cursor mCursor, String Type) {
    CharSequence title = null;
    Intent i = new Intent();
    i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    String query = "";

    if ( Type == TYPE_ALBUM ){
        query = mCursor.getString(mCursor.getColumnIndexOrThrow(AlbumColumns.ALBUM));
    }
    else if( Type == TYPE_ARTIST ){
        query = mCursor.getString(mCursor.getColumnIndexOrThrow(ArtistColumns.ARTIST));
    }
    else if( Type == TYPE_GENRE ||  Type == TYPE_PLAYLIST ||  Type == TYPE_SONG ){
        query = mCursor.getString(mCursor.getColumnIndexOrThrow(MediaColumns.TITLE));
    }
    title = "";
    i.putExtra("", query);
    title = title + " " + query;
    title = "Search " + title;
    i.putExtra(SearchManager.QUERY, query);
    mContext.startActivity(Intent.createChooser(i, title));
}
项目:mobile-manager-tool    文件:ApolloUtils.java   
/**
 * @return A custom ContextMenu header
 */
public static  View setHeaderLayout(String Type, Cursor cursor, Activity activity) {
    LayoutInflater inflater = activity.getLayoutInflater();
    View header = inflater.inflate(R.layout.music_context_menu_header, null, false);

    // Artist image
    final ImageView mHanderImage = (ImageView)header.findViewById(R.id.header_image);
    String albumId="",artistName="",albumName="";

    if(Type == TYPE_ALBUM){
        albumName = cursor.getString(cursor.getColumnIndexOrThrow(AlbumColumns.ALBUM));
        artistName = cursor.getString(cursor.getColumnIndexOrThrow(AlbumColumns.ARTIST));
        albumId = cursor.getString(cursor.getColumnIndexOrThrow(BaseColumns._ID));
    }
    else{
        artistName = cursor.getString(cursor.getColumnIndexOrThrow(ArtistColumns.ARTIST));
    }


    ImageInfo mInfo = new ImageInfo();
    mInfo.type = Type;
    mInfo.size = SIZE_THUMB;
    mInfo.source = SRC_FIRST_AVAILABLE;
    mInfo.data = (Type == TYPE_ALBUM ? new String[]{ albumId , artistName, albumName } : new String[]{ artistName});

    ImageProvider.getInstance(activity).loadImage( mHanderImage, mInfo );

    // Set artist name
    TextView headerText = (TextView)header.findViewById(R.id.header_text);
    headerText.setText( (Type == TYPE_ALBUM ? albumName : artistName));
    headerText.setBackgroundColor((activity).getResources().getColor(R.color.transparent_black));
    return header;
}
项目:mobile-manager-tool    文件:TracksBrowser.java   
/**
  * @return number of albums from Bundle
  */
 public String getNumSongs() {
    String[] projection = {
             BaseColumns._ID, ArtistColumns.ARTIST, ArtistColumns.NUMBER_OF_TRACKS
     };
    Uri uri = Audio.Artists.EXTERNAL_CONTENT_URI;
     Long id = ApolloUtils.getArtistId(getArtist(), ARTIST_ID, this);
     Cursor cursor = null;
     try{
        cursor = this.getContentResolver().query(uri, projection, BaseColumns._ID+ "=" + DatabaseUtils.sqlEscapeString(String.valueOf(id)), null, null);
     }
     catch(Exception e){
        e.printStackTrace();
     }
     if(cursor == null)
        return String.valueOf(0);
     int mArtistNumAlbumsIndex = cursor.getColumnIndexOrThrow(ArtistColumns.NUMBER_OF_TRACKS);
     if(cursor.getCount()>0){
    cursor.moveToFirst();
      String numAlbums = cursor.getString(mArtistNumAlbumsIndex);
cursor.close();
      if(numAlbums != null){
        return numAlbums;
      }
     }
     return String.valueOf(0);
 }
项目:mobile-manager-tool    文件:TracksBrowser.java   
/**
  * @return number of albums from Bundle
  */
 public String getNumAlbums() {
     if (bundle.getString(NUMALBUMS) != null)
         return bundle.getString(NUMALBUMS);
     String[] projection = {
             BaseColumns._ID, ArtistColumns.ARTIST, ArtistColumns.NUMBER_OF_ALBUMS
     };
     Uri uri = Audio.Artists.EXTERNAL_CONTENT_URI;
     Long id = ApolloUtils.getArtistId(getArtist(), ARTIST_ID, this);
     Cursor cursor = null;
     try{
        cursor = this.getContentResolver().query(uri, projection, BaseColumns._ID+ "=" + DatabaseUtils.sqlEscapeString(String.valueOf(id)), null, null);
     }
     catch(Exception e){
        e.printStackTrace();
     }
     if(cursor == null)
        return String.valueOf(0);
     int mArtistNumAlbumsIndex = cursor.getColumnIndexOrThrow(ArtistColumns.NUMBER_OF_ALBUMS);
     if(cursor.getCount()>0){
    cursor.moveToFirst();
      String numAlbums = cursor.getString(mArtistNumAlbumsIndex);
cursor.close();
      if(numAlbums != null){
        return numAlbums;
      }
     }
     return String.valueOf(0);
 }
项目:mobile-manager-tool    文件:ArtistsFragment.java   
public void setupFragmentData(){
    mAdapter = new ArtistAdapter(getActivity(), R.layout.music_gridview_items, null,
                                    new String[] {}, new int[] {}, 0); 
    mProjection = new String []{
            BaseColumns._ID, ArtistColumns.ARTIST, ArtistColumns.NUMBER_OF_ALBUMS
    };
    mUri = Audio.Artists.EXTERNAL_CONTENT_URI;
    mSortOrder = Audio.Artists.DEFAULT_SORT_ORDER;
    mFragmentGroupId = 1;
    mType = TYPE_ARTIST;
}
项目:mobile-manager-tool    文件:ArtistAdapter.java   
public void setupViewData(Cursor mCursor){

        mLineOneText = mCursor.getString(mCursor.getColumnIndexOrThrow(ArtistColumns.ARTIST));
        int albums_plural = mCursor.getInt(mCursor.getColumnIndexOrThrow(ArtistColumns.NUMBER_OF_ALBUMS));
        boolean unknown = mLineOneText == null || mLineOneText.equals(MediaStore.UNKNOWN_STRING);
        mLineTwoText = MusicUtils.makeAlbumsLabel(mContext, albums_plural, 0, unknown);        
        mGridType = TYPE_ARTIST;        
        mImageData = new String[]{mLineOneText};
        mPlayingId = MusicUtils.getCurrentArtistId();
        mCurrentId = mCursor.getLong(mCursor.getColumnIndexOrThrow(BaseColumns._ID));

    }
项目:AlarmOn    文件:MediaArtistsView.java   
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  super.onItemClick(parent, view, position, id);
  albumsView.query(Albums.EXTERNAL_CONTENT_URI, ArtistColumns.ARTIST_KEY + " = '" + getLastSelectedName() + "'");
  getFlipper().setInAnimation(getContext(), R.anim.slide_in_left);
  getFlipper().setOutAnimation(getContext(), R.anim.slide_out_left);
  getFlipper().showNext();
}
项目:com.cp.monsterMod    文件:ApolloUtils.java   
/**
 * @return A custom ContextMenu header
 */
public static  View setHeaderLayout(String Type, Cursor cursor, Activity activity) {
    LayoutInflater inflater = activity.getLayoutInflater();
    View header = inflater.inflate(R.layout.context_menu_header, null, false);

    // Artist image
    final ImageView mHanderImage = (ImageView)header.findViewById(R.id.header_image);
    String albumId="",artistName="",albumName="";

    if(Type == TYPE_ALBUM){
        albumName = cursor.getString(cursor.getColumnIndexOrThrow(AlbumColumns.ALBUM));
        artistName = cursor.getString(cursor.getColumnIndexOrThrow(AlbumColumns.ARTIST));
        albumId = cursor.getString(cursor.getColumnIndexOrThrow(BaseColumns._ID));
    }
    else{
        artistName = cursor.getString(cursor.getColumnIndexOrThrow(ArtistColumns.ARTIST));
    }


    ImageInfo mInfo = new ImageInfo();
    mInfo.type = Type;
    mInfo.size = SIZE_THUMB;
    mInfo.source = SRC_FIRST_AVAILABLE;
    mInfo.data = (Type == TYPE_ALBUM ? new String[]{ albumId , artistName, albumName } : new String[]{ artistName});

    ImageProvider.getInstance(activity).loadImage( mHanderImage, mInfo );

    // Set artist name
    TextView headerText = (TextView)header.findViewById(R.id.header_text);
    headerText.setText( (Type == TYPE_ALBUM ? albumName : artistName));
    headerText.setBackgroundColor((activity).getResources().getColor(R.color.transparent_black));
    return header;
}
项目:com.cp.monsterMod    文件:MusicUtils.java   
public static String getArtistName(Context mContext, long artist_id, boolean default_name) {
    String where = BaseColumns._ID + "=" + artist_id;
    String[] cols = new String[] {
        ArtistColumns.ARTIST
    };
    Uri uri = Audio.Artists.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;
    }
}
项目:com.cp.monsterMod    文件:TracksBrowser.java   
/**
  * @return number of albums from Bundle
  */
 public String getNumSongs() {
    String[] projection = {
             BaseColumns._ID, ArtistColumns.ARTIST, ArtistColumns.NUMBER_OF_TRACKS
     };
    Uri uri = Audio.Artists.EXTERNAL_CONTENT_URI;        
     Long id = ApolloUtils.getArtistId(getArtist(), ARTIST_ID, this);
     Cursor cursor = null;
     try{
        cursor = this.getContentResolver().query(uri, projection, BaseColumns._ID+ "=" + DatabaseUtils.sqlEscapeString(String.valueOf(id)), null, null);
     }
     catch(Exception e){
        e.printStackTrace();            
     }
     if(cursor == null)
        return String.valueOf(0);
     int mArtistNumAlbumsIndex = cursor.getColumnIndexOrThrow(ArtistColumns.NUMBER_OF_TRACKS);
     if(cursor.getCount()>0){
    cursor.moveToFirst();
      String numAlbums = cursor.getString(mArtistNumAlbumsIndex);   
cursor.close();
      if(numAlbums != null){
        return numAlbums;
      }
     }        
     return String.valueOf(0);
 }
项目:com.cp.monsterMod    文件:TracksBrowser.java   
/**
  * @return number of albums from Bundle
  */
 public String getNumAlbums() {
     if (bundle.getString(NUMALBUMS) != null)
         return bundle.getString(NUMALBUMS);
     String[] projection = {
             BaseColumns._ID, ArtistColumns.ARTIST, ArtistColumns.NUMBER_OF_ALBUMS
     };
     Uri uri = Audio.Artists.EXTERNAL_CONTENT_URI;        
     Long id = ApolloUtils.getArtistId(getArtist(), ARTIST_ID, this);
     Cursor cursor = null;
     try{
        cursor = this.getContentResolver().query(uri, projection, BaseColumns._ID+ "=" + DatabaseUtils.sqlEscapeString(String.valueOf(id)), null, null);
     }
     catch(Exception e){
        e.printStackTrace();            
     }
     if(cursor == null)
        return String.valueOf(0);
     int mArtistNumAlbumsIndex = cursor.getColumnIndexOrThrow(ArtistColumns.NUMBER_OF_ALBUMS);
     if(cursor.getCount()>0){
    cursor.moveToFirst();
      String numAlbums = cursor.getString(mArtistNumAlbumsIndex);   
cursor.close();
      if(numAlbums != null){
        return numAlbums;
      }
     }        
     return String.valueOf(0);
 }
项目:com.cp.monsterMod    文件:ArtistsFragment.java   
public void setupFragmentData(){
    mAdapter = new ArtistAdapter(getActivity(), R.layout.gridview_items, null, 
                                    new String[] {}, new int[] {}, 0); 
    mProjection = new String []{
            BaseColumns._ID, ArtistColumns.ARTIST, ArtistColumns.NUMBER_OF_ALBUMS
    };
    mUri = Audio.Artists.EXTERNAL_CONTENT_URI;
    mSortOrder = Audio.Artists.DEFAULT_SORT_ORDER;
    mFragmentGroupId = 1;
    mType = TYPE_ARTIST;
}
项目:com.cp.monsterMod    文件:ArtistAdapter.java   
public void setupViewData(Cursor mCursor){

        mLineOneText = mCursor.getString(mCursor.getColumnIndexOrThrow(ArtistColumns.ARTIST));
        int albums_plural = mCursor.getInt(mCursor.getColumnIndexOrThrow(ArtistColumns.NUMBER_OF_ALBUMS));
        boolean unknown = mLineOneText == null || mLineOneText.equals(MediaStore.UNKNOWN_STRING);
        mLineTwoText = MusicUtils.makeAlbumsLabel(mContext, albums_plural, 0, unknown);        
        mGridType = TYPE_ARTIST;        
        mImageData = new String[]{mLineOneText};
        mPlayingId = MusicUtils.getCurrentArtistId();
        mCurrentId = mCursor.getLong(mCursor.getColumnIndexOrThrow(BaseColumns._ID));

    }
项目:itmarry    文件:MusicUtils.java   
public static String getArtistName(Context mContext, long artist_id, boolean default_name) {
    String where = BaseColumns._ID + "=" + artist_id;
    String[] cols = new String[] {
        ArtistColumns.ARTIST
    };
    Uri uri = Audio.Artists.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;
    }
}
项目:itmarry    文件:TracksBrowser.java   
/**
 * @return number of albums from Bundle
 */
public String getNumAlbums() {
    if (bundle.getString(NUMALBUMS) != null)
        return bundle.getString(NUMALBUMS);
    String[] projection = {
            BaseColumns._ID, ArtistColumns.ARTIST, ArtistColumns.NUMBER_OF_ALBUMS
    };
    Uri uri = Audio.Artists.EXTERNAL_CONTENT_URI;        
    Long id = ApolloUtils.getArtistId(getArtist(), ARTIST_ID, this);
    Cursor cursor = null;
    try{
        cursor = this.getContentResolver().query(uri, projection, BaseColumns._ID+ "=" + DatabaseUtils.sqlEscapeString(String.valueOf(id)), null, null);
    }
    catch(Exception e){
        e.printStackTrace();            
    }
    if(cursor == null)
        return String.valueOf(0);
    int mArtistNumAlbumsIndex = cursor.getColumnIndexOrThrow(ArtistColumns.NUMBER_OF_ALBUMS);
    if(cursor.getCount()>0){
    cursor.moveToFirst();
     String numAlbums = cursor.getString(mArtistNumAlbumsIndex);      
     if(numAlbums != null){
        return numAlbums;
     }
    }        
    return String.valueOf(0);
}
项目:itmarry    文件:ArtistsFragment.java   
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String[] projection = {
            BaseColumns._ID, ArtistColumns.ARTIST, ArtistColumns.NUMBER_OF_ALBUMS
    };
    Uri uri = Audio.Artists.EXTERNAL_CONTENT_URI;
    String sortOrder = Audio.Artists.DEFAULT_SORT_ORDER;
    return new CursorLoader(getActivity(), uri, projection, null, null, sortOrder);
}
项目:itmarry    文件:ArtistsFragment.java   
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    // Check for database errors
    if (data == null) {
        return;
    }

    mArtistIdIndex = data.getColumnIndexOrThrow(BaseColumns._ID);
    mArtistNameIndex = data.getColumnIndexOrThrow(ArtistColumns.ARTIST);
    mArtistNumAlbumsIndex = data.getColumnIndexOrThrow(ArtistColumns.NUMBER_OF_ALBUMS);
    mArtistAdapter.changeCursor(data);
    mCursor = data;
}
项目:Player-by-TweekProject    文件:ArtistLoader.java   
/**
 * Creates the {@link Cursor} used to run the query.
 * 
 * @param context The {@link Context} to use.
 * @return The {@link Cursor} used to run the artist query.
 */
public static final Cursor makeArtistCursor(final Context context) {
    return context.getContentResolver().query(MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI,
            new String[] {
                    /* 0 */
                    BaseColumns._ID,
                    /* 1 */
                    ArtistColumns.ARTIST,
                    /* 2 */
                    ArtistColumns.NUMBER_OF_ALBUMS,
                    /* 3 */
                    ArtistColumns.NUMBER_OF_TRACKS
            }, null, null, PreferenceUtils.getInstace(context).getArtistSortOrder());
}
项目:xPlodMusic    文件:ApolloUtils.java   
/**
 * @return A custom ContextMenu header
 */
public static  View setHeaderLayout(String Type, Cursor cursor, Activity activity) {
    LayoutInflater inflater = activity.getLayoutInflater();
    View header = inflater.inflate(R.layout.context_menu_header, null, false);

    // Artist image
    final ImageView mHanderImage = (ImageView)header.findViewById(R.id.header_image);
    String albumId="",artistName="",albumName="";

    if(Type == TYPE_ALBUM){
        albumName = cursor.getString(cursor.getColumnIndexOrThrow(AlbumColumns.ALBUM));
        artistName = cursor.getString(cursor.getColumnIndexOrThrow(AlbumColumns.ARTIST));
        albumId = cursor.getString(cursor.getColumnIndexOrThrow(BaseColumns._ID));
    }
    else{
        artistName = cursor.getString(cursor.getColumnIndexOrThrow(ArtistColumns.ARTIST));
    }


    ImageInfo mInfo = new ImageInfo();
    mInfo.type = Type;
    mInfo.size = SIZE_THUMB;
    mInfo.source = SRC_FIRST_AVAILABLE;
    mInfo.data = (Type == TYPE_ALBUM ? new String[]{ albumId , artistName, albumName } : new String[]{ artistName});

    ImageProvider.getInstance(activity).loadImage( mHanderImage, mInfo );

    // Set artist name
    TextView headerText = (TextView)header.findViewById(R.id.header_text);
    headerText.setText( (Type == TYPE_ALBUM ? albumName : artistName));
    headerText.setBackgroundColor((activity).getResources().getColor(R.color.transparent_black));
    return header;
}
项目:xPlodMusic    文件:MusicUtils.java   
public static String getArtistName(Context mContext, long artist_id, boolean default_name) {
    String where = BaseColumns._ID + "=" + artist_id;
    String[] cols = new String[] {
        ArtistColumns.ARTIST
    };
    Uri uri = Audio.Artists.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;
    }
}
项目:xPlodMusic    文件:TracksBrowser.java   
/**
  * @return number of albums from Bundle
  */
 public String getNumSongs() {
    String[] projection = {
             BaseColumns._ID, ArtistColumns.ARTIST, ArtistColumns.NUMBER_OF_TRACKS
     };
    Uri uri = Audio.Artists.EXTERNAL_CONTENT_URI;        
     Long id = ApolloUtils.getArtistId(getArtist(), ARTIST_ID, this);
     Cursor cursor = null;
     try{
        cursor = this.getContentResolver().query(uri, projection, BaseColumns._ID+ "=" + DatabaseUtils.sqlEscapeString(String.valueOf(id)), null, null);
     }
     catch(Exception e){
        e.printStackTrace();            
     }
     if(cursor == null)
        return String.valueOf(0);
     int mArtistNumAlbumsIndex = cursor.getColumnIndexOrThrow(ArtistColumns.NUMBER_OF_TRACKS);
     if(cursor.getCount()>0){
    cursor.moveToFirst();
      String numAlbums = cursor.getString(mArtistNumAlbumsIndex);   
cursor.close();
      if(numAlbums != null){
        return numAlbums;
      }
     }        
     return String.valueOf(0);
 }
项目:xPlodMusic    文件:TracksBrowser.java   
/**
  * @return number of albums from Bundle
  */
 public String getNumAlbums() {
     if (bundle.getString(NUMALBUMS) != null)
         return bundle.getString(NUMALBUMS);
     String[] projection = {
             BaseColumns._ID, ArtistColumns.ARTIST, ArtistColumns.NUMBER_OF_ALBUMS
     };
     Uri uri = Audio.Artists.EXTERNAL_CONTENT_URI;        
     Long id = ApolloUtils.getArtistId(getArtist(), ARTIST_ID, this);
     Cursor cursor = null;
     try{
        cursor = this.getContentResolver().query(uri, projection, BaseColumns._ID+ "=" + DatabaseUtils.sqlEscapeString(String.valueOf(id)), null, null);
     }
     catch(Exception e){
        e.printStackTrace();            
     }
     if(cursor == null)
        return String.valueOf(0);
     int mArtistNumAlbumsIndex = cursor.getColumnIndexOrThrow(ArtistColumns.NUMBER_OF_ALBUMS);
     if(cursor.getCount()>0){
    cursor.moveToFirst();
      String numAlbums = cursor.getString(mArtistNumAlbumsIndex);   
cursor.close();
      if(numAlbums != null){
        return numAlbums;
      }
     }        
     return String.valueOf(0);
 }
项目:xPlodMusic    文件:ArtistsFragment.java   
public void setupFragmentData(){
    mAdapter = new ArtistAdapter(getActivity(), R.layout.gridview_items, null, 
                                    new String[] {}, new int[] {}, 0); 
    mProjection = new String []{
            BaseColumns._ID, ArtistColumns.ARTIST, ArtistColumns.NUMBER_OF_ALBUMS
    };
    mUri = Audio.Artists.EXTERNAL_CONTENT_URI;
    mSortOrder = Audio.Artists.DEFAULT_SORT_ORDER;
    mFragmentGroupId = 1;
    mType = TYPE_ARTIST;
}
项目:xPlodMusic    文件:ArtistAdapter.java   
public void setupViewData(Cursor mCursor){

        mLineOneText = mCursor.getString(mCursor.getColumnIndexOrThrow(ArtistColumns.ARTIST));
        int albums_plural = mCursor.getInt(mCursor.getColumnIndexOrThrow(ArtistColumns.NUMBER_OF_ALBUMS));
        boolean unknown = mLineOneText == null || mLineOneText.equals(MediaStore.UNKNOWN_STRING);
        mLineTwoText = MusicUtils.makeAlbumsLabel(mContext, albums_plural, 0, unknown);        
        mGridType = TYPE_ARTIST;        
        mImageData = new String[]{mLineOneText};
        mPlayingId = MusicUtils.getCurrentArtistId();
        mCurrentId = mCursor.getLong(mCursor.getColumnIndexOrThrow(BaseColumns._ID));

    }
项目:AlarmOn    文件:MediaArtistsView.java   
public void query(Uri contentUri, String selection) {
  super.query(contentUri, ArtistColumns.ARTIST_KEY, selection, R.layout.media_picker_row, artistsColumns, artistsResIDs);
}