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


Java ViewScaleType类代码示例

本文整理汇总了Java中com.nostra13.universalimageloader.core.assist.ViewScaleType的典型用法代码示例。如果您正苦于以下问题:Java ViewScaleType类的具体用法?Java ViewScaleType怎么用?Java ViewScaleType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ViewScaleType类属于com.nostra13.universalimageloader.core.assist包,在下文中一共展示了ViewScaleType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ImageDecodingInfo

import com.nostra13.universalimageloader.core.assist.ViewScaleType; //导入依赖的package包/类
public ImageDecodingInfo(String imageKey, String imageUri, String originalImageUri, ImageSize targetSize, ViewScaleType viewScaleType,
						 ImageDownloader downloader, DisplayImageOptions displayOptions) {
	this.imageKey = imageKey;
	this.imageUri = imageUri;
	this.originalImageUri = originalImageUri;
	this.targetSize = targetSize;

	this.imageScaleType = displayOptions.getImageScaleType();
	this.viewScaleType = viewScaleType;

	this.downloader = downloader;
	this.extraForDownloader = displayOptions.getExtraForDownloader();

	considerExifParams = displayOptions.isConsiderExifParams();
	decodingOptions = new Options();
	copyOptions(displayOptions.getDecodingOptions(), decodingOptions);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:ImageDecodingInfo.java

示例2: computeImageScale

import com.nostra13.universalimageloader.core.assist.ViewScaleType; //导入依赖的package包/类
public static float computeImageScale(ImageSize srcSize, ImageSize targetSize, ViewScaleType viewScaleType, boolean stretch) {
    int destWidth;
    int srcWidth = srcSize.getWidth();
    int srcHeight = srcSize.getHeight();
    int targetWidth = targetSize.getWidth();
    int targetHeight = targetSize.getHeight();
    float widthScale = ((float) srcWidth) / ((float) targetWidth);
    float heightScale = ((float) srcHeight) / ((float) targetHeight);
    int destHeight;
    if ((viewScaleType != ViewScaleType.FIT_INSIDE || widthScale < heightScale) && (viewScaleType != ViewScaleType.CROP || widthScale >= heightScale)) {
        destWidth = (int) (((float) srcWidth) / heightScale);
        destHeight = targetHeight;
    } else {
        destWidth = targetWidth;
        destHeight = (int) (((float) srcHeight) / widthScale);
    }
    if ((stretch || destWidth >= srcWidth || destHeight >= srcHeight) && (!stretch || destWidth == srcWidth || destHeight == srcHeight)) {
        return 1.0f;
    }
    return ((float) destWidth) / ((float) srcWidth);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:22,代码来源:ImageSizeUtils.java

示例3: resizeAndSaveImage

import com.nostra13.universalimageloader.core.assist.ViewScaleType; //导入依赖的package包/类
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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:21,代码来源:LoadAndDisplayImageTask.java

示例4: computeImageScale

import com.nostra13.universalimageloader.core.assist.ViewScaleType; //导入依赖的package包/类
public static float computeImageScale(ImageSize srcSize, ImageSize targetSize, ViewScaleType
        viewScaleType, boolean stretch) {
    int destWidth;
    int srcWidth = srcSize.getWidth();
    int srcHeight = srcSize.getHeight();
    int targetWidth = targetSize.getWidth();
    int targetHeight = targetSize.getHeight();
    float widthScale = ((float) srcWidth) / ((float) targetWidth);
    float heightScale = ((float) srcHeight) / ((float) targetHeight);
    int destHeight;
    if ((viewScaleType != ViewScaleType.FIT_INSIDE || widthScale < heightScale) &&
            (viewScaleType != ViewScaleType.CROP || widthScale >= heightScale)) {
        destWidth = (int) (((float) srcWidth) / heightScale);
        destHeight = targetHeight;
    } else {
        destWidth = targetWidth;
        destHeight = (int) (((float) srcHeight) / widthScale);
    }
    if ((stretch || destWidth >= srcWidth || destHeight >= srcHeight) && (!stretch ||
            destWidth == srcWidth || destHeight == srcHeight)) {
        return 1.0f;
    }
    return ((float) destWidth) / ((float) srcWidth);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:25,代码来源:ImageSizeUtils.java

示例5: resizeAndSaveImage

import com.nostra13.universalimageloader.core.assist.ViewScaleType; //导入依赖的package包/类
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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:24,代码来源:LoadAndDisplayImageTask.java

示例6: tryLoadBitmap

import com.nostra13.universalimageloader.core.assist.ViewScaleType; //导入依赖的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

示例7: loadImage

import com.nostra13.universalimageloader.core.assist.ViewScaleType; //导入依赖的package包/类
public void loadImage(String s, ImageSize imagesize, DisplayImageOptions displayimageoptions, ImageLoadingListener imageloadinglistener, ImageLoadingProgressListener imageloadingprogresslistener)
{
    a();
    if (imagesize == null)
    {
        imagesize = h.a();
    }
    DisplayImageOptions displayimageoptions1;
    if (displayimageoptions == null)
    {
        displayimageoptions1 = h.r;
    } else
    {
        displayimageoptions1 = displayimageoptions;
    }
    displayImage(s, new NonViewAware(s, imagesize, ViewScaleType.CROP), displayimageoptions1, imageloadinglistener, imageloadingprogresslistener);
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:18,代码来源:ImageLoader.java

示例8: NonViewAware

import com.nostra13.universalimageloader.core.assist.ViewScaleType; //导入依赖的package包/类
public NonViewAware(String s, ImageSize imagesize, ViewScaleType viewscaletype)
{
    if (imagesize == null)
    {
        throw new IllegalArgumentException("imageSize must not be null");
    }
    if (viewscaletype == null)
    {
        throw new IllegalArgumentException("scaleType must not be null");
    } else
    {
        imageUri = s;
        imageSize = imagesize;
        scaleType = viewscaletype;
        return;
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:18,代码来源:NonViewAware.java

示例9: ImageDecodingInfo

import com.nostra13.universalimageloader.core.assist.ViewScaleType; //导入依赖的package包/类
public ImageDecodingInfo(String imageKey, String imageUri, ImageSize targetSize, ViewScaleType viewScaleType,
						 ImageDownloader downloader, DisplayImageOptions displayOptions) {
	this.imageKey = imageKey;
	this.imageUri = imageUri;
	this.targetSize = targetSize;

	this.imageScaleType = displayOptions.getImageScaleType();
	this.viewScaleType = viewScaleType;

	this.downloader = downloader;
	this.extraForDownloader = displayOptions.getExtraForDownloader();

	considerExifParams = displayOptions.isConsiderExifParams();
	decodingOptions = new Options();
	copyOptions(displayOptions.getDecodingOptions(), decodingOptions);
}
 
开发者ID:Apokrif,项目名称:morse,代码行数:17,代码来源:ImageDecodingInfo.java

示例10: computeImageScale

import com.nostra13.universalimageloader.core.assist.ViewScaleType; //导入依赖的package包/类
/**
 * Computes scale of target size (<b>targetSize</b>) to source size (<b>srcSize</b>).<br />
 * <br />
 * <b>Examples:</b><br />
 * <p/>
 * <pre>
 * srcSize(40x40), targetSize(10x10) -> scale = 0.25
 *
 * srcSize(10x10), targetSize(20x20), stretch = false -> scale = 1
 * srcSize(10x10), targetSize(20x20), stretch = true  -> scale = 2
 *
 * srcSize(100x100), targetSize(20x40), viewScaleType = FIT_INSIDE -> scale = 0.2
 * srcSize(100x100), targetSize(20x40), viewScaleType = CROP       -> scale = 0.4
 * </pre>
 *
 * @param srcSize       Source (image) size
 * @param targetSize    Target (view) size
 * @param viewScaleType {@linkplain ViewScaleType Scale type} for placing image in view
 * @param stretch       Whether source size should be stretched if target size is larger than source size. If <b>false</b>
 *                      then result scale value can't be greater than 1.
 * @return Computed scale
 */
public static float computeImageScale(ImageSize srcSize, ImageSize targetSize, ViewScaleType viewScaleType,
		boolean stretch) {
	final int srcWidth = srcSize.getWidth();
	final int srcHeight = srcSize.getHeight();
	final int targetWidth = targetSize.getWidth();
	final int targetHeight = targetSize.getHeight();

	final float widthScale = (float) srcWidth / targetWidth;
	final float heightScale = (float) srcHeight / targetHeight;

	final int destWidth;
	final int destHeight;
	if ((viewScaleType == ViewScaleType.FIT_INSIDE && widthScale >= heightScale) || (viewScaleType == ViewScaleType.CROP && widthScale < heightScale)) {
		destWidth = targetWidth;
		destHeight = (int) (srcHeight / widthScale);
	} else {
		destWidth = (int) (srcWidth / heightScale);
		destHeight = targetHeight;
	}

	float scale = 1;
	if ((!stretch && destWidth < srcWidth && destHeight < srcHeight) || (stretch && destWidth != srcWidth && destHeight != srcHeight)) {
		scale = (float) destWidth / srcWidth;
	}

	return scale;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:50,代码来源:ImageSizeUtils.java

示例11: resizeAndSaveImage

import com.nostra13.universalimageloader.core.assist.ViewScaleType; //导入依赖的package包/类
/** 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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:LoadAndDisplayImageTask.java

示例12: getScaleType

import com.nostra13.universalimageloader.core.assist.ViewScaleType; //导入依赖的package包/类
@Override
public ViewScaleType getScaleType() {
	ImageView imageView = (ImageView) viewRef.get();
	if (imageView != null) {
		return ViewScaleType.fromImageView(imageView);
	}
	return super.getScaleType();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:ImageViewAware.java

示例13: NonViewAware

import com.nostra13.universalimageloader.core.assist.ViewScaleType; //导入依赖的package包/类
public NonViewAware(String imageUri, ImageSize imageSize, ViewScaleType scaleType) {
	if (imageSize == null) throw new IllegalArgumentException("imageSize must not be null");
	if (scaleType == null) throw new IllegalArgumentException("scaleType must not be null");

	this.imageUri = imageUri;
	this.imageSize = imageSize;
	this.scaleType = scaleType;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:NonViewAware.java

示例14: computeImageSampleSize

import com.nostra13.universalimageloader.core.assist.ViewScaleType; //导入依赖的package包/类
public static int computeImageSampleSize(ImageSize srcSize, ImageSize targetSize, ViewScaleType viewScaleType, boolean powerOf2Scale) {
    int srcWidth = srcSize.getWidth();
    int srcHeight = srcSize.getHeight();
    int targetWidth = targetSize.getWidth();
    int targetHeight = targetSize.getHeight();
    int scale = 1;
    int halfWidth;
    int halfHeight;
    switch (viewScaleType) {
        case FIT_INSIDE:
            if (!powerOf2Scale) {
                scale = Math.max(srcWidth / targetWidth, srcHeight / targetHeight);
                break;
            }
            halfWidth = srcWidth / 2;
            halfHeight = srcHeight / 2;
            while (true) {
                if (halfWidth / scale <= targetWidth && halfHeight / scale <= targetHeight) {
                    break;
                }
                scale *= 2;
            }
            break;
        case CROP:
            if (!powerOf2Scale) {
                scale = Math.min(srcWidth / targetWidth, srcHeight / targetHeight);
                break;
            }
            halfWidth = srcWidth / 2;
            halfHeight = srcHeight / 2;
            while (halfWidth / scale > targetWidth && halfHeight / scale > targetHeight) {
                scale *= 2;
            }
            break;
    }
    if (scale < 1) {
        scale = 1;
    }
    return considerMaxTextureSize(srcWidth, srcHeight, scale, powerOf2Scale);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:41,代码来源:ImageSizeUtils.java

示例15: ImageDecodingInfo

import com.nostra13.universalimageloader.core.assist.ViewScaleType; //导入依赖的package包/类
public ImageDecodingInfo(String imageKey, String imageUri, String originalImageUri, ImageSize targetSize, ViewScaleType viewScaleType, ImageDownloader downloader, DisplayImageOptions displayOptions) {
    this.imageKey = imageKey;
    this.imageUri = imageUri;
    this.originalImageUri = originalImageUri;
    this.targetSize = targetSize;
    this.imageScaleType = displayOptions.getImageScaleType();
    this.viewScaleType = viewScaleType;
    this.downloader = downloader;
    this.extraForDownloader = displayOptions.getExtraForDownloader();
    this.considerExifParams = displayOptions.isConsiderExifParams();
    copyOptions(displayOptions.getDecodingOptions(), this.decodingOptions);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:13,代码来源:ImageDecodingInfo.java


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