com.bumptech.glide.request.target.ViewTarget.getRequest()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中com.bumptech.glide.request.target.ViewTarget.getRequest()方法的一些代码示例,展示了ViewTarget.getRequest()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ViewTarget.getRequest()方法的具体详情如下:
包路径:com.bumptech.glide.request.target.ViewTarget
类名称:ViewTarget
方法名:getRequest

ViewTarget.getRequest介绍

[英]Returns any stored request using android.view.View#getTag().

For Glide to function correctly, Glide must be the only thing that calls View#setTag(Object). If the tag is cleared or put to another object type, Glide will not be able to retrieve and cancel previous loads which will not only prevent Glide from reusing resource, but will also result in incorrect images being loaded and lots of flashing of images in lists. As a result, this will throw an java.lang.IllegalArgumentException if android.view.View#getTag()} returns a non null object that is not an com.bumptech.glide.request.Request.
[中]使用android返回任何存储的请求。看法查看#getTag()。
为了让Glide正常工作,Glide必须是唯一调用View#setTag(Object)的东西。如果清除标记或将其放入另一个对象类型,Glide将无法检索和取消以前的加载,这不仅会阻止Glide重用资源,还会导致加载错误的图像和列表中大量图像的闪烁。因此,这将抛出一个java。如果是android,则为lang.IllegalArgumentException。看法View#getTag()}返回一个非空对象,该对象不是com。邦普泰克。滑行要求要求

代码示例

代码示例来源:origin: bumptech/glide

@SuppressWarnings("WeakerAccess")
@Synthetic void pauseMyRequest() {
 Request request = getRequest();
 // If the Request were cleared by the developer, it would be null here. The only way it's
 // present is if the developer hasn't previously cleared this Target.
 if (request != null) {
  isClearedByUs = true;
  request.clear();
  isClearedByUs = false;
 }
}

代码示例来源:origin: bumptech/glide

@Test(expected = IllegalArgumentException.class)
public void testThrowsIfViewTagIsNotRequestObject() {
 view.setTag(new Object());
 target.getRequest();
}

代码示例来源:origin: bumptech/glide

@SuppressWarnings("WeakerAccess")
@Synthetic void resumeMyRequest() {
 Request request = getRequest();
 if (request != null && request.isCleared()) {
  request.begin();
 }
}

代码示例来源:origin: bumptech/glide

@Test
public void testReturnsNullFromGetRequestIfNoRequestSet() {
 assertNull(target.getRequest());
}

代码示例来源:origin: bumptech/glide

@Test
public void testCanSetAndRetrieveRequest() {
 target.setRequest(request);
 assertEquals(request, target.getRequest());
}

代码示例来源:origin: bumptech/glide

@Test
public void testRetrievesRequestFromPreviousTargetForView() {
 target.setRequest(request);
 ViewTarget<View, Object> second = new TestViewTarget(view);
 assertEquals(request, second.getRequest());
}

相关文章