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()) { Bitmap bitmapOnFaile = options.getImageBitmapOnFail(configuration.resources); if (options.getDisplayer() instanceof RoundedBitmapDisplayer && bitmapOnFaile != null) { int corner = ((RoundedBitmapDisplayer) options.getDisplayer()).getRoundedBitmapCorner(); if (corner != 0) { imageAware.setImageDrawable(new RoundedBitmapDisplayer.RoundedDrawable(bitmapOnFaile, corner, 0)); } } else { imageAware.setImageDrawable(options.getImageOnFail(configuration.resources)); } } listener.onLoadingFailed(uri, imageAware.getWrappedView(), new FailReason(failType, failCause)); } }; runTask(r, false, handler, engine); }
/** * 图片加载失败事件处理分发 * @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); }
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 (!this.syncLoading && !isTaskInterrupted() && !isTaskNotActual()) { runTask(new Runnable() { public void run() { if (LoadAndDisplayImageTask.this.options.shouldShowImageOnFail()) { LoadAndDisplayImageTask.this.imageAware.setImageDrawable(LoadAndDisplayImageTask.this.options.getImageOnFail(LoadAndDisplayImageTask.this.configuration.resources)); } LoadAndDisplayImageTask.this.listener.onLoadingFailed(LoadAndDisplayImageTask.this.uri, LoadAndDisplayImageTask.this.imageAware.getWrappedView(), new FailReason(failType, failCause)); } }, false, this.handler, this.engine); } }
private void fireFailEvent(final FailType failType, final Throwable failCause) { if (options.isSyncLoading() || isTaskInterrupted() || isTaskNotActual()) return; handler.post(new Runnable() { @Override public void run() { if (options.shouldShowImageOnFail()) { imageAware.setImageDrawable(options.getImageOnFail(configuration.resources)); } listener.onLoadingFailed(uri, imageAware.getWrappedView(), new FailReason(failType, failCause)); } }); }
private void fireImageLoadingFailedEvent(final FailType failType, final Throwable failCause) { if (!Thread.interrupted()) { handler.post(new Runnable() { @Override public void run() { if (options.shouldShowImageOnFail()) { imageView.setImageResource(options.getImageOnFail()); } listener.onLoadingFailed(uri, imageView, new FailReason(failType, failCause)); } }); } }
private Bitmap tryLoadBitmap() throws TaskCancelledException { Bitmap bitmap = null; if (this.thumbnailUtils != null && this.uri.startsWith("LetvThumbnailUtils")) { bitmap = this.thumbnailUtils.getThumbnailBitmap(this.uri.replace("LetvThumbnailUtils", "")); if (bitmap != null) { return bitmap; } } try { File imageFile = this.configuration.diskCache.get(this.uri); if (imageFile != null && imageFile.exists()) { L.d(LOG_LOAD_IMAGE_FROM_DISK_CACHE, this.memoryCacheKey); this.loadedFrom = LoadedFrom.DISC_CACHE; checkTaskNotActual(); bitmap = decodeImage(Scheme.FILE.wrap(imageFile.getAbsolutePath())); } if (bitmap == null || bitmap.getWidth() <= 0 || bitmap.getHeight() <= 0) { L.d(LOG_LOAD_IMAGE_FROM_NETWORK, this.memoryCacheKey); this.loadedFrom = LoadedFrom.NETWORK; String imageUriForDecoding = this.uri; if (this.options.isCacheOnDisk() && tryCacheImageOnDisk()) { imageFile = this.configuration.diskCache.get(this.uri); if (imageFile != null) { imageUriForDecoding = Scheme.FILE.wrap(imageFile.getAbsolutePath()); } } checkTaskNotActual(); bitmap = decodeImage(imageUriForDecoding); if (bitmap == null || bitmap.getWidth() <= 0 || bitmap.getHeight() <= 0) { fireFailEvent(FailType.DECODING_ERROR, null); } } } catch (IllegalStateException e) { fireFailEvent(FailType.NETWORK_DENIED, null); } catch (TaskCancelledException e2) { throw e2; } catch (IOException e3) { L.e(e3); fireFailEvent(FailType.IO_ERROR, e3); } catch (OutOfMemoryError e4) { L.e(e4); fireFailEvent(FailType.OUT_OF_MEMORY, e4); } catch (Throwable e5) { L.e(e5); fireFailEvent(FailType.UNKNOWN, e5); } return bitmap; }
private Bitmap tryLoadBitmap() throws TaskCancelledException { Bitmap bitmap = null; try { File imageFile = this.configuration.diskCache.get(this.uri); if (imageFile != null && imageFile.exists() && imageFile.length() > 0) { L.d(LOG_LOAD_IMAGE_FROM_DISK_CACHE, this.memoryCacheKey); this.loadedFrom = LoadedFrom.DISC_CACHE; checkTaskNotActual(); bitmap = decodeImage(Scheme.FILE.wrap(imageFile.getAbsolutePath())); } if (bitmap == null || bitmap.getWidth() <= 0 || bitmap.getHeight() <= 0) { L.d(LOG_LOAD_IMAGE_FROM_NETWORK, this.memoryCacheKey); this.loadedFrom = LoadedFrom.NETWORK; String imageUriForDecoding = this.uri; if (this.options.isCacheOnDisk() && tryCacheImageOnDisk()) { imageFile = this.configuration.diskCache.get(this.uri); if (imageFile != null) { imageUriForDecoding = Scheme.FILE.wrap(imageFile.getAbsolutePath()); } } checkTaskNotActual(); bitmap = decodeImage(imageUriForDecoding); if (bitmap == null || bitmap.getWidth() <= 0 || bitmap.getHeight() <= 0) { fireFailEvent(FailType.DECODING_ERROR, null); } } } catch (IllegalStateException e) { fireFailEvent(FailType.NETWORK_DENIED, null); } catch (TaskCancelledException e2) { throw e2; } catch (IOException e3) { L.e(e3); fireFailEvent(FailType.IO_ERROR, e3); } catch (OutOfMemoryError e4) { L.e(e4); fireFailEvent(FailType.OUT_OF_MEMORY, e4); } catch (Throwable e5) { L.e(e5); fireFailEvent(FailType.UNKNOWN, e5); } return bitmap; }
private void fireFailEvent(FailType failType, Throwable failCause) { if (!this.syncLoading && !isTaskInterrupted() && !isTaskNotActual()) { runTask(new 2 (this, failType, failCause),false, this.handler, this.engine); } }