Java Code Examples for com.nostra13.universalimageloader.utils.L

The following examples show how to use com.nostra13.universalimageloader.utils.L. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
protected Options prepareDecodingOptions(ImageSize imageSize, ImageDecodingInfo decodingInfo) {
	ImageScaleType scaleType = decodingInfo.getImageScaleType();
	int scale;
	if (scaleType == ImageScaleType.NONE) {
		scale = 1;
	} else if (scaleType == ImageScaleType.NONE_SAFE) {
		scale = ImageSizeUtils.computeMinImageSampleSize(imageSize);
	} else {
		ImageSize targetSize = decodingInfo.getTargetSize();
		boolean powerOf2 = scaleType == ImageScaleType.IN_SAMPLE_POWER_OF_2;
		scale = ImageSizeUtils.computeImageSampleSize(imageSize, targetSize, decodingInfo.getViewScaleType(), powerOf2);
	}
	if (scale > 1 && loggingEnabled) {
		L.d(LOG_SUBSAMPLE_IMAGE, imageSize, imageSize.scaleDown(scale), scale, decodingInfo.getImageKey());
	}

	Options decodingOptions = decodingInfo.getDecodingOptions();
	decodingOptions.inSampleSize = scale;
	return decodingOptions;
}
 
Example 2
private ImageLoaderConfiguration(final Builder builder) {
	resources = builder.context.getResources();
	maxImageWidthForMemoryCache = builder.maxImageWidthForMemoryCache;
	maxImageHeightForMemoryCache = builder.maxImageHeightForMemoryCache;
	maxImageWidthForDiskCache = builder.maxImageWidthForDiskCache;
	maxImageHeightForDiskCache = builder.maxImageHeightForDiskCache;
	processorForDiskCache = builder.processorForDiskCache;
	taskExecutor = builder.taskExecutor;
	taskExecutorForCachedImages = builder.taskExecutorForCachedImages;
	threadPoolSize = builder.threadPoolSize;
	threadPriority = builder.threadPriority;
	tasksProcessingType = builder.tasksProcessingType;
	diskCache = builder.diskCache;
	memoryCache = builder.memoryCache;
	defaultDisplayImageOptions = builder.defaultDisplayImageOptions;
	downloader = builder.downloader;
	decoder = builder.decoder;

	customExecutor = builder.customExecutor;
	customExecutorForCachedImages = builder.customExecutorForCachedImages;

	networkDeniedDownloader = new NetworkDeniedImageDownloader(downloader);
	slowNetworkDownloader = new SlowNetworkImageDownloader(downloader);

	L.writeDebugLogs(builder.writeLogs);
}
 
Example 3
public o threadPriority(int i1)
{
    if (k != null || l != null)
    {
        L.w("threadPoolSize(), threadPriority() and tasksProcessingOrder() calls can overlap taskExecutor() and taskExecutorForCachedImages() calls.", new Object[0]);
    }
    if (i1 < 1)
    {
        p = 1;
        return this;
    }
    if (i1 > 10)
    {
        p = 10;
        return this;
    } else
    {
        p = i1;
        return this;
    }
}
 
Example 4
Source Project: candybar   Source File: BaseImageDecoder.java    License: Apache License 2.0 6 votes vote down vote up
protected Options prepareDecodingOptions(ImageSize imageSize, ImageDecodingInfo decodingInfo) {
    ImageScaleType scaleType = decodingInfo.getImageScaleType();
    int scale;
    if (scaleType == ImageScaleType.NONE) {
        scale = 1;
    } else if (scaleType == ImageScaleType.NONE_SAFE) {
        scale = ImageSizeUtils.computeMinImageSampleSize(imageSize);
    } else {
        ImageSize targetSize = decodingInfo.getTargetSize();
        boolean powerOf2 = scaleType == ImageScaleType.IN_SAMPLE_POWER_OF_2;
        scale = ImageSizeUtils.computeImageSampleSize(imageSize, targetSize, decodingInfo.getViewScaleType(), powerOf2);
    }
    if (scale > 1 && loggingEnabled) {
        L.d(LOG_SUBSAMPLE_IMAGE, imageSize, imageSize.scaleDown(scale), scale, decodingInfo.getImageKey());
    }

    Options decodingOptions = decodingInfo.getDecodingOptions();
    decodingOptions.inSampleSize = scale;
    return decodingOptions;
}
 
