Glide取消圖片加載
1.在任務(wù)剛開始時(shí);
2.在EngineJob中,Future.cancel(true)
3.在加載完成,但沒有加載到控件;
RequestManager.java:
public void pauseRequests() { Util.assertMainThread(); requestTracker.pauseRequests(); }
RequestTracker.java:
public void pauseRequests() { isPaused = true; for (Request request : Util.getSnapshot(requests)) { if (request.isRunning()) { request.pause(); pendingRequests.add(request); } } }
GenericRequest.java:
@Override public void pause() { clear(); status = Status.PAUSED; }
GenericRequest.LoadStatus.java:
public void cancel() { engineJob.removeCallback(cb); }
EngineJob.java:
public void removeCallback(ResourceCallback cb) { Util.assertMainThread(); if (hasResource || hasException) { addIgnoredCallback(cb); } else { cbs.remove(cb); if (cbs.isEmpty()) { cancel(); } } } void cancel() { if (hasException || hasResource || isCancelled) { return; } engineRunnable.cancel(); Future currentFuture = future; if (currentFuture != null) { currentFuture.cancel(true); } isCancelled = true; listener.onEngineJobCancelled(this, key); }
EngineRunnable.java:
public void cancel() { isCancelled = true; decodeJob.cancel(); }
EngineRunnable.java:
@Override public void run() { if (isCancelled) { return; } Exception exception = null; Resource> resource = null; try { resource = decode(); } catch (Exception e) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "Exception decoding", e); } exception = e; } if (isCancelled) { if (resource != null) { resource.recycle(); } return; } if (resource == null) { onLoadFailed(exception); } else { onLoadComplete(resource); } }
EngineJob.java:
private volatile Future> future; void cancel() { if (hasException || hasResource || isCancelled) { return; } engineRunnable.cancel(); Future currentFuture = future; if (currentFuture != null) { currentFuture.cancel(true); } isCancelled = true; listener.onEngineJobCancelled(this, key); }
public void start(EngineRunnable engineRunnable) { this.engineRunnable = engineRunnable; future = diskCacheService.submit(engineRunnable); } @Override public void submitForSource(EngineRunnable runnable) { future = sourceService.submit(runnable); }
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://m.specialneedsforspecialkids.com/yun/70704.html
摘要:版本問題如何實(shí)現(xiàn)與生命周期的綁定如何實(shí)現(xiàn)緩存如何實(shí)現(xiàn)圖片壓縮如何實(shí)現(xiàn)與生命周期的綁定創(chuàng)建將其與傳入的生命周期綁定這樣做的好處是當(dāng)時(shí),也會(huì)做相應(yīng)操作,如停掉圖片加載綁定首先無論傳入的是什么,只要是在子線程中調(diào)用創(chuàng)建的與綁定,這樣創(chuàng)建的的生命周 版本4.9.0 問題 Glide如何實(shí)現(xiàn)與生命周期的綁定? Glide如何實(shí)現(xiàn)緩存? Glide如何實(shí)現(xiàn)圖片壓縮? Glide如何實(shí)現(xiàn)與生命周...
摘要:從這段代碼入手分析分析從這段代碼可以看出無論傳入的是還是或者干脆傳入或都會(huì)調(diào)用這個(gè)方法而這個(gè)方法生成兩個(gè)對象對象,并把它加到上對象這兩個(gè)對象擁有共同的對象對象,當(dāng)系統(tǒng)調(diào)用的生命周期,的生命周期隨之被調(diào)用來處理列表,將的生命周期與的生命周期聯(lián) 從這段代碼入手分析Glide Glide.with(context) .load(url) .placehol...
閱讀 1694·2023-04-25 20:16
閱讀 3878·2021-10-09 09:54
閱讀 2710·2021-09-04 16:40
閱讀 2527·2019-08-30 15:55
閱讀 843·2019-08-29 12:37
閱讀 2746·2019-08-26 13:55
閱讀 2917·2019-08-26 11:42
閱讀 3159·2019-08-23 18:26