com.bumptech.glide.BitmapRequestBuilder Java Examples

The following examples show how to use com.bumptech.glide.BitmapRequestBuilder. 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: GirlAdapter.java    From GankGirl with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    GankBean gankBean = mData.get(position);
    BitmapRequestBuilder<String, Bitmap> requestBuilder = Glide.with(mContext)
            .load(gankBean.url)
            .asBitmap()
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .transform(new GlideRoundTransform(mContext, 4))
            .animate(R.anim.image_alpha_in)
            .error(R.color.accent);
    requestBuilder.into(new BitmapImageViewTarget(holder.ivGirlImg){
        @Override
        protected void setResource(Bitmap resource) {
            holder.ivGirlImg.setOriginalSize(resource.getWidth(), resource.getHeight());
            holder.ivGirlImg.setImageBitmap(resource);
        }
    });
}
 
Example #2
Source File: ArtistGlideRequest.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public BitmapRequestBuilder<?, BitmapPaletteWrapper> build() {
    //noinspection unchecked
    return createBaseRequest(builder.requestManager, builder.artist, builder.noCustomImage, builder.forceDownload)
            .asBitmap()
            .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class)
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .priority(Priority.LOW)
            .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .signature(createSignature(builder.artist));
}
 
Example #3
Source File: ImageLoader.java    From v2ex with Apache License 2.0 5 votes vote down vote up
public BitmapRequestBuilder beginImageLoad(String url,
        RequestListener<String, Bitmap> requestListener, boolean crop) {
    return requestManager.load(url)
            .asBitmap()
            .listener(requestListener)
            .transform(crop ? mCenterCrop : mFitCenter);
}
 
Example #4
Source File: ImageLoader.java    From v2ex with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #5
Source File: ArtistGlideRequest.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
public BitmapRequestBuilder<?, BitmapPaletteWrapper> build() {
    //noinspection unchecked
    return createBaseRequest(builder.requestManager, builder.artist, builder.noCustomImage)
            .asBitmap()
            .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class)
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .priority(Priority.LOW)
            .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .signature(createSignature(builder.artist));
}
 
Example #6
Source File: ArtistGlideRequest.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
public BitmapRequestBuilder<?, Bitmap> build() {
    //noinspection unchecked
    return createBaseRequest(builder.requestManager, builder.artist, builder.noCustomImage)
            .asBitmap()
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .priority(Priority.LOW)
            .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .signature(createSignature(builder.artist));
}
 
Example #7
Source File: SongGlideRequest.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
public BitmapRequestBuilder<?, BitmapPaletteWrapper> build() {
    //noinspection unchecked
    return createBaseRequest(builder.requestManager, builder.song, builder.ignoreMediaStore)
            .asBitmap()
            .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class)
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .signature(createSignature(builder.song));
}
 
Example #8
Source File: SongGlideRequest.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
public BitmapRequestBuilder<?, Bitmap> build() {
    //noinspection unchecked
    return createBaseRequest(builder.requestManager, builder.song, builder.ignoreMediaStore)
            .asBitmap()
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .signature(createSignature(builder.song));
}
 
Example #9
Source File: ImageLoader.java    From RetailStore with Apache License 2.0 5 votes vote down vote up
public BitmapRequestBuilder beginImageLoad(String url,
        RequestListener<String, Bitmap> requestListener, boolean crop) {
    if (crop){
        return mGlideModelRequest.load(url)
                .listener(requestListener)
                .transform(mCenterCrop);
    } else {
        return mGlideModelRequest.load(url)
                .listener(requestListener);
    }
}
 
Example #10
Source File: ImageLoader.java    From RetailStore with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #11
Source File: SongGlideRequest.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
public BitmapRequestBuilder<?, Bitmap> build() {
    //noinspection unchecked
    return createBaseRequest(builder.requestManager, builder.song, builder.ignoreMediaStore)
            .asBitmap()
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .signature(createSignature(builder.song));
}
 
Example #12
Source File: ArtistGlideRequest.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public BitmapRequestBuilder<?, Bitmap> build() {
    //noinspection unchecked
    return createBaseRequest(builder.requestManager, builder.artist, builder.noCustomImage, builder.forceDownload)
            .asBitmap()
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .priority(Priority.LOW)
            .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .signature(createSignature(builder.artist));
}
 
Example #13
Source File: SongGlideRequest.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public BitmapRequestBuilder<?, BitmapPaletteWrapper> build() {
    //noinspection unchecked
    return createBaseRequest(builder.requestManager, builder.song, builder.ignoreMediaStore)
            .asBitmap()
            .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class)
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .signature(createSignature(builder.song));
}
 
Example #14
Source File: SongGlideRequest.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public BitmapRequestBuilder<?, Bitmap> build() {
    //noinspection unchecked
    return createBaseRequest(builder.requestManager, builder.song, builder.ignoreMediaStore)
            .asBitmap()
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .signature(createSignature(builder.song));
}
 
Example #15
Source File: SongGlideRequest.java    From Orin with GNU General Public License v3.0 5 votes vote down vote up
public BitmapRequestBuilder<?, BitmapPaletteWrapper> build() {
    //noinspection unchecked
    return createBaseRequest(builder.requestManager, builder.song, builder.ignoreMediaStore)
            .asBitmap()
            .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class)
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .signature(createSignature(builder.song));
}
 
Example #16
Source File: SongGlideRequest.java    From Orin with GNU General Public License v3.0 5 votes vote down vote up
public BitmapRequestBuilder<?, Bitmap> build() {
    //noinspection unchecked
    return createBaseRequest(builder.requestManager, builder.song, builder.ignoreMediaStore)
            .asBitmap()
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .signature(createSignature(builder.song));
}
 
Example #17
Source File: ArtistGlideRequest.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
public BitmapRequestBuilder<?, BitmapPaletteWrapper> build() {
    //noinspection unchecked
    return createBaseRequest(builder.requestManager, builder.artist, builder.noCustomImage)
            .asBitmap()
            .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class)
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .priority(Priority.LOW)
            .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .signature(createSignature(builder.artist));
}
 
Example #18
Source File: ArtistGlideRequest.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
public BitmapRequestBuilder<?, Bitmap> build() {
    //noinspection unchecked
    return createBaseRequest(builder.requestManager, builder.artist, builder.noCustomImage)
            .asBitmap()
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .priority(Priority.LOW)
            .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .signature(createSignature(builder.artist));
}
 
Example #19
Source File: SongGlideRequest.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
public BitmapRequestBuilder<?, BitmapPaletteWrapper> build() {
    //noinspection unchecked
    return createBaseRequest(builder.requestManager, builder.song, builder.ignoreMediaStore)
            .asBitmap()
            .transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class)
            .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
            .error(DEFAULT_ERROR_IMAGE)
            .animate(DEFAULT_ANIMATION)
            .signature(createSignature(builder.song));
}
 
Example #20
Source File: MusicService.java    From RetroMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
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());
    }
}
 
Example #21
Source File: MusicService.java    From Orin with GNU General Public License v3.0 4 votes vote down vote up
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());
    }
}
 
Example #22
Source File: MusicService.java    From Music-Player with GNU General Public License v3.0 4 votes vote down vote up
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());
    }
}
 
Example #23
Source File: MusicService.java    From Phonograph with GNU General Public License v3.0 4 votes vote down vote up
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());
    }
}