android.provider.MediaStore.Audio Java Examples

The following examples show how to use android.provider.MediaStore.Audio. 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: TracksBrowser.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
public void onSearchWeb(){
	String query = "";
	if (Audio.Artists.CONTENT_TYPE.equals(mimeType)) {
		query = getArtist();
    } else if (Audio.Albums.CONTENT_TYPE.equals(mimeType)) {
    	query = getAlbum() + " " + getArtist();
    } else if (Playlists.CONTENT_TYPE.equals(mimeType)) {
    	query = bundle.getString(PLAYLIST_NAME);
    }
    else{
        Long id = bundle.getLong(BaseColumns._ID);
        query = MusicUtils.parseGenreName(this, MusicUtils.getGenreName(this, id, true));
    }
    final Intent googleSearch = new Intent(Intent.ACTION_WEB_SEARCH);
    googleSearch.putExtra(SearchManager.QUERY, query);
    startActivity(googleSearch);
}
 
Example #2
Source File: ApolloService.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
private boolean makeAutoShuffleList() {
    ContentResolver res = getContentResolver();
    Cursor c = null;
    try {
        c = res.query(Audio.Media.EXTERNAL_CONTENT_URI, new String[] {
            BaseColumns._ID
        }, AudioColumns.IS_MUSIC + "=1", null, null);
        if (c == null || c.getCount() == 0) {
            return false;
        }
        int len = c.getCount();
        long[] list = new long[len];
        for (int i = 0; i < len; i++) {
            c.moveToNext();
            list[i] = c.getLong(0);
        }
        mAutoShuffleList = list;
        return true;
    } catch (RuntimeException ex) {
    } finally {
        if (c != null) {
            c.close();
        }
    }
    return false;
}
 
Example #3
Source File: StorageProvider.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
protected ParcelFileDescriptor openAudioThumbnailCleared(long id, CancellationSignal signal)
        throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();

    Cursor cursor = null;
    try {
        cursor = resolver.query(Audio.Albums.EXTERNAL_CONTENT_URI,
        		AudioThumbnailQuery.PROJECTION, Audio.Albums._ID + "=" + id,
                null, null);
        if (cursor.moveToFirst()) {
            final String data = cursor.getString(AudioThumbnailQuery._DATA);
            return ParcelFileDescriptor.open(
                    new File(data), ParcelFileDescriptor.MODE_READ_ONLY);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
    }
    return null;
}
 
Example #4
Source File: QuickQueueFragment.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
	String[] projection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST,
    };
    StringBuilder selection = new StringBuilder();
    Uri uri = Audio.Media.EXTERNAL_CONTENT_URI;
    String sortOrder = Audio.Media.DEFAULT_SORT_ORDER;
    uri = Audio.Media.EXTERNAL_CONTENT_URI;
    long[] mNowPlaying = MusicUtils.getQueue();
    if (mNowPlaying.length == 0)
        return null;
    selection = new StringBuilder();
    selection.append(BaseColumns._ID + " IN (");
    if (mNowPlaying == null || mNowPlaying.length <= 0)
        return null;
    for (long queue_id : mNowPlaying) {
        selection.append(queue_id + ",");
    }
    selection.deleteCharAt(selection.length() - 1);
    selection.append(")");
	
    return new AddIdCursorLoader(getActivity(), uri, projection, selection.toString(), null,
            sortOrder);
}
 
Example #5
Source File: QuickQueueFragment.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
/**
 * Reload the queue after we remove a track
 */
private void reloadQueueCursor() {
    String[] projection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST,
    };
    StringBuilder selection = new StringBuilder();
    Uri uri = Audio.Media.EXTERNAL_CONTENT_URI;
    String sortOrder = Audio.Media.DEFAULT_SORT_ORDER;
    uri = Audio.Media.EXTERNAL_CONTENT_URI;
    long[] mNowPlaying = MusicUtils.getQueue();
    if (mNowPlaying.length == 0)
        return;
    selection = new StringBuilder();
    selection.append(BaseColumns._ID + " IN (");
    if (mNowPlaying == null || mNowPlaying.length <= 0)
        return;
    for (long queue_id : mNowPlaying) {
        selection.append(queue_id + ",");
    }
    selection.deleteCharAt(selection.length() - 1);
    selection.append(")");

    mCursor = MusicUtils.query(getActivity(), uri, projection, selection.toString(), null,
            sortOrder);
    mQuickQueueAdapter.changeCursor(mCursor);
}
 