Example 5
Source Project: letv   Source File: LruDiscCache.java    License: Apache License 2.0 6 votes vote down vote up
public File get(String imageUri) {
    File file = null;
    Snapshot snapshot = null;
    try {
        snapshot = this.cache.get(getKey(imageUri));
        if (snapshot != null) {
            file = snapshot.getFile(0);
        }
        if (snapshot != null) {
            snapshot.close();
        }
    } catch (IOException e) {
        L.e(e);
        if (snapshot != null) {
            snapshot.close();
        }
    } catch (Throwable th) {
        if (snapshot != null) {
            snapshot.close();
        }
    }
    return file;
}
 
Example 6
/**
 * @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();
}
 
Example 7
Source Project: mobile-manager-tool   Source File: ImageLoaderConfiguration.java    License: MIT License 6 votes vote down vote up
private ImageLoaderConfiguration(final Builder builder) {
	resources = builder.context.getResources();
	maxImageWidthForMemoryCache = builder.maxImageWidthForMemoryCache;
	maxImageHeightForMemoryCache = builder.maxImageHeightForMemoryCache;
	maxImageWidthForDiskCache = builder.maxImageWidthForDiskCache;
	maxImageHeightForDiskCache = builder.maxImageHeightForDiskCache;
	processorForDiskCache = builder.processorForDiskCache;
	taskExecutor = builder.taskExecutor;
	taskExecutorForCachedImages = builder.taskExecutorForCachedImages;
	threadPoolSize = builder.threadPoolSize;
	threadPriority = builder.threadPriority;
	tasksProcessingType = builder.tasksProcessingType;
	diskCache = builder.diskCache;
	memoryCache = builder.memoryCache;
	defaultDisplayImageOptions = builder.defaultDisplayImageOptions;
	downloader = builder.downloader;
	decoder = builder.decoder;

	customExecutor = builder.customExecutor;
	customExecutorForCachedImages = builder.customExecutorForCachedImages;

	networkDeniedDownloader = new NetworkDeniedImageDownloader(downloader);
	slowNetworkDownloader = new SlowNetworkImageDownloader(downloader);

	L.writeDebugLogs(builder.writeLogs);
}
 
Example 8
Source Project: WliveTV   Source File: ImageLoaderConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
private ImageLoaderConfiguration(final Builder builder) {
	resources = builder.context.getResources();
	maxImageWidthForMemoryCache = builder.maxImageWidthForMemoryCache;
	maxImageHeightForMemoryCache = builder.maxImageHeightForMemoryCache;
	maxImageWidthForDiskCache = builder.maxImageWidthForDiskCache;
	maxImageHeightForDiskCache = builder.maxImageHeightForDiskCache;
	processorForDiskCache = builder.processorForDiskCache;
	taskExecutor = builder.taskExecutor;
	taskExecutorForCachedImages = builder.taskExecutorForCachedImages;
	threadPoolSize = builder.threadPoolSize;
	threadPriority = builder.threadPriority;
	tasksProcessingType = builder.tasksProcessingType;
	diskCache = builder.diskCache;
	memoryCache = builder.memoryCache;
	defaultDisplayImageOptions = builder.defaultDisplayImageOptions;
	downloader = builder.downloader;
	decoder = builder.decoder;

	customExecutor = builder.customExecutor;
	customExecutorForCachedImages = builder.customExecutorForCachedImages;

	networkDeniedDownloader = new NetworkDeniedImageDownloader(downloader);
	slowNetworkDownloader = new SlowNetworkImageDownloader(downloader);

	L.writeDebugLogs(builder.writeLogs);
}
 
Example 9
Source Project: letv   Source File: LoadAndDisplayImageTask.java    License: Apache License 2.0 6 votes vote down vote up
private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException {
    File targetFile = this.configuration.diskCache.get(this.uri);
    if (targetFile == null || !targetFile.exists()) {
        return false;
    }
    Bitmap bmp = this.decoder.decode(new ImageDecodingInfo(this.memoryCacheKey, Scheme.FILE.wrap(targetFile.getAbsolutePath()), this.uri, new ImageSize(maxWidth, maxHeight), ViewScaleType.FIT_INSIDE, getDownloader(), new Builder().cloneFrom(this.options).imageScaleType(ImageScaleType.IN_SAMPLE_INT).build()));
    if (!(bmp == null || this.configuration.processorForDiskCache == null)) {
        L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, this.memoryCacheKey);
        bmp = this.configuration.processorForDiskCache.process(bmp);
        if (bmp == null) {
            L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, this.memoryCacheKey);
        }
    }
    if (bmp == null) {
        return false;
    }
    boolean saved = this.configuration.diskCache.save(this.uri, bmp);
    bmp.recycle();
    return saved;
}
 
Example 10
Source Project: MiBandDecompiled   Source File: ImageLoaderConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
public Builder threadPriority(int i1)
{
    if (k != null || l != null)
    {
        L.w("threadPoolSize(), threadPriority() and tasksProcessingOrder() calls can overlap taskExecutor() and taskExecutorForCachedImages() calls.", new Object[0]);
    }
    if (i1 < 1)
    {
        p = 1;
        return this;
    }
    if (i1 > 10)
    {
        p = 10;
        return this;
    } else
    {
        p = i1;
        return this;
    }
}
 
Example 11
/**
 * 线程任务执行方法
 */
