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

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

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

Util.getSnapshot介绍

[英]Returns a copy of the given list that is safe to iterate over and perform actions that may modify the original list.

See #303, #375, #322, #2262.
[中]返回给定列表的副本,可以安全地迭代并执行可能修改原始列表的操作。
参见#303、#375、#322、#2262。

代码示例

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

  1. @NonNull
  2. public List<Target<?>> getAll() {
  3. return Util.getSnapshot(targets);
  4. }

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

  1. @Override
  2. public void onDestroy() {
  3. for (Target<?> target : Util.getSnapshot(targets)) {
  4. target.onDestroy();
  5. }
  6. }

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

  1. @Override
  2. public void onStart() {
  3. for (Target<?> target : Util.getSnapshot(targets)) {
  4. target.onStart();
  5. }
  6. }

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

  1. void onStop() {
  2. isStarted = false;
  3. for (LifecycleListener lifecycleListener : Util.getSnapshot(lifecycleListeners)) {
  4. lifecycleListener.onStop();
  5. }
  6. }

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

  1. @Override
  2. public void onStop() {
  3. for (Target<?> target : Util.getSnapshot(targets)) {
  4. target.onStop();
  5. }
  6. }

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

  1. void onStart() {
  2. isStarted = true;
  3. for (LifecycleListener lifecycleListener : Util.getSnapshot(lifecycleListeners)) {
  4. lifecycleListener.onStart();
  5. }
  6. }

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

  1. void onDestroy() {
  2. isDestroyed = true;
  3. for (LifecycleListener lifecycleListener : Util.getSnapshot(lifecycleListeners)) {
  4. lifecycleListener.onDestroy();
  5. }
  6. }
  7. }

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

  1. /**
  2. * Cancels all requests and clears their resources.
  3. *
  4. * <p>After this call requests cannot be restarted.
  5. */
  6. public void clearRequests() {
  7. for (Request request : Util.getSnapshot(requests)) {
  8. // It's unsafe to recycle the Request here because we don't know who might else have a
  9. // reference to it.
  10. clearRemoveAndMaybeRecycle(request, /*isSafeToRecycle=*/ false);
  11. }
  12. pendingRequests.clear();
  13. }

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

  1. /**
  2. * Stops any in progress requests.
  3. */
  4. public void pauseRequests() {
  5. isPaused = true;
  6. for (Request request : Util.getSnapshot(requests)) {
  7. if (request.isRunning()) {
  8. request.clear();
  9. pendingRequests.add(request);
  10. }
  11. }
  12. }

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

  1. /** Stops any in progress requests and releases bitmaps associated with completed requests. */
  2. public void pauseAllRequests() {
  3. isPaused = true;
  4. for (Request request : Util.getSnapshot(requests)) {
  5. if (request.isRunning() || request.isComplete()) {
  6. request.clear();
  7. pendingRequests.add(request);
  8. }
  9. }
  10. }

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

  1. /**
  2. * Starts any not yet completed or failed requests.
  3. */
  4. public void resumeRequests() {
  5. isPaused = false;
  6. for (Request request : Util.getSnapshot(requests)) {
  7. // We don't need to check for cleared here. Any explicit clear by a user will remove the
  8. // Request from the tracker, so the only way we'd find a cleared request here is if we cleared
  9. // it. As a result it should be safe for us to resume cleared requests.
  10. if (!request.isComplete() && !request.isRunning()) {
  11. request.begin();
  12. }
  13. }
  14. pendingRequests.clear();
  15. }

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

  1. /**
  2. * Restarts failed requests and cancels and restarts in progress requests.
  3. */
  4. public void restartRequests() {
  5. for (Request request : Util.getSnapshot(requests)) {
  6. if (!request.isComplete() && !request.isCleared()) {
  7. request.clear();
  8. if (!isPaused) {
  9. request.begin();
  10. } else {
  11. // Ensure the request will be restarted in onResume.
  12. pendingRequests.add(request);
  13. }
  14. }
  15. }
  16. }

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

  1. /**
  2. * Cancels all requests and clears their resources.
  3. */
  4. public void clearRequests() {
  5. for (Request request : Util.getSnapshot(requests)) {
  6. request.clear();
  7. }
  8. pendingRequests.clear();
  9. }

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

  1. void onStart() {
  2. isStarted = true;
  3. for (LifecycleListener lifecycleListener : Util.getSnapshot(lifecycleListeners)) {
  4. lifecycleListener.onStart();
  5. }
  6. }

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

  1. void onDestroy() {
  2. isDestroyed = true;
  3. for (LifecycleListener lifecycleListener : Util.getSnapshot(lifecycleListeners)) {
  4. lifecycleListener.onDestroy();
  5. }
  6. }
  7. }

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

  1. void onStop() {
  2. isStarted = false;
  3. for (LifecycleListener lifecycleListener : Util.getSnapshot(lifecycleListeners)) {
  4. lifecycleListener.onStop();
  5. }
  6. }

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

  1. /**
  2. * Stops any in progress requests.
  3. */
  4. public void pauseRequests() {
  5. isPaused = true;
  6. for (Request request : Util.getSnapshot(requests)) {
  7. if (request.isRunning()) {
  8. request.pause();
  9. pendingRequests.add(request);
  10. }
  11. }
  12. }

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

  1. /**
  2. * Starts any not yet completed or failed requests.
  3. */
  4. public void resumeRequests() {
  5. isPaused = false;
  6. for (Request request : Util.getSnapshot(requests)) {
  7. if (!request.isComplete() && !request.isCancelled() && !request.isRunning()) {
  8. request.begin();
  9. }
  10. }
  11. pendingRequests.clear();
  12. }

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

  1. /**
  2. * Restarts failed requests and cancels and restarts in progress requests.
  3. */
  4. public void restartRequests() {
  5. for (Request request : Util.getSnapshot(requests)) {
  6. if (!request.isComplete() && !request.isCancelled()) {
  7. // Ensure the request will be restarted in onResume.
  8. request.pause();
  9. if (!isPaused) {
  10. request.begin();
  11. } else {
  12. pendingRequests.add(request);
  13. }
  14. }
  15. }
  16. }
  17. }

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

  1. void onStart() {
  2. isStarted = true;
  3. for (LifecycleListener lifecycleListener : Util.getSnapshot(lifecycleListeners)) {
  4. lifecycleListener.onStart();
  5. }
  6. }

相关文章