use of com.bumptech.glide.BitmapRequestBuilder in project iosched by google.
the class ImageLoader method loadImage.
/**
* Load an image from a url into an ImageView using the default placeholder
* drawable if available.
* @param url The web URL of an image.
* @param imageView The target ImageView to load the image into.
* @param requestListener A listener to monitor the request result.
* @param placeholderOverride A drawable to use as a placeholder for this specific image.
* If this parameter is present, {@link #mPlaceHolderResId}
* if ignored for this request.
*/
public void loadImage(String url, ImageView imageView, RequestListener<String, Bitmap> requestListener, Drawable placeholderOverride, boolean crop) {
BitmapRequestBuilder request = beginImageLoad(url, requestListener, crop).animate(R.anim.image_fade_in);
if (placeholderOverride != null) {
request.placeholder(placeholderOverride);
} else if (mPlaceHolderResId != -1) {
request.placeholder(mPlaceHolderResId);
}
request.into(imageView);
}
use of com.bumptech.glide.BitmapRequestBuilder in project Phonograph by kabouzeid.
the class MusicService method updateMediaSessionMetaData.
private void updateMediaSessionMetaData() {
final Song song = getCurrentSong();
if (song.id == -1) {
mediaSession.setMetadata(null);
return;
}
final MediaMetadataCompat.Builder metaData = new MediaMetadataCompat.Builder().putString(MediaMetadataCompat.METADATA_KEY_ARTIST, song.artistName).putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, song.artistName).putString(MediaMetadataCompat.METADATA_KEY_ALBUM, song.albumName).putString(MediaMetadataCompat.METADATA_KEY_TITLE, song.title).putLong(MediaMetadataCompat.METADATA_KEY_DURATION, song.duration).putLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER, getPosition() + 1).putLong(MediaMetadataCompat.METADATA_KEY_YEAR, song.year).putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
metaData.putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getPlayingQueue().size());
}
if (PreferenceUtil.getInstance(this).albumArtOnLockscreen()) {
final Point screenSize = Util.getScreenSize(MusicService.this);
final BitmapRequestBuilder<?, Bitmap> request = SongGlideRequest.Builder.from(Glide.with(MusicService.this), song).checkIgnoreMediaStore(MusicService.this).asBitmap().build();
if (PreferenceUtil.getInstance(this).blurredAlbumArt()) {
request.transform(new BlurTransformation.Builder(MusicService.this).build());
}
runOnUiThread(new Runnable() {
@Override
public void run() {
request.into(new SimpleTarget<Bitmap>(screenSize.x, screenSize.y) {
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
mediaSession.setMetadata(metaData.build());
}
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
metaData.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, copy(resource));
mediaSession.setMetadata(metaData.build());
}
});
}
});
} else {
mediaSession.setMetadata(metaData.build());
}
}
Aggregations