/** * Used to fetch for the album art via Last.fm. * * @param context The {@link Context} to use. * @param album The name of the album in the profile the user is viewing. * @param artist The name of the album artist in the profile the user is viewing */ public void fetchAlbumPhoto(final Activity context, final String album, final String artist) { if (!TextUtils.isEmpty(album)) { mFetcher.removeFromCache(ImageFetcher.generateAlbumCacheKey(album, artist)); mFetcher.loadAlbumImage(artist, album, -1, mAlbumArt); } else { setDefault(context); } }
/** * Used to set the artist image in the artist profile. * * @param context The {@link Context} to use. * @param artist The name of the artist in the profile the user is viewing. */ public void setArtistPhoto(final Activity context, final String artist) { if (!TextUtils.isEmpty(artist)) { mFetcher.loadArtistImage(artist, mPhoto); } else { setDefault(context); } }
/** * Used to blur the artist image in the album profile. * * @param context The {@link Context} to use. * @param artist The artist nmae used to fetch the cached artist image. * @param album The album name used to fetch the album art in case the artist image is missing. */ public void blurPhoto(final Activity context, final String artist, final String album) { // FIXME: this should go into an AsyncTask // First check for the artist image Bitmap artistImage = mFetcher.getCachedBitmap(artist); // Second check for cached artwork if (artistImage == null) { artistImage = mFetcher.getCachedArtwork(album, artist); } // If all else, use the default image if (artistImage == null) { artistImage = BitmapFactory.decodeResource(getResources(), R.drawable.theme_preview); } final Bitmap blur = BitmapUtils.createBlurredBitmap(artistImage); mPhoto.setImageBitmap(blur); }
/** * Used to set the album art in the album profile. * * @param context The {@link Context} to use. * @param album The name of the album in the profile the user is viewing. */ public void setAlbumPhoto(final Activity context, final String album, final String artist) { if (!TextUtils.isEmpty(album)) { mAlbumArt.setVisibility(View.VISIBLE); mFetcher.loadAlbumImage( artist, album, MusicUtils.getIdForAlbum(context, album, artist), mAlbumArt); } else { setDefault(context); } }
/** * Used to set the header image for playlists and genres. * * @param context The {@link Context} to use. * @param profileName The key used to fetch the image. */ public void setPlaylistOrGenrePhoto(final Activity context, final String profileName) { if (!TextUtils.isEmpty(profileName)) { final Bitmap image = mFetcher.getCachedBitmap(profileName); if (image != null) { mPhoto.setImageBitmap(image); } else { setDefault(context); } } else { setDefault(context); } }
/** * Used to set the album art in the artist profile. * * @param context The {@link Context} to use. * @param artist The name of the artist in the profile the user is viewing. */ public void setArtistAlbumPhoto(final Activity context, final String artist) { final String lastAlbum = MusicUtils.getLastAlbumForArtist(context, artist); if (!TextUtils.isEmpty(lastAlbum)) { // Set the last album the artist played mFetcher.loadAlbumImage( artist, lastAlbum, MusicUtils.getIdForAlbum(context, lastAlbum, artist), mPhoto); // Play the album mPhoto.setOnClickListener( new OnClickListener() { @Override public void onClick(final View v) { final long[] albumList = MusicUtils.getSongListForAlbum( getContext(), MusicUtils.getIdForAlbum(context, lastAlbum, artist)); MusicUtils.playAll(getContext(), albumList, 0, false); } }); } else { setDefault(context); } }