com.bumptech.glide.util.Util.assertBackgroundThread()方法的使用及代码示例

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

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

Util.assertBackgroundThread介绍

[英]Throws an java.lang.IllegalArgumentException if called on the main thread.
[中]抛出一个java。如果在主线程上调用lang.IllegalArgumentException。

代码示例

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

  1. /**
  2. * Clears disk cache.
  3. *
  4. * <p>
  5. * This method should always be called on a background thread, since it is a blocking call.
  6. * </p>
  7. */
  8. // Public API.
  9. @SuppressWarnings({"unused", "WeakerAccess"})
  10. public void clearDiskCache() {
  11. Util.assertBackgroundThread();
  12. engine.clearDiskCache();
  13. }

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

  1. private synchronized R doGet(Long timeoutMillis)
  2. throws ExecutionException, InterruptedException, TimeoutException {
  3. if (assertBackgroundThread && !isDone()) {
  4. Util.assertBackgroundThread();

代码示例来源:origin: guolindev/giffun

  1. /**
  2. * Clears disk cache.
  3. *
  4. * <p>
  5. * This method should always be called on a background thread, since it is a blocking call.
  6. * </p>
  7. */
  8. public void clearDiskCache() {
  9. Util.assertBackgroundThread();
  10. getEngine().clearDiskCache();
  11. }

代码示例来源:origin: guolindev/giffun

  1. private synchronized R doGet(Long timeoutMillis) throws ExecutionException, InterruptedException, TimeoutException {
  2. if (assertBackgroundThread) {
  3. Util.assertBackgroundThread();
  4. }
  5. if (isCancelled) {
  6. throw new CancellationException();
  7. } else if (exceptionReceived) {
  8. throw new ExecutionException(exception);
  9. } else if (resultReceived) {
  10. return resource;
  11. }
  12. if (timeoutMillis == null) {
  13. waiter.waitForTimeout(this, 0);
  14. } else if (timeoutMillis > 0) {
  15. waiter.waitForTimeout(this, timeoutMillis);
  16. }
  17. if (Thread.interrupted()) {
  18. throw new InterruptedException();
  19. } else if (exceptionReceived) {
  20. throw new ExecutionException(exception);
  21. } else if (isCancelled) {
  22. throw new CancellationException();
  23. } else if (!resultReceived) {
  24. throw new TimeoutException();
  25. }
  26. return resource;
  27. }

代码示例来源:origin: mozilla-tw/Rocket

  1. /**
  2. * Clears disk cache.
  3. *
  4. * <p>
  5. * This method should always be called on a background thread, since it is a blocking call.
  6. * </p>
  7. */
  8. @SuppressWarnings("unused") // Public API
  9. public void clearDiskCache() {
  10. Util.assertBackgroundThread();
  11. engine.clearDiskCache();
  12. }

代码示例来源:origin: mozilla-tw/Rocket

  1. private synchronized R doGet(Long timeoutMillis)
  2. throws ExecutionException, InterruptedException, TimeoutException {
  3. if (assertBackgroundThread && !isDone()) {
  4. Util.assertBackgroundThread();
  5. }
  6. if (isCancelled) {
  7. throw new CancellationException();
  8. } else if (loadFailed) {
  9. throw new ExecutionException(new IllegalStateException("Load failed"));
  10. } else if (resultReceived) {
  11. return resource;
  12. }
  13. if (timeoutMillis == null) {
  14. waiter.waitForTimeout(this, 0);
  15. } else if (timeoutMillis > 0) {
  16. waiter.waitForTimeout(this, timeoutMillis);
  17. }
  18. if (Thread.interrupted()) {
  19. throw new InterruptedException();
  20. } else if (loadFailed) {
  21. throw new ExecutionException(new IllegalStateException("Load failed"));
  22. } else if (isCancelled) {
  23. throw new CancellationException();
  24. } else if (!resultReceived) {
  25. throw new TimeoutException();
  26. }
  27. return resource;
  28. }

相关文章