当前位置: 首页>>代码示例>>Java>>正文


Java ImageSizeUtils.defineTargetSizeForView方法代码示例

本文整理汇总了Java中com.nostra13.universalimageloader.utils.ImageSizeUtils.defineTargetSizeForView方法的典型用法代码示例。如果您正苦于以下问题:Java ImageSizeUtils.defineTargetSizeForView方法的具体用法?Java ImageSizeUtils.defineTargetSizeForView怎么用?Java ImageSizeUtils.defineTargetSizeForView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.nostra13.universalimageloader.utils.ImageSizeUtils的用法示例。


在下文中一共展示了ImageSizeUtils.defineTargetSizeForView方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tryLoadBitmap

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入方法依赖的package包/类
Bitmap tryLoadBitmap(ImageViewAware imageAware) {
    Bitmap bitmap = null;
    try {
        java.io.File imageFile = diskCache.get(getMessage().get_id());
        if (imageFile != null && imageFile.exists() && imageFile.length() > 0) {
            ViewScaleType viewScaleType = imageAware.getScaleType();
            ImageSize imageSize = ImageSizeUtils.defineTargetSizeForView(imageAware, new ImageSize(MainApp.CONTEXT.getResources().getDisplayMetrics().widthPixels, MainApp.CONTEXT.getResources().getDisplayMetrics().heightPixels));
            ImageDecodingInfo decodingInfo = new ImageDecodingInfo(getMessage().get_id(),
                    ImageDownloader.Scheme.FILE.wrap(imageFile.getAbsolutePath()), getMessage().get_id(), imageSize, viewScaleType,
                    new BaseImageDownloader(MainApp.CONTEXT), options);
            bitmap = decoder.decode(decodingInfo);
            MainApp.memoryCache.put(getMessage().get_id(), bitmap);
        }
    } catch (Exception ignored) {
        ignored.printStackTrace();
    }
    return bitmap;
}
 
开发者ID:jianliaoim,项目名称:talk-android,代码行数:19,代码来源:VideoRow.java

