android.provider.MediaStore.Audio.AlbumColumns Java Examples

The following examples show how to use android.provider.MediaStore.Audio.AlbumColumns. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MusicService.java    From Muzesto with GNU General Public License v3.0 5 votes vote down vote up
public String getAlbumArtistName() {
    synchronized (this) {
        if (mAlbumCursor == null) {
            return null;
        }
        return mAlbumCursor.getString(mAlbumCursor.getColumnIndexOrThrow(AlbumColumns.ARTIST));
    }
}
 
Example #2
Source File: ApolloUtils.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
/**
 * @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;
}
 
Example #3
Source File: AddIdCursorLoader.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
@Override
  public Cursor loadInBackground() {

      Cursor mediaCursor = getContext().getContentResolver().query(mUri, mProjection, mSelection,
              mSelectionArgs, mSortOrder);
      //Get cursor filled with Audio Id's
      String [] projection =  new String[] {
              BaseColumns._ID, AlbumColumns.ALBUM
      };
      Uri uri = Audio.Albums.EXTERNAL_CONTENT_URI;
      String sortOrder = Audio.Albums.DEFAULT_SORT_ORDER;
      Cursor albumCursor = getContext().getContentResolver().query(uri, projection, null, null, sortOrder);

      //Matrix cursor to hold final data to be returned to calling context
      MatrixCursor cursor = new MatrixCursor( new String[]
      		{ BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ARTIST, AudioColumns.ALBUM, AudioColumns.ALBUM_ID});
      //Map data from Audio Id cursor to the ALbumName Colum
      ContentQueryMap mQueryMap = new ContentQueryMap(albumCursor, AlbumColumns.ALBUM, false, null);

Map<String, ContentValues> data = mQueryMap.getRows();
      if (mediaCursor != null) {
          while(mediaCursor.moveToNext()) {
		String id = mediaCursor.getString(mediaCursor.getColumnIndexOrThrow(BaseColumns._ID));
		String title = mediaCursor.getString(mediaCursor.getColumnIndexOrThrow(MediaColumns.TITLE));
		String artist = mediaCursor.getString(mediaCursor.getColumnIndexOrThrow(AudioColumns.ARTIST));
		String album = mediaCursor.getString(mediaCursor.getColumnIndexOrThrow(AudioColumns.ALBUM));

		ContentValues tData = data.get(album);
		String albumid = (String) tData.get(BaseColumns._ID);
		cursor.addRow(new String[] {id, title, artist, album, albumid});
          }
          mediaCursor.close();
      }

      if (cursor != null) {
          // Ensure the cursor window is filled
          registerContentObserver(cursor, mObserver);
      }
      return cursor;
  }
 
Example #4
Source File: AlbumsFragment.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
public void setupFragmentData(){
	mAdapter = new AlbumAdapter(getActivity(), R.layout.music_gridview_items, null,
            					new String[] {}, new int[] {}, 0); 
	mProjection = new String []{
            BaseColumns._ID, AlbumColumns.ALBUM, AlbumColumns.ARTIST, AlbumColumns.ALBUM_ART
    };
    mUri = Audio.Albums.EXTERNAL_CONTENT_URI;
    mSortOrder = Audio.Albums.DEFAULT_SORT_ORDER;
    mFragmentGroupId = 2;
    mType = TYPE_ALBUM;
}
 
Example #5
Source File: ArtistAlbumsFragment.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
public void setupFragmentData(){
    mAdapter =new ArtistAlbumAdapter(getActivity(), R.layout.music_listview_items, null,
            									new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
            BaseColumns._ID, AlbumColumns.ALBUM, AlbumColumns.NUMBER_OF_SONGS,
            AlbumColumns.ARTIST
    };
    mSortOrder =  Audio.Albums.DEFAULT_SORT_ORDER;
    long artistId = getArguments().getLong((BaseColumns._ID));
    mUri = Audio.Artists.Albums.getContentUri(EXTERNAL, artistId);
    mFragmentGroupId = 7;
    mType = TYPE_ALBUM;     
}
 
Example #6
Source File: AlbumAdapter.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
public void setupViewData(Cursor mCursor){
    
	mLineOneText = mCursor.getString(mCursor.getColumnIndexOrThrow(AlbumColumns.ALBUM));
    mLineTwoText = mCursor.getString(mCursor.getColumnIndexOrThrow(AlbumColumns.ARTIST));     
    mGridType = TYPE_ALBUM;        
    mImageData =  new String[]{ mCursor.getString(mCursor.getColumnIndexOrThrow(BaseColumns._ID)) , mLineTwoText, mLineOneText };
    mPlayingId = MusicUtils.getCurrentAlbumId();
    mCurrentId = mCursor.getLong(mCursor.getColumnIndexOrThrow(BaseColumns._ID));
    
}
 
Example #7
Source File: ArtistAlbumAdapter.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
public void setupViewData( Cursor mCursor ){
	mLineOneText = mCursor.getString(mCursor.getColumnIndexOrThrow(AlbumColumns.ALBUM));    	
    int songs_plural = mCursor.getInt(mCursor.getColumnIndexOrThrow(AlbumColumns.NUMBER_OF_SONGS));
	mLineTwoText =MusicUtils.makeAlbumsLabel(mContext, 0, songs_plural, true );    	
    String artistName = mCursor.getString(mCursor.getColumnIndexOrThrow(AlbumColumns.ARTIST));        
    String albumId = mCursor.getString(mCursor.getColumnIndexOrThrow(BaseColumns._ID));
    mImageData = new String[]{ albumId , artistName, mLineOneText };        
    mPlayingId = MusicUtils.getCurrentAlbumId();
    mCurrentId = Long.parseLong(albumId);        
    mListType = TYPE_ALBUM;   	
}
 
Example #8
Source File: MediaAlbumsView.java    From AlarmOn with Apache License 2.0 5 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  super.onItemClick(parent, view, position, id);
  songsView.query(Media.EXTERNAL_CONTENT_URI, AlbumColumns.ALBUM_KEY + " = '" + getLastSelectedName() + "'");
  getFlipper().setInAnimation(getContext(), R.anim.slide_in_left);
  getFlipper().setOutAnimation(getContext(), R.anim.slide_out_left);
  getFlipper().showNext();
}
 
Example #9
Source File: MediaAlbumsView.java    From AlarmOn with Apache License 2.0 4 votes vote down vote up
public MediaAlbumsView(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);
  overrideSortOrder(AlbumColumns.ALBUM + " ASC");
  songsView = new MediaSongsView(context);
  songsView.overrideSortOrder(null);
}
 
Example #10
Source File: MediaAlbumsView.java    From AlarmOn with Apache License 2.0 4 votes vote down vote up
public void query(Uri contentUri, String selection) {
  super.query(contentUri, AlbumColumns.ALBUM_KEY, selection, R.layout.media_picker_row, albumsColumns, albumsResIDs);
}