/** * @Description 得到原图 */ @SuppressWarnings("unused") private void getAlbum() { String[] projection = { Albums._ID, Albums.ALBUM, Albums.ALBUM_ART, Albums.ALBUM_KEY, Albums.ARTIST, Albums.NUMBER_OF_SONGS }; Cursor cursor = null; try { cursor = contentResolver.query(Albums.EXTERNAL_CONTENT_URI, projection, null, null, null); getAlbumColumnData(cursor); } catch (Exception e) { logger.e(e.getMessage()); } finally { if (null != cursor) { cursor.close(); } } }
/** * 得到原图 */ void getAlbum() { String[] projection = {Albums._ID, Albums.ALBUM, Albums.ALBUM_ART, Albums.ALBUM_KEY, Albums.ARTIST, Albums.NUMBER_OF_SONGS}; Cursor cursor = cr.query(Albums.EXTERNAL_CONTENT_URI, projection, null, null, null); getAlbumColumnData(cursor); }
/** * 从数据库中得到原图 * * @param cur */ private void getAlbumColumnData(Cursor cur) { try { if (cur.moveToFirst()) { int _id; String album; String albumArt; String albumKey; String artist; int numOfSongs; int _idColumn = cur.getColumnIndex(Albums._ID); int albumColumn = cur.getColumnIndex(Albums.ALBUM); int albumArtColumn = cur.getColumnIndex(Albums.ALBUM_ART); int albumKeyColumn = cur.getColumnIndex(Albums.ALBUM_KEY); int artistColumn = cur.getColumnIndex(Albums.ARTIST); int numOfSongsColumn = cur.getColumnIndex(Albums.NUMBER_OF_SONGS); do { _id = cur.getInt(_idColumn); album = cur.getString(albumColumn); albumArt = cur.getString(albumArtColumn); albumKey = cur.getString(albumKeyColumn); artist = cur.getString(artistColumn); numOfSongs = cur.getInt(numOfSongsColumn); HashMap<String, String> hash = new HashMap<String, String>(); hash.put("_id", _id + ""); hash.put("album", album); hash.put("albumArt", albumArt); hash.put("albumKey", albumKey); hash.put("artist", artist); hash.put("numOfSongs", numOfSongs + ""); albumList.add(hash); } while (cur.moveToNext()); } } catch (Exception e) { logger.e(e.getMessage()); } }
void getAlbum() { String[] projection = { Albums._ID, Albums.ALBUM, Albums.ALBUM_ART, Albums.ALBUM_KEY, Albums.ARTIST, Albums.NUMBER_OF_SONGS }; Cursor cursor = cr.query(Albums.EXTERNAL_CONTENT_URI, projection, null, null, null); getAlbumColumnData(cursor); }
/** * �õ�ԭͼ */ void getAlbum() { String[] projection = { Albums._ID, Albums.ALBUM, Albums.ALBUM_ART, Albums.ALBUM_KEY, Albums.ARTIST, Albums.NUMBER_OF_SONGS }; Cursor cursor = cr.query(Albums.EXTERNAL_CONTENT_URI, projection, null, null, null); getAlbumColumnData(cursor); }
public void getAlbum(){ String[] projection = { Albums._ID, Albums.ALBUM, Albums.ALBUM_ART, Albums.ALBUM_KEY, Albums.ARTIST, Albums.NUMBER_OF_SONGS }; Cursor cursor = resolver.query(Albums.EXTERNAL_CONTENT_URI, projection, null, null, Albums._ID+" desc"); if(cursor.moveToFirst()){ int _id; String album ; String albumArt ; String albumKey; String artist; int numOfSongs; int _idColumn = cursor.getColumnIndex(Albums._ID); int albumColumn = cursor.getColumnIndex(Albums.ALBUM); int albumArtColumn = cursor.getColumnIndex(Albums.ALBUM_ART); int albumKeyColumn = cursor.getColumnIndex(Albums.ALBUM_KEY); int artistColumn = cursor.getColumnIndex(Albums.ARTIST); int numOfSongsColumn = cursor.getColumnIndex(Albums.NUMBER_OF_SONGS); do { _id = cursor.getInt(_idColumn); album = cursor.getString(albumColumn); albumArt = cursor.getString(albumArtColumn); albumKey = cursor.getString(albumKeyColumn); artist = cursor.getString(artistColumn); numOfSongs = cursor.getInt(numOfSongsColumn); HashMap<String, String> hash = new HashMap<>(); hash.put("_id", _id + ""); hash.put("album", album); hash.put("albumArt", albumArt); hash.put("albumKey", albumKey); hash.put("artist", artist); hash.put("numOfSongs", numOfSongs + ""); albumList.add(hash); }while (cursor.moveToNext()); } cursor.close(); }
@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(); }
/** * 得到原图 */ void getAlbum() { String[] projection = { Albums._ID, Albums.ALBUM, Albums.ALBUM_ART, Albums.ALBUM_KEY, Albums.ARTIST, Albums.NUMBER_OF_SONGS }; Cursor cursor = cr.query(Albums.EXTERNAL_CONTENT_URI, projection, null, null, null); getAlbumColumnData(cursor); }
/** * 创建图片原图集合 */ private void createAlbums(){ Cursor cursor = mContentResolver.query(Media.EXTERNAL_CONTENT_URI, ALBUMS_PROJECTION, null, null, null); if (cursor.moveToFirst()) { int idIndex = cursor.getColumnIndex(Albums._ID); int albumIndex = cursor.getColumnIndex(Albums.ALBUM); int albumArtIndex = cursor.getColumnIndex(Albums.ALBUM_ART); int albumKeyIndex = cursor.getColumnIndex(Albums.ALBUM_KEY); int artistIndex = cursor.getColumnIndex(Albums.ARTIST); int numberOfSongsIndex = cursor.getColumnIndex(Albums.NUMBER_OF_SONGS); do { int id = cursor.getInt(idIndex); int numberOfSongs = cursor.getInt(numberOfSongsIndex); String album = cursor.getString(albumIndex); String artist = cursor.getString(artistIndex); String albumKey = cursor.getString(albumKeyIndex); String albumArt = cursor.getString(albumArtIndex); Map<String, String> albumItem = new HashMap<String, String>(); albumItem.put("_id", String.valueOf(id)); albumItem.put("album", album); albumItem.put("albumArt", albumArt); albumItem.put("albumKey", albumKey); albumItem.put("artist", artist); albumItem.put("numOfSongs", String.valueOf(numberOfSongs)); albums.add(albumItem); } while (cursor.moveToNext()); } cursor.close(); }
/** * 从本地数据库中得到原图 * * @param cur */ private void getAlbumColumnData(Cursor cur) { if (cur.moveToFirst()) { int _id; String album; String albumArt; String albumKey; String artist; int numOfSongs; int _idColumn = cur.getColumnIndex(Albums._ID); int albumColumn = cur.getColumnIndex(Albums.ALBUM); int albumArtColumn = cur.getColumnIndex(Albums.ALBUM_ART); int albumKeyColumn = cur.getColumnIndex(Albums.ALBUM_KEY); int artistColumn = cur.getColumnIndex(Albums.ARTIST); int numOfSongsColumn = cur.getColumnIndex(Albums.NUMBER_OF_SONGS); do { // Get the field values _id = cur.getInt(_idColumn); album = cur.getString(albumColumn); albumArt = cur.getString(albumArtColumn); albumKey = cur.getString(albumKeyColumn); artist = cur.getString(artistColumn); numOfSongs = cur.getInt(numOfSongsColumn); // Do something with the values. Log.i(TAG, _id + " album:" + album + " albumArt:" + albumArt + "albumKey: " + albumKey + " artist: " + artist + " numOfSongs: " + numOfSongs + "---"); HashMap<String, String> hash = new HashMap<String, String>(); hash.put("_id", _id + ""); hash.put("album", album); hash.put("albumArt", albumArt); hash.put("albumKey", albumKey); hash.put("artist", artist); hash.put("numOfSongs", numOfSongs + ""); albumList.add(hash); } while (cur.moveToNext()); cur.close(); } }
private void getAlbumColumnData(Cursor cur) { if (cur.moveToFirst()) { int _id; String album; String albumArt; String albumKey; String artist; int numOfSongs; int _idColumn = cur.getColumnIndex(Albums._ID); int albumColumn = cur.getColumnIndex(Albums.ALBUM); int albumArtColumn = cur.getColumnIndex(Albums.ALBUM_ART); int albumKeyColumn = cur.getColumnIndex(Albums.ALBUM_KEY); int artistColumn = cur.getColumnIndex(Albums.ARTIST); int numOfSongsColumn = cur.getColumnIndex(Albums.NUMBER_OF_SONGS); do { // Get the field values _id = cur.getInt(_idColumn); album = cur.getString(albumColumn); albumArt = cur.getString(albumArtColumn); albumKey = cur.getString(albumKeyColumn); artist = cur.getString(artistColumn); numOfSongs = cur.getInt(numOfSongsColumn); // Do something with the values. Log.i(TAG, _id + " album:" + album + " albumArt:" + albumArt + "albumKey: " + albumKey + " artist: " + artist + " numOfSongs: " + numOfSongs + "---"); HashMap<String, String> hash = new HashMap<String, String>(); hash.put("_id", _id + ""); hash.put("album", album); hash.put("albumArt", albumArt); hash.put("albumKey", albumKey); hash.put("artist", artist); hash.put("numOfSongs", numOfSongs + ""); albumList.add(hash); } while (cur.moveToNext()); } }
/** * �ӱ������ݿ��еõ�ԭͼ * * @param cur */ private void getAlbumColumnData(Cursor cur) { if (cur.moveToFirst()) { int _id; String album; String albumArt; String albumKey; String artist; int numOfSongs; int _idColumn = cur.getColumnIndex(Albums._ID); int albumColumn = cur.getColumnIndex(Albums.ALBUM); int albumArtColumn = cur.getColumnIndex(Albums.ALBUM_ART); int albumKeyColumn = cur.getColumnIndex(Albums.ALBUM_KEY); int artistColumn = cur.getColumnIndex(Albums.ARTIST); int numOfSongsColumn = cur.getColumnIndex(Albums.NUMBER_OF_SONGS); do { // Get the field values _id = cur.getInt(_idColumn); album = cur.getString(albumColumn); albumArt = cur.getString(albumArtColumn); albumKey = cur.getString(albumKeyColumn); artist = cur.getString(artistColumn); numOfSongs = cur.getInt(numOfSongsColumn); // Do something with the values. Log.i(TAG, _id + " album:" + album + " albumArt:" + albumArt + "albumKey: " + albumKey + " artist: " + artist + " numOfSongs: " + numOfSongs + "---"); HashMap<String, String> hash = new HashMap<String, String>(); hash.put("_id", _id + ""); hash.put("album", album); hash.put("albumArt", albumArt); hash.put("albumKey", albumKey); hash.put("artist", artist); hash.put("numOfSongs", numOfSongs + ""); albumList.add(hash); } while (cur.moveToNext()); } }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { String[] projection = new String[] { BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST }; StringBuilder where = new StringBuilder(); String sortOrder = Audio.Media.DEFAULT_SORT_ORDER; where.append(AudioColumns.IS_MUSIC + "=1").append(" AND " + MediaColumns.TITLE + " != ''"); Uri uri = Audio.Media.EXTERNAL_CONTENT_URI; if (getArguments() != null) { mPlaylistId = getArguments().getLong(BaseColumns._ID); String mimeType = getArguments().getString(MIME_TYPE); if (Audio.Playlists.CONTENT_TYPE.equals(mimeType)) { where = new StringBuilder(); where.append(AudioColumns.IS_MUSIC + "=1"); where.append(" AND " + MediaColumns.TITLE + " != ''"); switch ((int)mPlaylistId) { case (int)PLAYLIST_QUEUE: uri = Audio.Media.EXTERNAL_CONTENT_URI; long[] mNowPlaying = MusicUtils.getQueue(); if (mNowPlaying.length == 0) return null; where = new StringBuilder(); where.append(BaseColumns._ID + " IN ("); if (mNowPlaying == null || mNowPlaying.length <= 0) return null; for (long queue_id : mNowPlaying) { where.append(queue_id + ","); } where.deleteCharAt(where.length() - 1); where.append(")"); break; case (int)PLAYLIST_FAVORITES: long favorites_id = MusicUtils.getFavoritesId(getActivity()); projection = new String[] { Playlists.Members._ID, Playlists.Members.AUDIO_ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST }; uri = Playlists.Members.getContentUri(EXTERNAL, favorites_id); sortOrder = Playlists.Members.DEFAULT_SORT_ORDER; break; default: if (id < 0) return null; projection = new String[] { Playlists.Members._ID, Playlists.Members.AUDIO_ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST, AudioColumns.DURATION }; uri = Playlists.Members.getContentUri(EXTERNAL, mPlaylistId); sortOrder = Playlists.Members.DEFAULT_SORT_ORDER; break; } } else if (Audio.Genres.CONTENT_TYPE.equals(mimeType)) { long genreId = getArguments().getLong(BaseColumns._ID); uri = Genres.Members.getContentUri(EXTERNAL, genreId); projection = new String[] { BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST }; where = new StringBuilder(); where.append(AudioColumns.IS_MUSIC + "=1").append( " AND " + MediaColumns.TITLE + " != ''"); sortOrder = Genres.Members.DEFAULT_SORT_ORDER; } else { if (Audio.Albums.CONTENT_TYPE.equals(mimeType)) { long albumId = getArguments().getLong(BaseColumns._ID); where.append(" AND " + AudioColumns.ALBUM_ID + "=" + albumId); sortOrder = Audio.Media.TRACK + ", " + sortOrder; } else if (Audio.Artists.CONTENT_TYPE.equals(mimeType)) { sortOrder = MediaColumns.TITLE; long artist_id = getArguments().getLong(BaseColumns._ID); where.append(" AND " + AudioColumns.ARTIST_ID + "=" + artist_id); } } } return new CursorLoader(getActivity(), uri, projection, where.toString(), null, sortOrder); }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Check for database errors if (data == null) { return; } if (getArguments() != null && Playlists.CONTENT_TYPE.equals(getArguments().getString(MIME_TYPE)) && (getArguments().getLong(BaseColumns._ID) >= 0 || getArguments().getLong( BaseColumns._ID) == PLAYLIST_FAVORITES)) { mMediaIdIndex = data.getColumnIndexOrThrow(Playlists.Members.AUDIO_ID); mTitleIndex = data.getColumnIndexOrThrow(MediaColumns.TITLE); mAlbumIndex = data.getColumnIndexOrThrow(AudioColumns.ALBUM); // FIXME // mArtistIndex = // data.getColumnIndexOrThrow(Playlists.Members.ARTIST); } else if (getArguments() != null && Genres.CONTENT_TYPE.equals(getArguments().getString(MIME_TYPE))) { mMediaIdIndex = data.getColumnIndexOrThrow(BaseColumns._ID); mTitleIndex = data.getColumnIndexOrThrow(MediaColumns.TITLE); mArtistIndex = data.getColumnIndexOrThrow(AudioColumns.ARTIST); mAlbumIndex = data.getColumnIndexOrThrow(AudioColumns.ALBUM); } else if (getArguments() != null && Artists.CONTENT_TYPE.equals(getArguments().getString(MIME_TYPE))) { mTitleIndex = data.getColumnIndexOrThrow(MediaColumns.TITLE); // mArtistIndex is "line2" of the ListView mArtistIndex = data.getColumnIndexOrThrow(AudioColumns.ALBUM); } else if (getArguments() != null && Albums.CONTENT_TYPE.equals(getArguments().getString(MIME_TYPE))) { mMediaIdIndex = data.getColumnIndexOrThrow(BaseColumns._ID); mTitleIndex = data.getColumnIndexOrThrow(MediaColumns.TITLE); mArtistIndex = data.getColumnIndexOrThrow(AudioColumns.ARTIST); } else { mMediaIdIndex = data.getColumnIndexOrThrow(BaseColumns._ID); mTitleIndex = data.getColumnIndexOrThrow(MediaColumns.TITLE); mArtistIndex = data.getColumnIndexOrThrow(AudioColumns.ARTIST); mAlbumIndex = data.getColumnIndexOrThrow(AudioColumns.ALBUM); } mTrackAdapter.changeCursor(data); mListView.invalidateViews(); mCursor = data; }
/** * 从本地数据库中得到原图 * * @param cur */ private void getAlbumColumnData(Cursor cur) { if (cur.moveToFirst()) { int _id; String album; String albumArt; String albumKey; String artist; int numOfSongs; int _idColumn = cur.getColumnIndex(Albums._ID); int albumColumn = cur.getColumnIndex(Albums.ALBUM); int albumArtColumn = cur.getColumnIndex(Albums.ALBUM_ART); int albumKeyColumn = cur.getColumnIndex(Albums.ALBUM_KEY); int artistColumn = cur.getColumnIndex(Albums.ARTIST); int numOfSongsColumn = cur.getColumnIndex(Albums.NUMBER_OF_SONGS); do { // Get the field values _id = cur.getInt(_idColumn); album = cur.getString(albumColumn); albumArt = cur.getString(albumArtColumn); albumKey = cur.getString(albumKeyColumn); artist = cur.getString(artistColumn); numOfSongs = cur.getInt(numOfSongsColumn); // Do something with the values. Log.i(TAG, _id + " album:" + album + " albumArt:" + albumArt + "albumKey: " + albumKey + " artist: " + artist + " numOfSongs: " + numOfSongs + "---"); HashMap<String, String> hash = new HashMap<String, String>(); hash.put("_id", _id + ""); hash.put("album", album); hash.put("albumArt", albumArt); hash.put("albumKey", albumKey); hash.put("artist", artist); hash.put("numOfSongs", numOfSongs + ""); albumList.add(hash); } while (cur.moveToNext()); } }