当前位置: 首页>>代码示例>>Java>>正文


Java Request类代码示例

本文整理汇总了Java中com.bumptech.glide.request.Request的典型用法代码示例。如果您正苦于以下问题:Java Request类的具体用法?Java Request怎么用?Java Request使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Request类属于com.bumptech.glide.request包,在下文中一共展示了Request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testOnFrameReadyWithNullResourceDoesNotClearPreviousFrame

import com.bumptech.glide.request.Request; //导入依赖的package包/类
@Test
public void testOnFrameReadyWithNullResourceDoesNotClearPreviousFrame() {
  // Force the loader to create a real Handler by passing null.
  loader = createGifFrameLoader(null);

  DelayTarget previous = mock(DelayTarget.class);
  Request previousRequest = mock(Request.class);
  when(previous.getRequest()).thenReturn(previousRequest);
  when(previous.getResource()).thenReturn(Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888));

  DelayTarget current = mock(DelayTarget.class);
  when(current.getResource()).thenReturn(null);
  loader.onFrameReady(previous);
  loader.onFrameReady(current);

  verify(previousRequest, never()).clear();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:GifFrameLoaderTest.java

示例2: testOnFrameReadyClearsPreviousFrame

import com.bumptech.glide.request.Request; //导入依赖的package包/类
@Test
public void testOnFrameReadyClearsPreviousFrame() {
  // Force the loader to create a real Handler.
  loader = createGifFrameLoader(null);

  DelayTarget previous = mock(DelayTarget.class);
  Request previousRequest = mock(Request.class);
  when(previous.getRequest()).thenReturn(previousRequest);
  when(previous.getResource()).thenReturn(Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888));

  DelayTarget current = mock(DelayTarget.class);
  when(current.getResource()).thenReturn(Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565));
  loader.onFrameReady(previous);
  loader.onFrameReady(current);

  verify(requestManager).clear(eq(previous));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:GifFrameLoaderTest.java

示例3: clearRemoveAndMaybeRecycle