@Override
public void run() {
	//判断当前imageAware是否被回收
	if (imageAware.isCollected()) {
		L.d(LOG_TASK_CANCELLED_IMAGEAWARE_COLLECTED, memoryCacheKey);
		//进行回调加载取消
		listener.onLoadingCancelled(imageUri, imageAware.getWrappedView());
	} else if (isViewWasReused()) {
		//判断对象是否为同一个
		L.d(LOG_TASK_CANCELLED_IMAGEAWARE_REUSED, memoryCacheKey);
		listener.onLoadingCancelled(imageUri, imageAware.getWrappedView());
	} else {
		//进行显示
		L.d(LOG_DISPLAY_IMAGE_IN_IMAGEAWARE, loadedFrom, memoryCacheKey);
		//显示图片
		displayer.display(bitmap, imageAware, loadedFrom);
		engine.cancelDisplayTaskFor(imageAware);
		//图片显示完成回调
		listener.onLoadingComplete(imageUri, imageAware.getWrappedView(), bitmap);
	}
}
 
Example 12
/** @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();
}
 
Example 13
Source Project: talk-android   Source File: DiskDecoder.java    License: MIT License 6 votes vote down vote up
protected BitmapFactory.Options prepareDecodingOptions(ImageSize imageSize, ImageDecodingInfo decodingInfo) {
    ImageScaleType scaleType = decodingInfo.getImageScaleType();
    int scale;
    if (scaleType == ImageScaleType.NONE) {
        scale = 1;
    } else if (scaleType == ImageScaleType.NONE_SAFE) {
        scale = ImageSizeUtils.computeMinImageSampleSize(imageSize);
    } else {
        ImageSize targetSize = decodingInfo.getTargetSize();
        boolean powerOf2 = scaleType == ImageScaleType.IN_SAMPLE_POWER_OF_2;
        scale = ImageSizeUtils.computeImageSampleSize(imageSize, targetSize, decodingInfo.getViewScaleType(), powerOf2);
    }
    if (scale > 1 && loggingEnabled) {
        L.d(LOG_SUBSAMPLE_IMAGE, imageSize, imageSize.scaleDown(scale), scale, decodingInfo.getImageKey());
    }

    BitmapFactory.Options decodingOptions = decodingInfo.getDecodingOptions();
    decodingOptions.inSampleSize = scale;
    return decodingOptions;
}
 
Example 14
Source Project: MiBandDecompiled   Source File: l.java    License: Apache License 2.0 6 votes vote down vote up
private boolean n()
{
    String s1 = z.a(b);
    boolean flag;
    if (!H.equals(s1))
    {
        flag = true;
    } else
    {
        flag = false;
    }
    if (flag)
    {
        Object aobj[] = new Object[1];
        aobj[0] = H;
        L.d("ImageAware is reused for another image. Task is cancelled. [%s]", aobj);
        return true;
    } else
    {
        return false;
    }
}
 
Example 15
Source Project: candybar   Source File: Md5FileNameGenerator.java    License: Apache License 2.0 5 votes vote down vote up
private byte[] getMD5(byte[] data) {
    byte[] hash = null;
    try {
        MessageDigest digest = MessageDigest.getInstance(HASH_ALGORITHM);
        digest.update(data);
        hash = digest.digest();
    } catch (NoSuchAlgorithmException e) {
        L.e(e);
    }
    return hash;
}
 
Example 16
Source Project: BigApp_WordPress_Android   Source File: LruDiskCache.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void close() {
	try {
		cache.close();
	} catch (IOException e) {
		L.e(e);
	}
	cache = null;
}
 
Example 17
Source Project: candybar   Source File: LruDiskCache.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public File get(String imageUri) {
    DiskLruCache.Snapshot snapshot = null;
    try {
        snapshot = cache.get(getKey(imageUri));
        return snapshot == null ? null : snapshot.getFile(0);
    } catch (IOException e) {
        L.e(e);
        return null;
    } finally {
        if (snapshot != null) {
            snapshot.close();
        }
    }
}
 
Example 18
Source Project: candybar   Source File: LruDiskCache.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void close() {
    try {
        cache.close();
    } catch (IOException e) {
        L.e(e);
    }
    cache = null;
}
 
Example 19
Source Project: BigApp_WordPress_Android   Source File: BaseImageDecoder.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Decodes image from URI into {@link Bitmap}. Image is scaled close to incoming {@linkplain ImageSize target size}
 * during decoding (depend on incoming parameters).
 *
 * @param decodingInfo Needed data for decoding image
 * @return Decoded bitmap
 * @throws IOException                   if some I/O exception occurs during image reading
 * @throws UnsupportedOperationException if image URI has unsupported scheme(protocol)
 */