示例2: testGetImageSizeScaleTo_useImageActualSize

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入方法依赖的package包/类
@Test
public void testGetImageSizeScaleTo_useImageActualSize() throws Exception {
	// We layout the view to give it a width and height
	mView.measure(View.MeasureSpec.makeMeasureSpec(200, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(200, View.MeasureSpec.EXACTLY));
	mView.layout(0, 0, 200, 200);

	ImageSize expected = new ImageSize(200, 200);
	ImageSize result = ImageSizeUtils.defineTargetSizeForView(mImageAware, new ImageSize(590, 590));
	Assertions.assertThat(result).isNotNull();
	Assertions.assertThat(result.getWidth()).isEqualTo(expected.getWidth());
	Assertions.assertThat(result.getHeight()).isEqualTo(expected.getHeight());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:ImageSizeTest.java

示例3: testGetImageSizeScaleTo_dontUseImageActualSizeWithWrapContent

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入方法依赖的package包/类
/**
 * This will make sure the view falls back to the ViewParams/Max/Or Config if wrap content so that it is never
 * shrunk to the first image size. In this case it falls back to the config size
 * 
 * @throws Exception
 */
@Test
public void testGetImageSizeScaleTo_dontUseImageActualSizeWithWrapContent() throws Exception {
	//Set it to wrap content so that it will fall back to
	mView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
	mView.measure(View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY));
	// We layout the view to give it a width and height
	mView.layout(0, 0, 200, 200);

	ImageSize expected = new ImageSize(500, 500);
	ImageSize result = ImageSizeUtils.defineTargetSizeForView(mImageAware, new ImageSize(500, 500));
	Assertions.assertThat(result).isNotNull().isEqualsToByComparingFields(expected);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:ImageSizeTest.java

示例4: testGetImageSizeScaleTo_useImageLayoutParams

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入方法依赖的package包/类
@Test
public void testGetImageSizeScaleTo_useImageLayoutParams() throws Exception {
	// Set a defined width
	mView.setLayoutParams(new FrameLayout.LayoutParams(300, 300));

	ImageSize expected = new ImageSize(300, 300);
	ImageSize result = ImageSizeUtils.defineTargetSizeForView(mImageAware, new ImageSize(500, 500));
	Assertions.assertThat(result).isNotNull().isEqualsToByComparingFields(expected);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:ImageSizeTest.java

示例5: testGetImageSizeScaleTo_useImageConfigMaxSize

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入方法依赖的package包/类
@Test
public void testGetImageSizeScaleTo_useImageConfigMaxSize() throws Exception {
	ImageSize expected = new ImageSize(500, 500);
	ImageSize result = ImageSizeUtils.defineTargetSizeForView(mImageAware, new ImageSize(500, 500));
	Assertions.assertThat(result).isNotNull().isEqualsToByComparingFields(expected);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:ImageSizeTest.java

示例6: displayImage

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入方法依赖的package包/类
public void displayImage(String uri, ImageAware imageAware, DisplayImageOptions options, ImageLoadingListener listener, ImageLoadingProgressListener progressListener) {
    checkConfiguration();
    if (imageAware == null) {
        throw new IllegalArgumentException(ERROR_WRONG_ARGUMENTS);
    }
    if (listener == null) {
        listener = this.emptyListener;
    }
    if (options == null) {
        options = this.configuration.defaultDisplayImageOptions;
    }
    if (TextUtils.isEmpty(uri)) {
        this.engine.cancelDisplayTaskFor(imageAware);
        listener.onLoadingStarted(uri, imageAware.getWrappedView());
        if (options.shouldShowImageForEmptyUri()) {
            imageAware.setImageDrawable(options.getImageForEmptyUri(this.configuration.resources));
        } else {
            imageAware.setImageDrawable(null);
        }
        listener.onLoadingComplete(uri, imageAware.getWrappedView(), null);
        return;
    }
    ImageSize targetSize = ImageSizeUtils.defineTargetSizeForView(imageAware, this.configuration.getMaxImageSize());
    String memoryCacheKey = MemoryCacheUtils.generateKey(uri, targetSize);
    this.engine.prepareDisplayTaskFor(imageAware, memoryCacheKey);
    listener.onLoadingStarted(uri, imageAware.getWrappedView());
    Bitmap bmp = (Bitmap) this.configuration.memoryCache.get(memoryCacheKey);
    if (bmp == null || bmp.isRecycled()) {
        if (options.shouldShowImageOnLoading()) {
            imageAware.setImageDrawable(options.getImageOnLoading(this.configuration.resources));
        } else if (options.isResetViewBeforeLoading()) {
            imageAware.setImageDrawable(null);
        }
        LoadAndDisplayImageTask displayTask = new LoadAndDisplayImageTask(this.engine, new ImageLoadingInfo(uri, imageAware, targetSize, memoryCacheKey, options, listener, progressListener, this.engine.getLockForUri(uri)), defineHandler(options));
        if (options.isSyncLoading()) {
            displayTask.run();
            return;
        } else {
            this.engine.submit(displayTask);
            return;
        }
    }
    L.d(LOG_LOAD_IMAGE_FROM_MEMORY_CACHE, memoryCacheKey);
    if (options.shouldPostProcess()) {
        ProcessAndDisplayImageTask displayTask2 = new ProcessAndDisplayImageTask(this.engine, bmp, new ImageLoadingInfo(uri, imageAware, targetSize, memoryCacheKey, options, listener, progressListener, this.engine.getLockForUri(uri)), defineHandler(options));
        if (options.isSyncLoading()) {
            displayTask2.run();
            return;
        } else {
            this.engine.submit(displayTask2);
            return;
        }
    }
    options.getDisplayer().display(bmp, imageAware, LoadedFrom.MEMORY_CACHE);
    listener.onLoadingComplete(uri, imageAware.getWrappedView(), bmp);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:57,代码来源:ImageLoader.java

示例7: displayImage

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入方法依赖的package包/类
public void displayImage(String uri, ImageAware imageAware, DisplayImageOptions options,
                         ImageSize targetSize, ImageLoadingListener listener,
                         ImageLoadingProgressListener progressListener) {
    checkConfiguration();
    if (imageAware == null) {
        throw new IllegalArgumentException(ERROR_WRONG_ARGUMENTS);
    }
    if (listener == null) {
        listener = this.defaultListener;
    }
    if (options == null) {
        options = this.configuration.defaultDisplayImageOptions;
    }
    if (TextUtils.isEmpty(uri)) {
        this.engine.cancelDisplayTaskFor(imageAware);
        listener.onLoadingStarted(uri, imageAware.getWrappedView());
        if (options.shouldShowImageForEmptyUri()) {
            imageAware.setImageDrawable(options.getImageForEmptyUri(this.configuration
                    .resources));
        } else {
            imageAware.setImageDrawable(null);
        }
        listener.onLoadingComplete(uri, imageAware.getWrappedView(), null);
        return;
    }
    if (targetSize == null) {
        targetSize = ImageSizeUtils.defineTargetSizeForView(imageAware, this.configuration
                .getMaxImageSize());
    }
    String memoryCacheKey = MemoryCacheUtils.generateKey(uri, targetSize);
    this.engine.prepareDisplayTaskFor(imageAware, memoryCacheKey);
    listener.onLoadingStarted(uri, imageAware.getWrappedView());
    Bitmap bmp = this.configuration.memoryCache.get(memoryCacheKey);
    if (bmp == null || bmp.isRecycled()) {
        if (options.shouldShowImageOnLoading()) {
            imageAware.setImageDrawable(options.getImageOnLoading(this.configuration
                    .resources));
        } else if (options.isResetViewBeforeLoading()) {
            imageAware.setImageDrawable(null);
        }
        LoadAndDisplayImageTask displayTask = new LoadAndDisplayImageTask(this.engine, new
                ImageLoadingInfo(uri, imageAware, targetSize, memoryCacheKey, options,
                listener, progressListener, this.engine.getLockForUri(uri)), defineHandler
                (options));
        if (options.isSyncLoading()) {
            displayTask.run();
            return;
        } else {
            this.engine.submit(displayTask);
            return;
        }
    }
    L.d(LOG_LOAD_IMAGE_FROM_MEMORY_CACHE, memoryCacheKey);
    if (options.shouldPostProcess()) {
        ProcessAndDisplayImageTask displayTask2 = new ProcessAndDisplayImageTask(this.engine,
                bmp, new ImageLoadingInfo(uri, imageAware, targetSize, memoryCacheKey,
                options, listener, progressListener, this.engine.getLockForUri(uri)),
                defineHandler(options));
        if (options.isSyncLoading()) {
            displayTask2.run();
            return;
        } else {
            this.engine.submit(displayTask2);
            return;
        }
    }
    options.getDisplayer().display(bmp, imageAware, LoadedFrom.MEMORY_CACHE);
    listener.onLoadingComplete(uri, imageAware.getWrappedView(), bmp);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:70,代码来源:ImageLoader.java


注:本文中的com.nostra13.universalimageloader.utils.ImageSizeUtils.defineTargetSizeForView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。