private void fireFailEvent(final FailType failType, final Throwable failCause) { if (syncLoading || isTaskInterrupted() || isTaskNotActual()) return; Runnable r = new Runnable() { @Override public void run() { if (options.shouldShowImageOnFail()) { imageAware.setImageDrawable(options.getImageOnFail(configuration.resources)); } listener.onLoadingFailed(uri, imageAware.getWrappedView(), new FailReason(failType, failCause)); } }; runTask(r, false, handler, engine); }
/** @return <b>true</b> - if loading should be continued; <b>false</b> - if loading should be interrupted */ private boolean fireProgressEvent(final int current, final int total) { if (isTaskInterrupted() || isTaskNotActual()) return false; if (progressListener != null) { Runnable r = new Runnable() { @Override public void run() { progressListener.onProgressUpdate(uri, imageAware.getWrappedView(), current, total); } }; runTask(r, false, handler, engine); } return true; }
/** @return <b>true</b> - if task should be interrupted; <b>false</b> - otherwise */ private boolean waitIfPaused() { AtomicBoolean pause = engine.getPause(); if (pause.get()) { synchronized (engine.getPauseLock()) { if (pause.get()) { L.d(LOG_WAITING_FOR_RESUME, memoryCacheKey); try { engine.getPauseLock().wait(); } catch (InterruptedException e) { L.e(LOG_TASK_INTERRUPTED, memoryCacheKey); return true; } L.d(LOG_RESUME_AFTER_PAUSE, memoryCacheKey); } } } return isTaskNotActual(); }
/** @return <b>true</b> - if task should be interrupted; <b>false</b> - otherwise */ private boolean delayIfNeed() { if (options.shouldDelayBeforeLoading()) { L.d(LOG_DELAY_BEFORE_LOADING, options.getDelayBeforeLoading(), memoryCacheKey); try { Thread.sleep(options.getDelayBeforeLoading()); } catch (InterruptedException e) { L.e(LOG_TASK_INTERRUPTED, memoryCacheKey); return true; } return isTaskNotActual(); } return false; }
private void fireFailEvent(final FailType failType, final Throwable failCause) { if (syncLoading || isTaskInterrupted() || isTaskNotActual()) return; Runnable r = new Runnable() { @Override public void run() { if (options.shouldShowImageOnFail()) { imageAware.setImageDrawable(options.getImageOnFail(configuration.resources)); } listener.onLoadingFailed(uri, imageAware.getWrappedView(), new FailReason(failType, failCause)); } }; runTask(r, false, handler, engine); }
private void fireFailEvent(final FailType failType, final Throwable failCause) { if (syncLoading || isTaskInterrupted() || isTaskNotActual()) return; Runnable r = new Runnable() { @Override public void run() { if (options.shouldShowImageOnFail()) { imageAware.setImageDrawable(options.getImageOnFail(configuration.resources)); } listener.onLoadingFailed(uri, imageAware.getWrappedView(), new FailReason(failType, failCause)); } }; runTask(r, false, handler, engine); }
/** @return <b>true</b> - if loading should be continued; <b>false</b> - if loading should be interrupted */ private boolean fireProgressEvent(final int current, final int total) { if (isTaskInterrupted() || isTaskNotActual()) return false; if (progressListener != null) { Runnable r = new Runnable() { @Override public void run() { progressListener.onProgressUpdate(uri, imageAware.getWrappedView(), current, total); } }; runTask(r, false, handler, engine); } return true; }
/** @return <b>true</b> - if loading should be continued; <b>false</b> - if loading should be interrupted */ private boolean fireProgressEvent(final int current, final int total) { if (isTaskInterrupted() || isTaskNotActual()) return false; if (progressListener != null) { Runnable r = new Runnable() { @Override public void run() { progressListener.onProgressUpdate(uri, imageAware.getWrappedView(), current, total); } }; runTask(r, false, handler, engine); } return true; }
/** * 进行图片进度事件 * @param current 当前图片下载的图片资源大小 * @param total 图片资源下载的总大小 * @return */ private boolean fireProgressEvent(final int current, final int total) { if (isTaskInterrupted() || isTaskNotActual()) return false; if (progressListener != null) { Runnable r = new Runnable() { @Override public void run() { //进行回调图片加载进度信息 progressListener.onProgressUpdate(uri, imageAware.getWrappedView(), current, total); } }; //执行任务 runTask(r, false, handler, engine); } return true; }
/** * 图片加载失败事件处理分发 * @param failType * @param failCause */ private void fireFailEvent(final FailType failType, final Throwable failCause) { if (syncLoading || isTaskInterrupted() || isTaskNotActual()) return; Runnable r = new Runnable() { @Override public void run() { if (options.shouldShowImageOnFail()) { //存在图片加载失败的占位图片配置,进行设置 imageAware.setImageDrawable(options.getImageOnFail(configuration.resources)); } //进行回调图片加载失败方法 listener.onLoadingFailed(uri, imageAware.getWrappedView(), new FailReason(failType, failCause)); } }; //任务进行运行 runTask(r, false, handler, engine); }
/** @return <b>true</b> - if task should be interrupted; <b>false</b> - otherwise */ private boolean waitIfPaused() { AtomicBoolean pause = engine.getPause(); if (pause.get()) { synchronized (engine.getPauseLock()) { if (pause.get()) { L.d(LOG_WAITING_FOR_RESUME, memoryCacheKey); try { engine.getPauseLock().wait(); } catch (InterruptedException e) { L.e(LOG_TASK_INTERRUPTED, memoryCacheKey); return true; } L.d(LOG_RESUME_AFTER_PAUSE, memoryCacheKey); } } } return isTaskNotActual(); }
/** @return <b>true</b> - if task should be interrupted; <b>false</b> - otherwise */ private boolean waitIfPaused() { AtomicBoolean pause = engine.getPause(); if (pause.get()) { synchronized (engine.getPauseLock()) { if (pause.get()) { L.d(LOG_WAITING_FOR_RESUME, memoryCacheKey); try { engine.getPauseLock().wait(); } catch (InterruptedException e) { L.e(LOG_TASK_INTERRUPTED, memoryCacheKey); return true; } L.d(LOG_RESUME_AFTER_PAUSE, memoryCacheKey); } } } return isTaskNotActual(); }
/** @return <b>true</b> - if task should be interrupted; <b>false</b> - otherwise */ private boolean delayIfNeed() { if (options.shouldDelayBeforeLoading()) { L.d(LOG_DELAY_BEFORE_LOADING, options.getDelayBeforeLoading(), memoryCacheKey); try { Thread.sleep(options.getDelayBeforeLoading()); } catch (InterruptedException e) { L.e(LOG_TASK_INTERRUPTED, memoryCacheKey); return true; } return isTaskNotActual(); } return false; }
/** @return <b>true</b> - if task should be interrupted; <b>false</b> - otherwise */ private boolean delayIfNeed() { if (options.shouldDelayBeforeLoading()) { L.d(LOG_DELAY_BEFORE_LOADING, options.getDelayBeforeLoading(), memoryCacheKey); try { Thread.sleep(options.getDelayBeforeLoading()); } catch (InterruptedException e) { L.e(LOG_TASK_INTERRUPTED, memoryCacheKey); return true; } return isTaskNotActual(); } return false; }
/** * @return <b>true</b> - if task should be interrupted; <b>false</b> - otherwise * 判断是否需要等待暂时 */ private boolean waitIfPaused() { AtomicBoolean pause = engine.getPause(); if (pause.get()) { synchronized (engine.getPauseLock()) { if (pause.get()) { L.d(LOG_WAITING_FOR_RESUME, memoryCacheKey); try { engine.getPauseLock().wait(); } catch (InterruptedException e) { L.e(LOG_TASK_INTERRUPTED, memoryCacheKey); return true; } L.d(LOG_RESUME_AFTER_PAUSE, memoryCacheKey); } } } return isTaskNotActual(); }
/** * @return <b>true</b> - if task should be interrupted; <b>false</b> - otherwise * 判断是否需要延时 */ private boolean delayIfNeed() { if (options.shouldDelayBeforeLoading()) { L.d(LOG_DELAY_BEFORE_LOADING, options.getDelayBeforeLoading(), memoryCacheKey); try { Thread.sleep(options.getDelayBeforeLoading()); } catch (InterruptedException e) { L.e(LOG_TASK_INTERRUPTED, memoryCacheKey); return true; } return isTaskNotActual(); } return false; }