@Override
public Bitmap decode(ImageDecodingInfo decodingInfo) throws IOException {
    Bitmap decodedBitmap;
    ImageFileInfo imageInfo;

    InputStream imageStream = getImageStream(decodingInfo);
    if (imageStream == null) {
        L.e(ERROR_NO_IMAGE_STREAM, decodingInfo.getImageKey());
        return null;
    }
    try {
        imageInfo = defineImageSizeAndRotation(imageStream, decodingInfo);
        imageStream = resetStream(imageStream, decodingInfo);
        Options decodingOptions = prepareDecodingOptions(imageInfo.imageSize, decodingInfo);
        decodedBitmap = BitmapFactory.decodeStream(imageStream, null, decodingOptions);
    } finally {
        IoUtils.closeSilently(imageStream);
    }

    if (decodedBitmap == null) {
        L.e(ERROR_CANT_DECODE_IMAGE, decodingInfo.getImageKey());
    } else {
        decodedBitmap = considerExactScaleAndOrientatiton(decodedBitmap, decodingInfo, imageInfo.exif.rotation,
                imageInfo.exif.flipHorizontal);
    }
    return decodedBitmap;
}
 
Example 20
Source Project: android-open-project-demo   Source File: LruDiscCache.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void close() {
	try {
		cache.close();
	} catch (IOException e) {
		L.e(e);
	}
	cache = null;
}
 
Example 21
Source Project: mobile-manager-tool   Source File: ViewAware.java    License: MIT License 5 votes vote down vote up
@Override
public boolean setImageDrawable(Drawable drawable) {
	if (Looper.myLooper() == Looper.getMainLooper()) {
		View view = viewRef.get();
		if (view != null) {
			setImageDrawableInto(drawable, view);
			return true;
		}
	} else {
		L.w(WARN_CANT_SET_DRAWABLE);
	}
	return false;
}
 
