Java Code Examples for com.nostra13.universalimageloader.utils.L#d()

The following examples show how to use com.nostra13.universalimageloader.utils.L#d() . 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
Source File: LoadAndDisplayImageTask.java    From candybar with Apache License 2.0 6 votes vote down vote up
/**
 * @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 2
Source File: LoadAndDisplayImageTask.java    From letv with 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 3
Source File: LoadAndDisplayImageTask.java    From letv with Apache License 2.0 6 votes vote down vote up
private boolean tryCacheImageOnDisk() throws TaskCancelledException {
    L.d(LOG_CACHE_IMAGE_ON_DISK, this.memoryCacheKey);
    try {
        boolean loaded = downloadImage();
        if (!loaded) {
            return loaded;
        }
        int width = this.configuration.maxImageWidthForDiskCache;
        int height = this.configuration.maxImageHeightForDiskCache;
        if (width <= 0 && height <= 0) {
            return loaded;
        }
        L.d(LOG_RESIZE_CACHED_IMAGE_FILE, this.memoryCacheKey);
        resizeAndSaveImage(width, height);
        return loaded;
    } catch (IOException e) {
        L.e(e);
        return false;
    }
}
 
Example 4
Source File: BaseImageDecoder.java    From WliveTV with 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 File: LoadAndDisplayImageTask.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
/** @return <b>true</b> - if target ImageAware is collected by GC; <b>false</b> - otherwise */
private boolean isViewCollected() {
	if (imageAware.isCollected()) {
		L.d(LOG_TASK_CANCELLED_IMAGEAWARE_COLLECTED, memoryCacheKey);
		return true;
	}
	return false;
}
 
Example 6
Source File: LoadAndDisplayImageTask.java    From letv with Apache License 2.0 5 votes vote down vote up
private boolean isViewReused() {
    boolean imageAwareWasReused;
    if (this.memoryCacheKey.equals(this.engine.getLoadingUriForView(this.imageAware))) {
        imageAwareWasReused = false;
    } else {
        imageAwareWasReused = true;
    }
    if (!imageAwareWasReused) {
        return false;
    }
    L.d(LOG_TASK_CANCELLED_IMAGEAWARE_REUSED, this.memoryCacheKey);
    return true;
}
 
Example 7
Source File: ProcessAndDisplayImageTask.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
@Override
public void run() {
	L.d(LOG_POSTPROCESS_IMAGE, imageLoadingInfo.memoryCacheKey);

	BitmapProcessor processor = imageLoadingInfo.options.getPostProcessor();
	Bitmap processedBitmap = processor.process(bitmap);
	com.nostra13.universalimageloader.core.DisplayBitmapTask displayBitmapTask = new com.nostra13.universalimageloader.core.DisplayBitmapTask(processedBitmap, imageLoadingInfo, engine,
			LoadedFrom.MEMORY_CACHE);
	com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.runTask(displayBitmapTask, imageLoadingInfo.options.isSyncLoading(), handler, engine);
}
 
Example 8
Source File: ImageLoader.java    From letv with Apache License 2.0 5 votes vote down vote up
public void destroy() {
    if (this.configuration != null) {
        L.d(LOG_DESTROY, new Object[0]);
    }
    stop();
    this.configuration.diskCache.close();
    this.engine = null;
    this.configuration = null;
}
 
Example 9
Source File: l.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
private boolean p()
{
    if (Thread.interrupted())
    {
        Object aobj[] = new Object[1];
        aobj[0] = H;
        L.d("Task was interrupted [%s]", aobj);
        return true;
    } else
    {
        return false;
    }
}
 
Example 10
Source File: ProcessAndDisplayImageTask.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
	L.d(LOG_POSTPROCESS_IMAGE, imageLoadingInfo.memoryCacheKey);
       //获取图片处理器 然后取得加载的图片
	BitmapProcessor processor = imageLoadingInfo.options.getPostProcessor();
	Bitmap processedBitmap = processor.process(bitmap);
	//封装图片显示任务   其中图片来源设置成-来自内存缓存
	DisplayBitmapTask displayBitmapTask = new DisplayBitmapTask(processedBitmap, imageLoadingInfo, engine,
			LoadedFrom.MEMORY_CACHE);
	//执行任务
	LoadAndDisplayImageTask.runTask(displayBitmapTask, imageLoadingInfo.options.isSyncLoading(), handler, engine);
}
 
