本文整理汇总了Java中com.bumptech.glide.RequestBuilder类的典型用法代码示例。如果您正苦于以下问题:Java RequestBuilder类的具体用法?Java RequestBuilder怎么用?Java RequestBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RequestBuilder类属于com.bumptech.glide包,在下文中一共展示了RequestBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: thumbnail
import com.bumptech.glide.RequestBuilder; //导入依赖的package包/类
@Override
@CheckResult
@SafeVarargs
@SuppressWarnings("varargs")
public final GlideRequest<TranscodeType> thumbnail(@Nullable RequestBuilder<TranscodeType>... arg0) {
return (GlideRequest<TranscodeType>) super.thumbnail(arg0);
}
示例2: onCreate
import com.bumptech.glide.RequestBuilder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView giphyLogoView = (ImageView) findViewById(R.id.giphy_logo_view);
Glide.with(this)
.load(R.raw.large_giphy_logo)
.into(giphyLogoView);
RecyclerView gifList = (RecyclerView) findViewById(R.id.gif_list);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
gifList.setLayoutManager(layoutManager);
RequestBuilder<Drawable> gifItemRequest = Glide.with(this).asDrawable();
ViewPreloadSizeProvider<Api.GifResult> preloadSizeProvider =
new ViewPreloadSizeProvider<>();
adapter = new GifAdapter(this, gifItemRequest, preloadSizeProvider);
gifList.setAdapter(adapter);
RecyclerViewPreloader<Api.GifResult> preloader =
new RecyclerViewPreloader<>(Glide.with(this), adapter, preloadSizeProvider, 4);
gifList.addOnScrollListener(preloader);
}
示例3: setupUserAvatar
import com.bumptech.glide.RequestBuilder; //导入依赖的package包/类
private void setupUserAvatar(AppCompatImageView avatar, Me.ProfileImage image) {
int flag = CalendarUtils.festivalFlag();
if (2 == flag) {
avatar.setImageResource(R.mipmap.new_year_round);
} else if (1 == flag) {
avatar.setImageResource(R.mipmap.new_year_dog2);
} else {
if (null == image) {
avatar.setImageResource(R.mipmap.bg_dark_avatar_male_big_normal);
} else {
RequestBuilder<Bitmap> bitmapRequestBuilder = GlideApp.with(getActivity())
.asBitmap()
.load(image.large)
.error(R.mipmap.bg_dark_avatar_male_big_normal)
.placeholder(R.mipmap.bg_dark_avatar_male_big_normal)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.fallback(R.mipmap.bg_dark_avatar_male_big_normal);
bitmapRequestBuilder.into(avatar);
}
}
}
示例4: showImage
import com.bumptech.glide.RequestBuilder; //导入依赖的package包/类
public static void showImage(Activity activity, ImageView imageView, String image,
Drawable placeholder, boolean anim) {
RequestOptions requestOptions = RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.ALL);
RequestBuilder<Drawable> builder = Glide.with(activity)
.load(image);
if (placeholder != null) {
requestOptions.placeholder(placeholder); //设置占位图片
}
if (!anim) {
requestOptions.dontAnimate();
}
builder.apply(requestOptions);
builder.into(imageView);
}
示例5: loadImage
import com.bumptech.glide.RequestBuilder; //导入依赖的package包/类
@BindingAdapter({"url", "thumbUrl", "manager", "show"})
public static void loadImage(LargeImageView largeImageView, String url, @Nullable String thumbUrl, DownloadPreferencesManager manager, boolean show) {
if (!show || TextUtils.isEmpty(url)) {
return;
}
Context context = largeImageView.getContext();
RequestBuilder<File> builder = Glide.with(context)
.download(new ForcePassUrl(url));
//avatar signature
if (manager != null && Api.isAvatarUrl(url)) {
builder = builder.apply(new RequestOptions()
.signature(manager.getAvatarCacheInvalidationIntervalSignature()));
}
builder.into(new LargeImageViewTarget(largeImageView) {
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
if (thumbUrl != null) {
loadImage(largeImageView, thumbUrl, null, manager, show);
} else {
super.onLoadFailed(errorDrawable);
}
}
});
}
示例6: startImageGetterViewTarget
import com.bumptech.glide.RequestBuilder; //导入依赖的package包/类
private void startImageGetterViewTarget(RequestBuilder<Drawable> glideRequestBuilder,
ImageGetterViewTarget imageGetterViewTarget, boolean emoticon) {
Single.just(glideRequestBuilder)
.subscribeOn(AndroidSchedulers.mainThread())
.to(imageGetterScoper)
.subscribe(builder -> {
if (emoticon) {
imageGetterViewTarget.mDrawable.setWidthTargetSize(emoticonSize);
imageGetterViewTarget.mDrawable.setHeightTargetSize(emoticonSize);
} else {
//Big image scale to fit width
imageGetterViewTarget.mDrawable.setTriggerSize(200);
if (mTextView.getWidth() > 0) {
imageGetterViewTarget.mDrawable.setWidthTargetSize(mTextView.getWidth());
}
}
builder.into(imageGetterViewTarget);
}, L::report);
}
示例7: loadAsPath
import com.bumptech.glide.RequestBuilder; //导入依赖的package包/类
public void loadAsPath(final String path, final int width, final int height, final int maskId, final String ext) {
if (TextUtils.isEmpty(path)) {
loadAsResource(R.drawable.nim_image_default, maskId);
return;
}
setBlendDrawable(maskId);
RequestBuilder builder;
if (ImageUtil.isGif(ext)) {
builder = Glide.with(getContext().getApplicationContext()).asGif().load(new File(path));
} else {
RequestOptions options = new RequestOptions()
.override(width, height)
.fitCenter()
.placeholder(R.drawable.nim_image_default)
.error(R.drawable.nim_image_default);
builder = Glide.with(getContext().getApplicationContext())
.asBitmap()
.apply(options)
.load(new File(path))
;
}
builder.into(this);
}
示例8: getPreloadRequestBuilder
import com.bumptech.glide.RequestBuilder; //导入依赖的package包/类
@Override
@Nullable
public RequestBuilder getPreloadRequestBuilder(IconDataParcelable iconData) {
GlideRequest request;
if(!showThumbs) {
request = GlideApp.with(fragment).asDrawable().fitCenter().load(iconData.image);
} else {
if (iconData.type == IconDataParcelable.IMAGE_FROMFILE) {
request = GlideApp.with(fragment).asDrawable().centerCrop().load(iconData.path).fallback(iconData.image);
} else {
request = GlideApp.with(fragment).asDrawable().centerCrop().load(iconData.image);
}
}
return request;
}
示例9: loadFlickrThumb
import com.bumptech.glide.RequestBuilder; //导入依赖的package包/类
public static void loadFlickrThumb(Photo photo, ImageView image) {
final RequestOptions options = new RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.DATA)
.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
.dontTransform();
final RequestBuilder<Drawable> thumbRequest = Glide.with(image)
.load(photo.getThumbnailUrl())
.apply(options)
.transition(DrawableTransitionOptions.with(TRANSITION_FACTORY));
Glide.with(image).load(photo.getMediumUrl())
.apply(options)
.thumbnail(thumbRequest)
.into(image);
}
示例10: loadFlickrFull
import com.bumptech.glide.RequestBuilder; //导入依赖的package包/类
public static void loadFlickrFull(Photo photo, ImageView image, LoadingListener listener) {
final String photoUrl = photo.getLargeSize() == null
? photo.getMediumUrl() : photo.getLargeUrl();
final RequestOptions options = new RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.DATA)
.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
.dontTransform();
final RequestBuilder<Drawable> thumbRequest = Glide.with(image)
.load(photo.getThumbnailUrl())
.apply(options);
Glide.with(image)
.load(photoUrl)
.apply(new RequestOptions().apply(options).placeholder(image.getDrawable()))
.thumbnail(thumbRequest)
.listener(new RequestListenerWrapper<>(listener))
.into(image);
}
示例11: loadFull
import com.bumptech.glide.RequestBuilder; //导入依赖的package包/类
/**
* Loads thumbnail and then replaces it with full image.
*/
public static void loadFull(ImageView image, int imageId, int thumbId) {
// We don't want Glide to crop or resize our image
final RequestOptions options = new RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.NONE)
.override(Target.SIZE_ORIGINAL)
.dontTransform();
final RequestBuilder<Drawable> thumbRequest = Glide.with(image)
.load(thumbId)
.apply(options);
Glide.with(image)
.load(imageId)
.apply(options)
.thumbnail(thumbRequest)
.into(image);
}
示例12: getPreloadRequestBuilder
import com.bumptech.glide.RequestBuilder; //导入依赖的package包/类
@Override
public RequestBuilder<Drawable> getPreloadRequestBuilder(MediaStoreData item) {
MediaStoreSignature signature =
new MediaStoreSignature(item.mimeType, item.dateModified, item.orientation);
return requestBuilder
.clone()
.signature(signature)
.load(item.uri);
}
示例13: getPreloadRequestBuilder
import com.bumptech.glide.RequestBuilder; //导入依赖的package包/类
@Override
public RequestBuilder<Drawable> getPreloadRequestBuilder(Api.GifResult item) {
return requestBuilder.load(item);
}
示例14: getRequestBuilder
import com.bumptech.glide.RequestBuilder; //导入依赖的package包/类
private static RequestBuilder<Bitmap> getRequestBuilder(
RequestManager requestManager, int width, int height) {
return requestManager
.asBitmap()
.apply(
diskCacheStrategyOf(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.override(width, height));
}
示例15: setUp
import com.bumptech.glide.RequestBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(handler.obtainMessage(anyInt(), isA(DelayTarget.class))).thenReturn(mock(Message.class));
firstFrame = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
ByteBuffer byteBuffer = ByteBuffer.allocate(10);
when(gifDecoder.getData()).thenReturn(byteBuffer);
requestBuilder = mock(RequestBuilder.class, new ReturnsSelfAnswer());
loader = createGifFrameLoader(handler);
}