/** Builds configured {@link ImageLoaderConfiguration} object */ public ImageLoaderConfiguration build() { initEmptyFieldsWithDefaultValues(); return new ImageLoaderConfiguration(this); }
/** @throws TaskCancelledException if current task was interrupted */ private void checkTaskInterrupted() throws TaskCancelledException { if (isTaskInterrupted()) { throw new TaskCancelledException(); } }
/** @throws TaskCancelledException if target ImageAware is collected by GC */ private void checkViewReused() throws TaskCancelledException { if (isViewReused()) { throw new TaskCancelledException(); } }
private ImageDownloader getDownloader() { ImageDownloader d; if (engine.isNetworkDenied()) { d = networkDeniedDownloader; } else if (engine.isSlowNetwork()) { d = slowNetworkDownloader; } else { d = downloader; } return d; }
/** @throws TaskCancelledException if target ImageAware is collected */ private void checkViewCollected() throws TaskCancelledException { if (isViewCollected()) { throw new TaskCancelledException(); } }
/** * @return <b>true</b> - if task is not actual (target ImageAware is collected by GC or the image URI of this task * doesn't match to image URI which is actual for current ImageAware at this moment)); <b>false</b> - otherwise */ private boolean isTaskNotActual() { return isViewCollected() || isViewReused(); }
private void fireCancelEvent() { if (syncLoading || isTaskInterrupted()) return; Runnable r = new Runnable() { @Override public void run() { listener.onLoadingCancelled(uri, imageAware.getWrappedView()); } }; runTask(r, false, handler, engine); }
/** * @throws TaskCancelledException if task is not actual (target ImageAware is collected by GC or the image URI of * this task doesn't match to image URI which is actual for current ImageAware at * this moment) */ private void checkTaskNotActual() throws TaskCancelledException { checkViewCollected(); checkViewReused(); }
/** * @param cacheDir Directory for file caching * @param reserveCacheDir null-ok; Reserve directory for file caching. It's used when the primary directory isn't available. */ public BaseDiskCache(File cacheDir, File reserveCacheDir) { this(cacheDir, reserveCacheDir, DefaultConfigurationFactory.createFileNameGenerator()); }
/** * Cancel the task of loading and displaying image for passed * {@link com.nostra13.universalimageloader.core.imageaware.ImageAware ImageAware}. * * @param imageAware {@link com.nostra13.universalimageloader.core.imageaware.ImageAware ImageAware} for * which display task will be cancelled */ public void cancelDisplayTask(ImageAware imageAware) { engine.cancelDisplayTaskFor(imageAware); }
public DisplayBitmapTask(Bitmap bitmap, ImageLoadingInfo imageLoadingInfo, ImageLoaderEngine engine, LoadedFrom loadedFrom) { this.bitmap = bitmap; imageUri = imageLoadingInfo.uri; imageAware = imageLoadingInfo.imageAware; memoryCacheKey = imageLoadingInfo.memoryCacheKey; displayer = imageLoadingInfo.options.getDisplayer(); listener = imageLoadingInfo.listener; this.engine = engine; this.loadedFrom = loadedFrom; }
/** * Returns memory cache * * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before */ public MemoryCache getMemoryCache() { checkConfiguration(); return configuration.memoryCache; }
/** * Pause ImageLoader. All new "load&display" tasks won't be executed until ImageLoader is {@link #resume() resumed}. * <br /> * Already running tasks are not paused. */ public void pause() { engine.pause(); }
private Executor createTaskExecutor() { return DefaultConfigurationFactory .createExecutor(configuration.threadPoolSize, configuration.threadPriority, configuration.tasksProcessingType); }
/** Returns singleton class instance */ public static ImageLoader getInstance() { if (instance == null) { synchronized (ImageLoader.class) { if (instance == null) { instance = new ImageLoader(); } } } return instance; }
/** * Returns URI of image which is loading at this moment into passed * {@link com.nostra13.universalimageloader.core.imageaware.ImageAware ImageAware} */ public String getLoadingUriForView(ImageAware imageAware) { return engine.getLoadingUriForView(imageAware); }
/** * Sets option whether ImageLoader will use {@link FlushedInputStream} for network downloads to handle <a * href="http://code.google.com/p/android/issues/detail?id=6066">this known problem</a> or not. * * @param handleSlowNetwork pass <b>true</b> - to use {@link FlushedInputStream} for network downloads; <b>false</b> * - otherwise. */ public void handleSlowNetwork(boolean handleSlowNetwork) { engine.handleSlowNetwork(handleSlowNetwork); }
/** * @param cacheDir Directory for file caching * @param maxAge Max file age (in seconds). If file age will exceed this value then it'll be removed on next * treatment (and therefore be reloaded). */ public LimitedAgeDiskCache(File cacheDir, File reserveCacheDir, long maxAge) { this(cacheDir, reserveCacheDir, DefaultConfigurationFactory.createFileNameGenerator(), maxAge); }
/** * Returns disk cache * * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before */ public DiskCache getDiskCache() { checkConfiguration(); return configuration.diskCache; }
/** * @param cacheDir Directory for file caching * @param maxAge Max file age (in seconds). If file age will exceed this value then it'll be removed on next * treatment (and therefore be reloaded). */ public LimitedAgeDiskCache(File cacheDir, long maxAge) { this(cacheDir, null, DefaultConfigurationFactory.createFileNameGenerator(), maxAge); }