Example 11
Source File: LoadAndDisplayImageTask.java    From mobile-manager-tool with MIT License 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 12
Source File: ImageLoader.java    From candybar with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes ImageLoader instance with configuration.<br />
 * If configurations was set before ( {@link #isInited()} == true) then this method does nothing.<br />
 * To force initialization with new configuration you should {@linkplain #destroy() destroy ImageLoader} at first.
 *
 * @param configuration {@linkplain ImageLoaderConfiguration ImageLoader configuration}
 * @throws IllegalArgumentException if <b>configuration</b> parameter is null
 */
public synchronized void init(ImageLoaderConfiguration configuration) {
    if (configuration == null) {
        throw new IllegalArgumentException(ERROR_INIT_CONFIG_WITH_NULL);
    }
    if (this.configuration == null) {
        L.d(LOG_INIT_CONFIG);
        engine = new ImageLoaderEngine(configuration);
        this.configuration = configuration;
    } else {
        L.w(WARNING_RE_INIT_CONFIG);
    }
}
 
Example 13
Source File: l.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
private boolean l()
{
    if (b.isCollected())
    {
        Object aobj[] = new Object[1];
        aobj[0] = H;
        L.d("ImageAware was collected by GC. Task is cancelled. [%s]", aobj);
        return true;
    } else
    {
        return false;
    }
}
 
Example 14
Source File: BaseImageDecoder.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
protected Bitmap considerExactScaleAndOrientatiton(Bitmap subsampledBitmap, ImageDecodingInfo decodingInfo,
		int rotation, boolean flipHorizontal) {
	Matrix m = new Matrix();
	// Scale to exact size if need
	ImageScaleType scaleType = decodingInfo.getImageScaleType();
	if (scaleType == ImageScaleType.EXACTLY || scaleType == ImageScaleType.EXACTLY_STRETCHED) {
		ImageSize srcSize = new ImageSize(subsampledBitmap.getWidth(), subsampledBitmap.getHeight(), rotation);
		float scale = ImageSizeUtils.computeImageScale(srcSize, decodingInfo.getTargetSize(), decodingInfo
				.getViewScaleType(), scaleType == ImageScaleType.EXACTLY_STRETCHED);
		if (Float.compare(scale, 1f) != 0) {
			m.setScale(scale, scale);

			if (loggingEnabled) {
				L.d(LOG_SCALE_IMAGE, srcSize, srcSize.scale(scale), scale, decodingInfo.getImageKey());
			}
		}
	}
	// Flip bitmap if need
	if (flipHorizontal) {
		m.postScale(-1, 1);

		if (loggingEnabled) L.d(LOG_FLIP_IMAGE, decodingInfo.getImageKey());
	}
	// Rotate bitmap if need
	if (rotation != 0) {
		m.postRotate(rotation);

		if (loggingEnabled) L.d(LOG_ROTATE_IMAGE, rotation, decodingInfo.getImageKey());
	}

	Bitmap finalBitmap = Bitmap.createBitmap(subsampledBitmap, 0, 0, subsampledBitmap.getWidth(), subsampledBitmap
			.getHeight(), m, true);
	if (finalBitmap != subsampledBitmap) {
		subsampledBitmap.recycle();
	}
	return finalBitmap;
}
 
Example 15
Source File: DiskDecoder.java    From talk-android with MIT License 5 votes vote down vote up
protected Bitmap considerExactScaleAndOrientatiton(Bitmap subsampledBitmap, ImageDecodingInfo decodingInfo,
                                                   int rotation, boolean flipHorizontal) {
    Matrix m = new Matrix();
    // Scale to exact size if need
    ImageScaleType scaleType = decodingInfo.getImageScaleType();
    if (scaleType == ImageScaleType.EXACTLY || scaleType == ImageScaleType.EXACTLY_STRETCHED) {
        ImageSize srcSize = new ImageSize(subsampledBitmap.getWidth(), subsampledBitmap.getHeight(), rotation);
        float scale = ImageSizeUtils.computeImageScale(srcSize, decodingInfo.getTargetSize(), decodingInfo
                .getViewScaleType(), scaleType == ImageScaleType.EXACTLY_STRETCHED);
        if (Float.compare(scale, 1f) != 0) {
            m.setScale(scale, scale);

            if (loggingEnabled) {
                L.d(LOG_SCALE_IMAGE, srcSize, srcSize.scale(scale), scale, decodingInfo.getImageKey());
            }
        }
    }
    // Flip bitmap if need
    if (flipHorizontal) {
        m.postScale(-1, 1);

        if (loggingEnabled) L.d(LOG_FLIP_IMAGE, decodingInfo.getImageKey());
    }
    // Rotate bitmap if need
    if (rotation != 0) {
        m.postRotate(rotation);

        if (loggingEnabled) L.d(LOG_ROTATE_IMAGE, rotation, decodingInfo.getImageKey());
    }

    Bitmap finalBitmap = Bitmap.createBitmap(subsampledBitmap, 0, 0, subsampledBitmap.getWidth(), subsampledBitmap
            .getHeight(), m, true);
    if (finalBitmap != subsampledBitmap) {
        subsampledBitmap.recycle();
    }
    return finalBitmap;
}
 
Example 16
Source File: ImageLoader.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
/**
 * 给ImageLoder进行初始化配置项
 * Initializes ImageLoader instance with configuration.<br />
 * If configurations was set before ( {@link #isInited()} == true) then this method does nothing.<br />
 * To force initialization with new configuration you should {@linkplain #destroy() destroy ImageLoader} at first.
 *
 * @param configuration {@linkplain ImageLoaderConfiguration ImageLoader configuration}
 * @throws IllegalArgumentException if <b>configuration</b> parameter is null
 */
public synchronized void init(ImageLoaderConfiguration configuration) {
	if (configuration == null) {
		throw new IllegalArgumentException(ERROR_INIT_CONFIG_WITH_NULL);
	}
	if (this.configuration == null) {
		L.d(LOG_INIT_CONFIG);
		//创建图片加载引擎
		engine = new ImageLoaderEngine(configuration);
		this.configuration = configuration;
	} else {
		L.w(WARNING_RE_INIT_CONFIG);
	}
}
 
Example 17
Source File: LoadAndDisplayImageTask.java    From candybar with Apache License 2.0 5 votes vote down vote up
/**
 * Decodes image file into Bitmap, resize it and save it back
 */
private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException {
    // Decode image file, compress and re-save it
    boolean saved = false;
    File targetFile = configuration.diskCache.get(uri);
    if (targetFile != null && targetFile.exists()) {
        ImageSize targetImageSize = new ImageSize(maxWidth, maxHeight);
        DisplayImageOptions specialOptions = new DisplayImageOptions.Builder().cloneFrom(options)
                .imageScaleType(ImageScaleType.IN_SAMPLE_INT).build();
        ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey,
                Scheme.FILE.wrap(targetFile.getAbsolutePath()), uri, targetImageSize, ViewScaleType.FIT_INSIDE,
                getDownloader(), specialOptions);
        Bitmap bmp = decoder.decode(decodingInfo);
        if (bmp != null && configuration.processorForDiskCache != null) {
            L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, memoryCacheKey);
            bmp = configuration.processorForDiskCache.process(bmp);
            if (bmp == null) {
                L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, memoryCacheKey);
            }
        }
        if (bmp != null) {
            saved = configuration.diskCache.save(uri, bmp);
            bmp.recycle();
        }
    }
    return saved;
}
 
