本文整理汇总了Java中com.bumptech.glide.GenericRequestBuilder类的典型用法代码示例。如果您正苦于以下问题:Java GenericRequestBuilder类的具体用法?Java GenericRequestBuilder怎么用?Java GenericRequestBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenericRequestBuilder类属于com.bumptech.glide包,在下文中一共展示了GenericRequestBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: displayImage
import com.bumptech.glide.GenericRequestBuilder; //导入依赖的package包/类
public void displayImage(final String uri, final ImageView imageView, int defaultIcon, final DisplayListener listener) {
GenericRequestBuilder req = Glide.with(imageView.getContext().getApplicationContext()).load(uri).asBitmap().diskCacheStrategy(mDiskCacheStrategy);
if (defaultIcon > 0) {
req.placeholder(defaultIcon);
}
req.into(new BitmapImageViewTarget(imageView) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
super.onResourceReady(resource, glideAnimation);
if (listener != null) {
listener.onLoadCompleted(uri, imageView, resource);
}
}
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
if (listener != null) {
listener.onLoadFailed(uri, imageView);
}
}
});
}
示例2: getRequestBuilder
import com.bumptech.glide.GenericRequestBuilder; //导入依赖的package包/类
private static GenericRequestBuilder<GifDecoder, GifDecoder, Bitmap, Bitmap> getRequestBuilder(Context context,
GifDecoder gifDecoder, int width, int height, BitmapPool bitmapPool) {
GifFrameResourceDecoder frameResourceDecoder = new GifFrameResourceDecoder(bitmapPool);
GifFrameModelLoader frameLoader = new GifFrameModelLoader();
Encoder<GifDecoder> sourceEncoder = NullEncoder.get();
return Glide.with(context)
.using(frameLoader, GifDecoder.class)
.load(gifDecoder)
.as(Bitmap.class)
.sourceEncoder(sourceEncoder)
.decoder(frameResourceDecoder)
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.override(width, height);
}
示例3: buildThumbnailGlideRequest
import com.bumptech.glide.GenericRequestBuilder; //导入依赖的package包/类
private GenericRequestBuilder buildThumbnailGlideRequest(@NonNull Slide slide, @NonNull MasterSecret masterSecret) {
@SuppressWarnings("ConstantConditions")
DrawableRequestBuilder<DecryptableUri> builder = Glide.with(getContext())
.load(new DecryptableUri(masterSecret, slide.getThumbnailUri()))
.diskCacheStrategy(DiskCacheStrategy.NONE)
.crossFade()
.transform(new RoundedCorners(getContext(), true, radius, backgroundColorHint));
if (slide.isInProgress()) return builder;
else return builder.error(R.drawable.ic_missing_thumbnail_picture);
}
示例4: buildPlaceholderGlideRequest
import com.bumptech.glide.GenericRequestBuilder; //导入依赖的package包/类
private GenericRequestBuilder buildPlaceholderGlideRequest(Slide slide) {
return Glide.with(getContext())
.load(slide.getPlaceholderRes(getContext().getTheme()))
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.NONE)
.fitCenter();
}
示例5: applyDimens
import com.bumptech.glide.GenericRequestBuilder; //导入依赖的package包/类
public static GenericRequestBuilder applyDimens(@NonNull GenericRequestBuilder requestBuilder,
@NonNull GlideTaskParams payload) {
final Media media = payload.getMedia();
if (media != null) {
requestBuilder.override(media.getWidth(), media.getHeight());
}
return requestBuilder;
}
示例6: load
import com.bumptech.glide.GenericRequestBuilder; //导入依赖的package包/类
public static <T extends ImageView> void load(@NonNull final GenericRequestBuilder requestBuilder,
@NonNull final GlideTaskParams<T> payload) {
if (payload.isThumbnail()) {
requestBuilder.thumbnail(payload.getThumbnailMultiplier());
}
requestBuilder.placeholder(payload.getPlaceholder())
.into(new GlideDrawableImageViewTarget(payload.getTarget()) {
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
if (payload.getCurrentRetry() < payload.getMaxRetry()) {
payload.incrementCurrentRetry();
load(requestBuilder, payload);
} else {
super.onLoadFailed(e, errorDrawable);
payload.getListener().failure(payload.getTarget(), errorDrawable);
}
}
@Override
public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
super.onResourceReady(resource, animation);
payload.getListener().success(payload.getTarget(), resource);
}
});
}
示例7: getDrawable
import com.bumptech.glide.GenericRequestBuilder; //导入依赖的package包/类
@Override public Drawable getDrawable(@NonNull String url) {
final UrlDrawable urlDrawable = new UrlDrawable();
if (container != null && container.get() != null) {
Context context = container.get().getContext();
final GenericRequestBuilder load = Glide.with(context)
.load(url)
.dontAnimate();
final GlideDrawableTarget target = new GlideDrawableTarget(urlDrawable, container, width);
load.into(target);
cachedTargets.add(target);
}
return urlDrawable;
}
示例8: provideGifRequestBuilder
import com.bumptech.glide.GenericRequestBuilder; //导入依赖的package包/类
@Singleton
@Provides
GenericRequestBuilder<Media, InputStream, byte[], GifDrawable> provideGifRequestBuilder(
RequestManager requestManager) {
return requestManager.using(new MediaLoader(mView), InputStream.class)
.from(Media.class)
.as(byte[].class)
.transcode(new GifDrawableBytesTranscoder(), GifDrawable.class)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.decoder(new StreamByteArrayResourceDecoder())
.sourceEncoder(new StreamEncoder())
.cacheDecoder(new FileToStreamDecoder<>(new StreamByteArrayResourceDecoder()));
}
示例9: create
import com.bumptech.glide.GenericRequestBuilder; //导入依赖的package包/类
public static GenericRequestBuilder<Uri, InputStream, SVG, PictureDrawable> create(Context context, Drawable placeholder) {
return Glide.with(context.getApplicationContext())
.using(Glide.buildStreamModelLoader(Uri.class, context), InputStream.class)
.from(Uri.class)
.as(SVG.class)
.transcode(new SvgDrawableTranscoder(), PictureDrawable.class)
.sourceEncoder(new StreamEncoder())
.cacheDecoder(new FileToStreamDecoder<>(new SvgDecoder()))
.decoder(new SvgDecoder())
.placeholder(placeholder)
.listener(new SvgSoftwareLayerSetter());
}
示例10: buildGlideRequest
import com.bumptech.glide.GenericRequestBuilder; //导入依赖的package包/类
private GenericRequestBuilder buildGlideRequest(@NonNull Slide slide,
@Nullable MasterSecret masterSecret)
{
final GenericRequestBuilder builder;
if (slide.getPart().isPendingPush()) {
builder = buildPendingGlideRequest(slide);
} else if (slide.getThumbnailUri() != null) {
builder = buildThumbnailGlideRequest(slide, masterSecret);
} else {
builder = buildPlaceholderGlideRequest(slide);
}
return builder.error(R.drawable.ic_missing_thumbnail_picture);
}
示例11: buildThumbnailGlideRequest
import com.bumptech.glide.GenericRequestBuilder; //导入依赖的package包/类
private GenericRequestBuilder buildThumbnailGlideRequest(Slide slide, MasterSecret masterSecret) {
final GenericRequestBuilder builder;
if (slide.isDraft()) builder = buildDraftGlideRequest(slide);
else builder = buildEncryptedPartGlideRequest(slide, masterSecret);
return builder;
}
示例12: buildEncryptedPartGlideRequest
import com.bumptech.glide.GenericRequestBuilder; //导入依赖的package包/类
private GenericRequestBuilder buildEncryptedPartGlideRequest(Slide slide, MasterSecret masterSecret) {
if (masterSecret == null) {
throw new IllegalStateException("null MasterSecret when loading non-draft thumbnail");
}
return Glide.with(getContext()).load(new DecryptableUri(masterSecret, slide.getThumbnailUri()))
.transform(new ThumbnailTransform(getContext()));
}
示例13: buildThumbnailGlideRequest
import com.bumptech.glide.GenericRequestBuilder; //导入依赖的package包/类
private GenericRequestBuilder buildThumbnailGlideRequest(@NonNull Slide slide, @NonNull MasterSecret masterSecret) {
@SuppressWarnings("ConstantConditions")
DrawableRequestBuilder<DecryptableUri> builder = Glide.with(getContext()).load(new DecryptableUri(masterSecret, slide.getThumbnailUri()))
.crossFade()
.transform(new RoundedCorners(getContext(), true, radius, backgroundColorHint));
if (slide.isInProgress()) return builder;
else return builder.error(R.drawable.ic_missing_thumbnail_picture);
}
示例14: provideGifRequestBuilder
import com.bumptech.glide.GenericRequestBuilder; //导入依赖的package包/类
@Singleton
@Provides
GenericRequestBuilder<GlideUrl, InputStream, byte[], GifDrawable> provideGifRequestBuilder(
RequestManager requestManager, OkHttpClient okHttpClient) {
return requestManager.using(new OkHttpUrlLoader(okHttpClient), InputStream.class)
.from(GlideUrl.class)
.as(byte[].class)
.transcode(new GifDrawableBytesTranscoder(), GifDrawable.class)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.decoder(new StreamByteArrayResourceDecoder())
.sourceEncoder(new StreamEncoder())
.cacheDecoder(new FileToStreamDecoder<>(new StreamByteArrayResourceDecoder()));
}
示例15: getHeroImage
import com.bumptech.glide.GenericRequestBuilder; //导入依赖的package包/类
@Bindable
public GenericRequestBuilder getHeroImage() {
if (mLfmReference != null) {
Image hero = mLfmReference.getImageBySize(Image.Size.MEGA);
if (hero != null) {
return Glide.with(getContext())
.load(hero.getUrl())
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.centerCrop()
.animate(android.R.anim.fade_in);
}
}
return null;
}