Example #6
Source File: AlbumListFragment.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
@Override
public void setupFragmentData() {
       mAdapter = new AlbumListAdapter(getActivity(), R.layout.music_listview_items, null,
               								new String[] {}, new int[] {}, 0);
   	mProjection = new String[] {
               BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
       };
       StringBuilder where = new StringBuilder();
       where.append(AudioColumns.IS_MUSIC + "=1")
       					.append(" AND " + MediaColumns.TITLE + " != ''");
       long albumId = getArguments().getLong(BaseColumns._ID);
       where.append(" AND " + AudioColumns.ALBUM_ID + "=" + albumId);
       mWhere = where.toString();        
       mSortOrder = Audio.Media.TRACK + ", " + Audio.Media.DEFAULT_SORT_ORDER;
       mUri = Audio.Media.EXTERNAL_CONTENT_URI;
       mFragmentGroupId = 89;
       mType = TYPE_ALBUM;
       mTitleColumn = MediaColumns.TITLE; 
}
 
Example #7
Source File: RecentlyAddedFragment.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
public void setupFragmentData(){
    mAdapter = new RecentlyAddedAdapter(getActivity(), R.layout.music_listview_items,
            null, new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
    };
    StringBuilder where = new StringBuilder();
    int X = MusicUtils.getIntPref(getActivity(), NUMWEEKS, 5) * 3600 * 24 * 7;
    where.append(MediaColumns.TITLE + " != ''");
    where.append(" AND " + AudioColumns.IS_MUSIC + "=1");
    where.append(" AND " + MediaColumns.DATE_ADDED + ">"
            + (System.currentTimeMillis() / 1000 - X));
    mWhere = where.toString();
    mSortOrder = MediaColumns.DATE_ADDED + " DESC";
    mUri = Audio.Media.EXTERNAL_CONTENT_URI;
    mTitleColumn = MediaColumns.TITLE;       
}
 
Example #8
Source File: StorageProvider.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
protected ParcelFileDescriptor openAudioThumbnailCleared(long id, CancellationSignal signal)
        throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();

    Cursor cursor = null;
    try {
        cursor = resolver.query(Audio.Albums.EXTERNAL_CONTENT_URI,
        		AudioThumbnailQuery.PROJECTION, Audio.Albums._ID + "=" + id,
                null, null);
        if (cursor.moveToFirst()) {
            final String data = cursor.getString(AudioThumbnailQuery._DATA);
            return ParcelFileDescriptor.open(
                    new File(data), ParcelFileDescriptor.MODE_READ_ONLY);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
    }
    return null;
}
 
Example #9
Source File: ArtistListFragment.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
@Override
public void setupFragmentData(){
    mAdapter = new ArtistListAdapter(getActivity(), R.layout.music_listview_items, null,
            								new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
    };
    StringBuilder where = new StringBuilder();
    where.append(AudioColumns.IS_MUSIC + "=1")
    					.append(" AND " + MediaColumns.TITLE + " != ''");
    long artist_id = getArguments().getLong(BaseColumns._ID);
    where.append(" AND " + AudioColumns.ARTIST_ID + "=" + artist_id);
    mWhere = where.toString();        
    mSortOrder = MediaColumns.TITLE;
    mUri = Audio.Media.EXTERNAL_CONTENT_URI;
    mFragmentGroupId = 88;
    mType = TYPE_ARTIST;
    mTitleColumn = MediaColumns.TITLE; 
}
 
Example #10
Source File: StorageProvider.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
protected ParcelFileDescriptor openAudioThumbnailCleared(long id, CancellationSignal signal)
        throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();

    Cursor cursor = null;
    try {
        cursor = resolver.query(Audio.Albums.EXTERNAL_CONTENT_URI,
        		AudioThumbnailQuery.PROJECTION, Audio.Albums._ID + "=" + id,
                null, null);
        if (cursor.moveToFirst()) {
            final String data = cursor.getString(AudioThumbnailQuery._DATA);
            return ParcelFileDescriptor.open(
                    new File(data), ParcelFileDescriptor.MODE_READ_ONLY);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
    }
    return null;
}
 
Example #11
Source File: QueryBrowserActivity.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
private Cursor getQueryCursor(AsyncQueryHandler async, String filter) {
    if (filter == null) {
        filter = "";
    }
    String[] ccols = new String[] {
            BaseColumns._ID, Audio.Media.MIME_TYPE, Audio.Artists.ARTIST, Audio.Albums.ALBUM,
            Audio.Media.TITLE, "data1", "data2"
    };

    Uri search = Uri.parse("content://media/external/audio/search/fancy/" + Uri.encode(filter));

    Cursor ret = null;
    if (async != null) {
        async.startQuery(0, null, search, ccols, null, null, null);
    } else {
        ret = MusicUtils.query(this, search, ccols, null, null, null);
    }
    return ret;
}
 