Example 18
Source File: ImageLoader.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void destroy()
{
    if (h != null)
    {
        L.d("Destroy ImageLoader", new Object[0]);
    }
    stop();
    h.o.close();
    i = null;
    h = null;
}
 
Example 19
Source File: ImageLoader.java    From letv with Apache License 2.0 5 votes vote down vote up
public synchronized void init(ImageLoaderConfiguration configuration) {
    if (configuration == null) {
        throw new IllegalArgumentException(ERROR_INIT_CONFIG_WITH_NULL);
    } else if (this.configuration == null) {
        L.d(LOG_INIT_CONFIG, new Object[0]);
        this.engine = new ImageLoaderEngine(configuration);
        this.configuration = configuration;
    } else {
        L.w(WARNING_RE_INIT_CONFIG, new Object[0]);
    }
}
 
Example 20
Source File: MyHistoryAdapter.java    From Conquer with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(context).inflate(R.layout.item_history, parent, false);
    }
    Card card = list.get(position);
    for (Card c : list)
        L.d(c.toString());
    CircularImageView iv_photo = ViewHolder.get(convertView, R.id.iv_photo);
    TextView tv_from = ViewHolder.get(convertView, R.id.tv_from);
    TextView tv_type = ViewHolder.get(convertView, R.id.tv_type);
    TextView tv_time = ViewHolder.get(convertView, R.id.tv_time);
    TextView tv_zixiname = ViewHolder.get(convertView, R.id.tv_zixiname);
    TextView tv_content = ViewHolder.get(convertView, R.id.tv_content);
    View ll_audio = ViewHolder.get(convertView, R.id.ll_audio);
    ImageView iv = ViewHolder.get(convertView, R.id.iv);
    View loading = ViewHolder.get(convertView, R.id.loading);
    tv_from.setText(card.getFnick());
    if (card.getType() == 0) {
        tv_type.setText("任务提醒");
        tv_type.setTextColor(context.getResources().getColor(R.color.blue_normal));
    } else {
        tv_type.setText("任务勾搭");
        tv_type.setTextColor(context.getResources().getColor(R.color.red_button));
    }
    tv_time
            .setText(TimeUtil.getDescriptionTimeFromTimestamp(TimeUtil.stringToLong(card.getCreatedAt(), TimeUtil.FORMAT_DATE_TIME_SECOND2)));
    tv_zixiname.setText(card.getZixiName());
    tv_content.setText(card.getContent());
    loading.setVisibility(View.GONE);
    ll_audio.setVisibility(View.GONE);

    if (!TextUtils.isEmpty(card.getAudioUrl())) {
        ll_audio.setVisibility(View.VISIBLE);
        initAudio(ll_audio, card.getAudioUrl());
    }
    if (!TextUtils.isEmpty(card.getImgUrl())) {
        iv.setVisibility(View.VISIBLE);
        initAlbum(iv, card.getImgUrl());
    }

    loader.displayImage(card.getFavatar(), iv_photo);
    return convertView;
}