use of com.bumptech.glide.request.target.Target in project glide by bumptech.
the class GlideTest method setUp.
@Before
public void setUp() throws Exception {
Glide.tearDown();
RobolectricPackageManager pm = RuntimeEnvironment.getRobolectricPackageManager();
ApplicationInfo info = pm.getApplicationInfo(RuntimeEnvironment.application.getPackageName(), 0);
info.metaData = new Bundle();
info.metaData.putString(SetupModule.class.getName(), "GlideModule");
// Ensure that target's size ready callback will be called synchronously.
target = mock(Target.class);
imageView = new ImageView(RuntimeEnvironment.application);
imageView.setLayoutParams(new ViewGroup.LayoutParams(100, 100));
doAnswer(new CallSizeReady()).when(target).getSize(isA(SizeReadyCallback.class));
Handler bgHandler = mock(Handler.class);
when(bgHandler.post(isA(Runnable.class))).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
Runnable runnable = (Runnable) invocation.getArguments()[0];
runnable.run();
return true;
}
});
Lifecycle lifecycle = mock(Lifecycle.class);
RequestManagerTreeNode treeNode = mock(RequestManagerTreeNode.class);
requestManager = new RequestManager(Glide.get(getContext()), lifecycle, treeNode);
requestManager.resumeRequests();
}
use of com.bumptech.glide.request.target.Target in project Douya by DreaminginCodeZH.
the class ImageUtils method loadNavigationHeaderAvatar.
public static void loadNavigationHeaderAvatar(final ImageView view, final String url) {
Context context = view.getContext();
int size = context.getResources().getDimensionPixelSize(R.dimen.navigation_header_avatar_size);
Glide.with(context).load(url).placeholder(R.drawable.avatar_icon_white_inactive_64dp).override(size, size).diskCacheStrategy(DiskCacheStrategy.ALL).dontAnimate().dontTransform().listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
(e != null ? e : new NullPointerException()).printStackTrace();
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
view.setTag(url);
return false;
}
}).into(view);
}
use of com.bumptech.glide.request.target.Target in project CloudReader by youlookwhat.
the class SlideShadeViewActivity method setData.
/**
* 加载titlebar背景
*/
private void setData() {
if (subjectsBean != null) {
// 高斯模糊背景 原来 参数:12,5 23,4
Glide.with(this).load(subjectsBean.getImages().getLarge()).error(R.drawable.stackblur_default).bitmapTransform(new BlurTransformation(this, 23, 4)).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
binding.titleToolBar.setBackgroundColor(Color.TRANSPARENT);
binding.ivTitleHeadBg.setImageAlpha(0);
binding.ivTitleHeadBg.setVisibility(View.VISIBLE);
return false;
}
}).into(binding.ivTitleHeadBg);
}
}
use of com.bumptech.glide.request.target.Target in project CloudReader by youlookwhat.
the class TestActivity method setData.
private void setData() {
if (subjectsBean != null) {
// 高斯模糊背景
Glide.with(this).load(subjectsBean.getImages().getLarge()).error(R.drawable.stackblur_default).bitmapTransform(new BlurTransformation(this, 12, 5)).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
mToolbar.setBackgroundColor(Color.TRANSPARENT);
binding.ivTitleBg.setImageAlpha(0);
binding.ivTitleBg.setVisibility(View.VISIBLE);
return false;
}
}).into(binding.ivTitleBg);
}
}
use of com.bumptech.glide.request.target.Target in project BBS-Android by bdpqchen.
the class GlideImageGeter method getDrawable.
@Override
public Drawable getDrawable(String url) {
final UrlDrawable urlDrawable = new UrlDrawable();
GenericRequestBuilder load;
final Target target;
if (isGif(url)) {
load = Glide.with(mContext).load(url).asGif();
target = new GifTarget(urlDrawable);
} else {
load = Glide.with(mContext).load(url).asBitmap();
target = new BitmapTarget(urlDrawable);
}
targets.add(target);
load.into(target);
return urlDrawable;
}
Aggregations