Example #12
Source File: PlaylistDialog.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
private int idForplaylist(String name) {

        Cursor cursor = MusicUtils.query(this, Audio.Playlists.EXTERNAL_CONTENT_URI, new String[] {
            Audio.Playlists._ID
        }, Audio.Playlists.NAME + "=?", new String[] {
            name
        }, Audio.Playlists.NAME, 0);
        int id = -1;
        if (cursor != null) {
            cursor.moveToFirst();
            if (!cursor.isAfterLast()) {
                id = cursor.getInt(0);
            }
            cursor.close();
        }

        return id;
    }
 
Example #13
Source File: PlaylistDialog.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
private String nameForId(long id) {

        Cursor cursor = MusicUtils.query(this, Audio.Playlists.EXTERNAL_CONTENT_URI, new String[] {
            Audio.Playlists.NAME
        }, Audio.Playlists._ID + "=?", new String[] {
            Long.valueOf(id).toString()
        }, Audio.Playlists.NAME);
        String name = null;
        if (cursor != null) {
            cursor.moveToFirst();
            if (!cursor.isAfterLast()) {
                name = cursor.getString(0);
            }
            cursor.close();
        }
        return name;
    }
 
Example #14
Source File: TracksBrowser.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
	if (Audio.Artists.CONTENT_TYPE.equals(mimeType)) {
		
    	menu.setHeaderTitle(R.string.image_edit_artists);
    	getMenuInflater().inflate(R.menu.music_context_artistimage, menu);
    	
    } else if (Audio.Albums.CONTENT_TYPE.equals(mimeType)) {
    	
    	menu.setHeaderTitle(R.string.image_edit_albums);
    	getMenuInflater().inflate(R.menu.music_context_albumimage, menu);
    	
    } else if (Playlists.CONTENT_TYPE.equals(mimeType)) {
    	menu.setHeaderTitle(R.string.image_edit_playlist);
    	getMenuInflater().inflate(R.menu.music_context_playlist_genreimage, menu);
    }
    else{
    	menu.setHeaderTitle(R.string.image_edit_genre);
    	getMenuInflater().inflate(R.menu.music_context_playlist_genreimage, menu);
    }
}
 
Example #15
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 #16
Source File: TracksBrowser.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
/**
  * @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);
 }
 
Example #17
Source File: NowPlayingFragment.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
@Override
public void setupFragmentData() {
	mAdapter = new NowPlayingAdapter(getActivity(), R.layout.music_dragsort_listview_items, null,
	        							new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
	            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
	    };
	mSortOrder = Audio.Media.DEFAULT_SORT_ORDER;
	mUri = Audio.Media.EXTERNAL_CONTENT_URI;
	StringBuilder where = new StringBuilder();
	long[] mNowPlaying = MusicUtils.getQueue();
	if (mNowPlaying.length <= 0){
		where.append(AudioColumns.IS_MUSIC + "=1").append(" AND " + MediaColumns.TITLE + " != ''");
	}
	else{
		where.append(BaseColumns._ID + " IN (");
		for (long queue_id : mNowPlaying) {
		    where.append(queue_id + ",");
		}
		where.deleteCharAt(where.length() - 1);
		where.append(")");			
	}
	mWhere = where.toString();
       mMediaIdColumn = BaseColumns._ID;
       mType = TYPE_SONG;
       mFragmentGroupId = 91;
}
 
Example #18
Source File: PlaylistsFragment.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
@Override
  public boolean onContextItemSelected(MenuItem item) {
  	if(item.getGroupId() == mFragmentGroupId){
       AdapterContextMenuInfo mi = (AdapterContextMenuInfo)item.getMenuInfo();
       switch (item.getItemId()) {
           case PLAY_SELECTION: {
               long[] list = MusicUtils.getSongListForPlaylist(getActivity(),
                       Long.parseLong(mCurrentId));
               MusicUtils.playAll(getActivity(), list, 0);
               break;
           }
           case RENAME_PLAYLIST: {
               Intent intent = new Intent(INTENT_RENAME_PLAYLIST);
               intent.putExtra(INTENT_KEY_RENAME, mi.id);
               getActivity().startActivity(intent);
               break;
           }
           case DELETE_PLAYLIST: {
               Uri uri = ContentUris.withAppendedId(
                       Audio.Playlists.EXTERNAL_CONTENT_URI, mi.id);
               getActivity().getContentResolver().delete(uri, null, null);
               break;
           }
           default:
               break;
       }
	return true;
}
      return super.onContextItemSelected(item);
  }
 
Example #19
Source File: GenresFragment.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
public void setupFragmentData(){
    mAdapter = new GenreAdapter(getActivity(), R.layout.music_listview_items, null,
            new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
            Audio.Genres._ID, Audio.Genres.NAME
    };        
    mSortOrder = Audio.Genres.DEFAULT_SORT_ORDER;
    mUri = Audio.Genres.EXTERNAL_CONTENT_URI;
    mFragmentGroupId = 4;
    mType = TYPE_GENRE;
    mTitleColumn = Audio.Genres.NAME;         
}
 
Example #20
Source File: GenresFragment.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    menu.add(mFragmentGroupId, ADD_TO_LOVE, 0, getResources().getString(R.string.play_all));
    mCurrentId = mCursor.getString(mCursor.getColumnIndexOrThrow(BaseColumns._ID));
    String title = mCursor.getString(mCursor.getColumnIndexOrThrow(Audio.Genres.NAME));
    menu.setHeaderTitle(title);
}
 
Example #21
Source File: FileUtils.java    From AndJie with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if uri is a media uri.
 * 
 * @param uri
 * @return
 */