import com.bumptech.glide.request.Request; //导入依赖的package包/类
private boolean clearRemoveAndMaybeRecycle(@Nullable Request request, boolean isSafeToRecycle) {
   if (request == null) {
     // If the Request is null, the request is already cleared and we don't need to search further
     // for its owner.
    return true;
  }
  boolean isOwnedByUs = requests.remove(request);
  // Avoid short circuiting.
  isOwnedByUs = pendingRequests.remove(request) || isOwnedByUs;
  if (isOwnedByUs) {
    request.clear();
    if (isSafeToRecycle) {
      request.recycle();
    }
  }
  return isOwnedByUs;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:RequestTracker.java

示例4: untrackOrDelegate

import com.bumptech.glide.request.Request; //导入依赖的package包/类
private void untrackOrDelegate(Target<?> target) {
  boolean isOwnedByUs = untrack(target);
  // We'll end up here if the Target was cleared after the RequestManager that started the request
  // is destroyed. That can happen for at least two reasons:
  // 1. We call clear() on a background thread using something other than Application Context
  // RequestManager.
  // 2. The caller retains a reference to the RequestManager after the corresponding Activity or
  // Fragment is destroyed, starts a load with it, and then clears that load with a different
  // RequestManager. Callers seem especially likely to do this in retained Fragments (#2262).
  //
  // #1 is always an error. At best the caller is leaking memory briefly in something like an
  // AsyncTask. At worst the caller is leaking an Activity or Fragment for a sustained period of
  // time if they do something like reference the Activity RequestManager in a long lived
  // background thread or task.
  //
  // #2 is always an error. Callers shouldn't be starting new loads using RequestManagers after
  // the corresponding Activity or Fragment is destroyed because retaining any reference to the
  // RequestManager leaks memory. It's possible that there's some brief period of time during or
  // immediately after onDestroy where this is reasonable, but I can't think of why.
  if (!isOwnedByUs && !glide.removeFromManagers(target) && target.getRequest() != null) {
    Request request = target.getRequest();
    target.setRequest(null);
    request.clear();
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:RequestManager.java

示例5: removeFromManagers_afterRequestManagerRemoved_clearsRequest

import com.bumptech.glide.request.Request; //导入依赖的package包/类
@Test
public void removeFromManagers_afterRequestManagerRemoved_clearsRequest() {
  target = requestManager.load(mockUri("content://uri")).into(new SimpleTarget<Drawable>() {
    @Override
    public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
      // Do nothing.
    }
  });
  Request request = Preconditions.checkNotNull(target.getRequest());

  requestManager.onDestroy();
  requestManager.clear(target);

  assertThat(target.getRequest()).isNull();
  assertThat(request.isCancelled()).isTrue();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:GlideTest.java

示例6: runRequest

import com.bumptech.glide.request.Request; //导入依赖的package包/类
/**
 * Starts tracking the given request.
 */
public void runRequest(Request request) {
  requests.add(request);
  if (!isPaused) {
    request.begin();
  } else {
    pendingRequests.add(request);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:RequestTracker.java

示例7: clearRemoveAndRecycle

import com.bumptech.glide.request.Request; //导入依赖的package包/类
/**
 * Stops tracking the given request, clears, and recycles it, and returns {@code true} if the
 * request was removed or {@code false} if the request was not found.
 */
public boolean clearRemoveAndRecycle(Request request) {
  boolean isOwnedByUs =
      request != null && (requests.remove(request) || pendingRequests.remove(request));
  if (isOwnedByUs) {
    request.clear();
    request.recycle();
  }
  return isOwnedByUs;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:RequestTracker.java

示例8: pauseRequests

import com.bumptech.glide.request.Request; //导入依赖的package包/类
/**
 * Stops any in progress requests.
 */
public void pauseRequests() {
  isPaused = true;
  for (Request request : Util.getSnapshot(requests)) {
    if (request.isRunning()) {
      request.pause();
      pendingRequests.add(request);
    }
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:RequestTracker.java

示例9: resumeRequests

import com.bumptech.glide.request.Request; //导入依赖的package包/类
/**
 * Starts any not yet completed or failed requests.
 */
public void resumeRequests() {
  isPaused = false;
  for (Request request : Util.getSnapshot(requests)) {
    if (!request.isComplete() && !request.isCancelled() && !request.isRunning()) {
      request.begin();
    }
  }
  pendingRequests.clear();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:RequestTracker.java

示例10: clearRequests

import com.bumptech.glide.request.Request; //导入依赖的package包/类
/**
 * Cancels all requests and clears their resources.
 *
 * <p>After this call requests cannot be restarted.
 */
public void clearRequests() {
  for (Request request : Util.getSnapshot(requests)) {
    clearRemoveAndRecycle(request);
  }
  pendingRequests.clear();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:RequestTracker.java

示例11: restartRequests

import com.bumptech.glide.request.Request; //导入依赖的package包/类
/**
 * Restarts failed requests and cancels and restarts in progress requests.
 */
public void restartRequests() {
  for (Request request : Util.getSnapshot(requests)) {
    if (!request.isComplete() && !request.isCancelled()) {
      // Ensure the request will be restarted in onResume.
      request.pause();
      if (!isPaused) {
        request.begin();
      } else {
        pendingRequests.add(request);
      }
    }
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:RequestTracker.java

示例12: untrack

import com.bumptech.glide.request.Request; //导入依赖的package包/类
boolean untrack(Target<?> target) {
  Request request = target.getRequest();
  // If the Target doesn't have a request, it's already been cleared.
  if (request == null) {
    return true;
  }

  if (requestTracker.clearRemoveAndRecycle(request)) {
    targetTracker.untrack(target);
    target.setRequest(null);
    return true;
  } else {
    return false;
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:RequestManager.java

示例13: runTestFileDefaultLoader

import com.bumptech.glide.request.Request; //导入依赖的package包/类
private void runTestFileDefaultLoader() {
  File file = new File("fake");
  mockUri(Uri.fromFile(file));

  requestManager.load(file).into(target);
  requestManager.load(file).into(imageView);

  verify(target).onResourceReady(isA(BitmapDrawable.class), isA(Transition.class));
  verify(target).setRequest((Request) notNull());

  assertNotNull(imageView.getDrawable());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:GlideTest.java

示例14: testUrlDefaultLoader

import com.bumptech.glide.request.Request; //导入依赖的package包/类
@Test
public void testUrlDefaultLoader() throws MalformedURLException {
  URL url = new URL("http://www.google.com");

  requestManager.load(url).into(target);
  requestManager.load(url).into(imageView);

  verify(target).onResourceReady(isA(BitmapDrawable.class), isA(Transition.class));
  verify(target).setRequest((Request) notNull());

  assertNotNull(imageView.getDrawable());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:GlideTest.java

示例15: runTestUriDefaultLoader

import com.bumptech.glide.request.Request; //导入依赖的package包/类
private void runTestUriDefaultLoader() {
  Uri uri = Uri.parse("content://test/something");
  mockUri(uri);

  requestManager.load(uri).into(target);
  requestManager.load(uri).into(imageView);

  verify(target).onResourceReady(notNull(), isA(Transition.class));
  verify(target).setRequest((Request) notNull());

  assertNotNull(imageView.getDrawable());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:GlideTest.java


注:本文中的com.bumptech.glide.request.Request类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。