Code example for LinkedList

Methods: offerLast, poll, remove

0
            imageView.setImageDrawable(placeHolder);
            imageView.setTag(new WeakReference<BitmapDownloaderTask>(task));
 
            imageView.setMinimumHeight(156);
 
            pendingTasks.offerLast(task);
            if (loaderTask == null || loaderTask.getStatus() == AsyncTask.Status.FINISHED) {
                loaderTask = pendingTasks.poll();
                loaderTask.execute();
            } 
        } 
    } 
 
    private boolean removePotentialDownload(String url, ImageView imageView) {
        BitmapDownloaderTask bitmapDownloaderTask = getBitmapDownloaderTask(imageView);
 
        if (bitmapDownloaderTask != null) {
            String bitmapUrl = bitmapDownloaderTask.url;
            if ((bitmapUrl == null) || (!bitmapUrl.equals(url))) {
                pendingTasks.remove(bitmapDownloaderTask);
            } else { 
                // The same URL is already being downloaded. 
                return false; 
            } 
        }