public static boolean isMediaUri(Uri uri) {
	String uriString = uri.toString();
	if (uriString.startsWith(Audio.Media.INTERNAL_CONTENT_URI.toString())
			|| uriString.startsWith(Audio.Media.EXTERNAL_CONTENT_URI
					.toString())
			|| uriString.startsWith(Video.Media.INTERNAL_CONTENT_URI
					.toString())
			|| uriString.startsWith(Video.Media.EXTERNAL_CONTENT_URI
					.toString())) {
		return true;
	} else {
		return false;
	}
}
 
Example #22
Source File: AudioWidget.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
protected void captureAudio(FormEntryPrompt prompt) {
    Intent i = new Intent(Audio.Media.RECORD_SOUND_ACTION);
    i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
            Audio.Media.EXTERNAL_CONTENT_URI.toString());
    try {
        ((Activity)getContext()).startActivityForResult(i, FormEntryConstants.AUDIO_VIDEO_FETCH);
        pendingCalloutInterface.setPendingCalloutFormIndex(prompt.getIndex());
    } catch (ActivityNotFoundException e) {
        Toast.makeText(getContext(),
                StringUtils.getStringSpannableRobust(getContext(),
                        R.string.activity_not_found,
                        "audio capture"),
                Toast.LENGTH_SHORT).show();
    }
}
 
Example #23
Source File: PlaylistsFragment.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
public void setupFragmentData(){
    mAdapter = new PlaylistAdapter(getActivity(), R.layout.music_listview_items, null,
            										new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
            BaseColumns._ID, PlaylistsColumns.NAME
    };
    mSortOrder = Audio.Playlists.DEFAULT_SORT_ORDER;
    mUri = Audio.Playlists.EXTERNAL_CONTENT_URI;
    mFragmentGroupId = 5;
    mType = TYPE_PLAYLIST;
    mTitleColumn = PlaylistsColumns.NAME;         
}
 
Example #24
Source File: ArtistsFragment.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
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;
}
 
Example #25
Source File: ApolloService.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
private void setNextTrack() {
    mNextPlayPos = getNextPosition(false);
    if (mNextPlayPos >= 0 && mPlayList != null) {
        long id = mPlayList[mNextPlayPos];
        mPlayer.setNextDataSource(Audio.Media.EXTERNAL_CONTENT_URI + "/" + id);
    }
}
 
Example #26
Source File: ApolloService.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
private Cursor getCursorForId(long lid) {
    String id = String.valueOf(lid);

    Cursor c = getContentResolver().query(
            Audio.Media.EXTERNAL_CONTENT_URI,
            mCursorCols, "_id=" + id , null, null);
    if (c != null) {
        c.moveToFirst();
    }
    return c;
}
 