Example 22
Source Project: android-open-project-demo   Source File: LruDiscCache.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public File get(String imageUri) {
	DiskLruCache.Snapshot snapshot = null;
	try {
		snapshot = cache.get(getKey(imageUri));
		return snapshot == null ? null : snapshot.getFile(0);
	} catch (IOException e) {
		L.e(e);
		return null;
	} finally {
		if (snapshot != null) {
			snapshot.close();
		}
	}
}
 
Example 23
/**
 * 进行关闭缓存
 */
@Override
public void close() {
	try {
		cache.close();
	} catch (IOException e) {
		L.e(e);
	}
	cache = null;
}
 
Example 24
Source Project: WliveTV   Source File: LoadAndDisplayImageTask.java    License: Apache License 2.0 5 votes vote down vote up
/** @return <b>true</b> - if current ImageAware is reused for displaying another image; <b>false</b> - otherwise */
private boolean isViewReused() {
	String currentCacheKey = engine.getLoadingUriForView(imageAware);
	// Check whether memory cache key (image URI) for current ImageAware is actual.
	// If ImageAware is reused for another task then current task should be cancelled.
	boolean imageAwareWasReused = !memoryCacheKey.equals(currentCacheKey);
	if (imageAwareWasReused) {
		L.d(LOG_TASK_CANCELLED_IMAGEAWARE_REUSED, memoryCacheKey);
		return true;
	}
	return false;
}
 
Example 25
Source Project: WliveTV   Source File: ImageLoaderConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets maximum disk cache size for images (in bytes).<br />
 * By default: disk cache is unlimited.<br />
 * <b>NOTE:</b> If you use this method then
 * {@link com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache LruDiskCache}
 * will be used as disk cache. You can use {@link #diskCache(DiskCache)} method for introduction your own
 * implementation of {@link DiskCache}
 */
public Builder diskCacheSize(int maxCacheSize) {
	if (maxCacheSize <= 0) throw new IllegalArgumentException("maxCacheSize must be a positive number");

	if (diskCache != null) {
		L.w(WARNING_OVERLAP_DISK_CACHE_PARAMS);
	}

	this.diskCacheSize = maxCacheSize;
	return this;
}
 
Example 26
public g memoryCacheSize(int i1)
{
    if (i1 <= 0)
    {
        throw new IllegalArgumentException("memoryCacheSize must be a positive number");
    }
    if (v != null)
    {
        L.w("memoryCache() and memoryCacheSize() calls overlap each other", new Object[0]);
    }
    s = i1;
    return this;
}
 
Example 27
Source Project: candybar   Source File: LoadAndDisplayImageTask.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @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;
}
 
Example 28
Source Project: WliveTV   Source File: LruDiskCache.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean remove(String imageUri) {
	try {
		return cache.remove(getKey(imageUri));
	} catch (IOException e) {
		L.e(e);
		return false;
	}
}
 
Example 29
Source Project: candybar   Source File: LoadAndDisplayImageTask.java    License: Apache License 2.0 5 votes vote down vote up
private boolean downloadImage() throws IOException {
    InputStream is = getDownloader().getStream(uri, options.getExtraForDownloader());
    if (is == null) {
        L.e(ERROR_NO_IMAGE_STREAM, memoryCacheKey);
        return false;
    } else {
        try {
            return configuration.diskCache.save(uri, is, this);
        } finally {
            IoUtils.closeSilently(is);
        }
    }
}
 
Example 30
Source Project: mobile-manager-tool   Source File: LoadAndDisplayImageTask.java    License: MIT License 5 votes vote down vote up
/** @return <b>true</b> - if current task was interrupted; <b>false</b> - otherwise */
private boolean isTaskInterrupted() {
	if (Thread.interrupted()) {
		L.d(LOG_TASK_INTERRUPTED, memoryCacheKey);
		return true;
	}
	return false;
}