@SuppressLint("NewApi") private void loadImageFromDisk(ImageView imageView) { if (imageView != null && !mIsCancelled) { ApptentiveLog.v("ApptentiveAttachmentLoader loadImageFromDisk: " + uri); mDrawableLoaderTask = new ApptentiveDrawableLoaderTask(imageView, this); try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mDrawableLoaderTask.executeOnExecutor( AsyncTask.THREAD_POOL_EXECUTOR, uri, diskCacheFilePath, String.valueOf(imageViewWidth), String.valueOf(imageViewHeight)); } else { mDrawableLoaderTask.execute( uri, diskCacheFilePath, String.valueOf(imageViewWidth), String.valueOf(imageViewHeight)); } } catch (RejectedExecutionException e) { } } }
private void cancel() { ApptentiveLog.v("ApptentiveAttachmentLoader cancel requested for: " + uri); mIsCancelled = true; ArrayList<LoaderRequest> duplicates = duplicateDownloads.get(uri); if (duplicates != null) { duplicates.remove(this); if (duplicates.size() > 0) { duplicateDownloads.put(uri, duplicates); } else { duplicateDownloads.remove(uri); } } if (queuedDownLoaderRequests.contains(this)) { queuedDownLoaderRequests.remove(this); } if (mDrawableDownloaderTask != null) { mDrawableDownloaderTask.cancel(true); } if (mDrawableLoaderTask != null) { mDrawableLoaderTask.cancel(true); } }