Example #27
Source File: TracksBrowser.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
    if (resultCode == FragmentActivity.RESULT_OK && requestCode == RESULT_LOAD_IMAGE  && data != null)
 {
    	Uri selectedImage = data.getData();
     String[] filePathColumn = { MediaStore.Images.Media.DATA };
     Cursor cursor = getContentResolver().query(selectedImage,filePathColumn, null, null, null);
     cursor.moveToFirst();
     int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
     String picturePath = cursor.getString(columnIndex);
     cursor.close();

        ImageInfo mInfo = new ImageInfo();
     if (Audio.Artists.CONTENT_TYPE.equals(mimeType)) {
         mInfo.type = TYPE_ARTIST;
         mInfo.data = new String[]{ getArtist(), picturePath };
     } else if (Audio.Albums.CONTENT_TYPE.equals(mimeType)) {
         mInfo.type = TYPE_ALBUM;
         mInfo.data = new String[]{ getAlbumId(), getAlbum(), getArtist(), picturePath };
     } else if (Playlists.CONTENT_TYPE.equals(mimeType)) {
         mInfo.type = TYPE_PLAYLIST;
         mInfo.data = new String[]{ bundle.getString(PLAYLIST_NAME), picturePath };
     }
     else{
     	Long id = bundle.getLong(BaseColumns._ID);
         mInfo.type = TYPE_GENRE;
         mInfo.data = new String[]{  MusicUtils.parseGenreName(this, MusicUtils.getGenreName(this, id, true)), picturePath };
     }

        mInfo.size = SIZE_NORMAL;
        mInfo.source = SRC_GALLERY;
        mImageProvider.loadImage((ImageView)findViewById(R.id.half_artist_image), mInfo );

 }
}
 
Example #28
Source File: TracksBrowser.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
/**
 * Set the correct title
 */
private void setTitle() {
    String name;
    long id;
    if (Playlists.CONTENT_TYPE.equals(mimeType)) {
        id = bundle.getLong(BaseColumns._ID);
        switch ((int)id) {
            case (int)PLAYLIST_QUEUE:
                setTitle(R.string.nowplaying);
                return;
            case (int)PLAYLIST_FAVORITES:
                setTitle(R.string.favorite);
                return;
            default:
                if (id < 0) {
                    setTitle(R.string.app_name);
                    return;
                }
        }
        name = MusicUtils.getPlaylistName(this, id);
    } else if (Audio.Artists.CONTENT_TYPE.equals(mimeType)) {
        id = bundle.getLong(BaseColumns._ID);
        name =  getString (R.string.artist_page_title)+MusicUtils.getArtistName(this, id, true);
    } else if (Audio.Albums.CONTENT_TYPE.equals(mimeType)) {
        id = bundle.getLong(BaseColumns._ID);
        name =  getString (R.string.album_page_title)+MusicUtils.getAlbumName(this, id, true);
    } else if (Genres.CONTENT_TYPE.equals(mimeType)) {
        id = bundle.getLong(BaseColumns._ID);
        name = MusicUtils.parseGenreName(this, MusicUtils.getGenreName(this, id, true));
    } else {
        setTitle(R.string.app_name);
        return;
    }
    setTitle(name);
}
 
Example #29
Source File: TracksBrowser.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
/**
  * @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);
 }
 
Example #30
Source File: TracksBrowser.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
/**
 * Initiate ViewPager and PagerAdapter
 */
private void initPager() {
    // Initiate PagerAdapter
    PagerAdapter mPagerAdapter = new PagerAdapter(getSupportFragmentManager());
    if (ApolloUtils.isArtist(mimeType))
        // Show all albums for an artist
        mPagerAdapter.addFragment(new ArtistAlbumsFragment(bundle));
    // Show the tracks for an artist or album
    if(Playlists.CONTENT_TYPE.equals(mimeType)){
        mPagerAdapter.addFragment(new PlaylistListFragment(bundle));
    }
    else if(Genres.CONTENT_TYPE.equals(mimeType)){
    	mPagerAdapter.addFragment(new GenreListFragment(bundle));
    }
    else if(ApolloUtils.isArtist(mimeType)){
    	mPagerAdapter.addFragment(new ArtistListFragment(bundle));
    }
    else if(Audio.Albums.CONTENT_TYPE.equals(mimeType)){
    	mPagerAdapter.addFragment(new AlbumListFragment(bundle));
    }

    // Set up ViewPager
    mViewPager = (ViewPager)findViewById(R.id.viewPager);
    mViewPager.setPageMargin(getResources().getInteger(R.integer.viewpager_margin_width));
    mViewPager.setPageMarginDrawable(R.drawable.music_viewpager_margin);
    mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount());
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.setOnPageChangeListener(new PageListener());
}