com.nostra13.universalimageloader.core.download.ImageDownloader.Scheme Java Examples

The following examples show how to use com.nostra13.universalimageloader.core.download.ImageDownloader.Scheme. 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: MediaPreviewCameraActivity.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    setContentView(R.layout.zg_activity_media_camera_preview);
    findViewById(R.id.iv_left).setOnClickListener(this);
    findViewById(R.id.tv_right).setOnClickListener(this);
    ((TextView) findViewById(R.id.title))
            .setText(R.string.zg_content_media_pic_preview);

    mProgress = (ProgressBar) findViewById(R.id.progressBar);
    mImageView = (ImageView) findViewById(R.id.imageview);

    mMediaInfo = (MediaInfo) getIntent().getExtras().getSerializable(
            MediaConstants.MEDIA_REQUEST_DATAS);

    ViewerImageLoader.getInstance().displayImage(
            Scheme.FILE.wrap(mMediaInfo.filePath), mImageView, this);
}
 
Example #2
Source File: BaseImageDownloader.java    From letv with Apache License 2.0 6 votes vote down vote up
public InputStream getStream(String imageUri, Object extra) throws IOException {
    switch (Scheme.ofUri(imageUri)) {
        case HTTP:
        case HTTPS:
            return getStreamFromNetwork(imageUri, extra);
        case FILE:
            return getStreamFromFile(imageUri, extra);
        case CONTENT:
            return getStreamFromContent(imageUri, extra);
        case ASSETS:
            return getStreamFromAssets(imageUri, extra);
        case DRAWABLE:
            return getStreamFromDrawable(imageUri, extra);
        default:
            return getStreamFromOtherSource(imageUri, extra);
    }
}
 
Example #3
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 #4
Source File: BaseImageDownloaderTest.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeAssets() throws Exception {
	String uri = "assets://folder/1.png";
	Scheme result = Scheme.ofUri(uri);
	Scheme expected = Scheme.ASSETS;
	Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #5
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 #6
Source File: MediaCatalogAdapter.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	ViewHolder holder;
	if (convertView == null) {
		holder = new ViewHolder();
		convertView = inflate.inflate(R.layout.zg_adapter_item_catalog,
				null);
		holder.tv_catalog = (TextView) convertView
				.findViewById(R.id.tv_catalog);
		holder.iv_preview = (ImageView) convertView
				.findViewById(R.id.iv_preview);
		holder.iv_select = (ImageView) convertView
				.findViewById(R.id.iv_select);
		convertView.setTag(holder);
	} else {
		holder = (ViewHolder) convertView.getTag();
	}
	MediaInfo file = getItem(position);
	if (file != null && !TextUtils.isEmpty(file.filePath)) {
		if (position == 0) {
			holder.tv_catalog.setText(getMediaText(mMediaType, context));
		} else {
			holder.tv_catalog.setText(new File(file.filePath)
					.getParentFile().getName());
		}

		if (position == select) {
			holder.iv_select.setVisibility(View.VISIBLE);
		} else {
			holder.iv_select.setVisibility(View.GONE);
		}
		mImageLoader.displayImageAndCachedMemory(
				Scheme.FILE.wrap(file.filePath), holder.iv_preview);
	}
	return convertView;
}
 
Example #7
Source File: MediaDetailFragment.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
private String getImageUrl(boolean display) {
	if (mMediaInfo == null) {
		return "";
	}
	if (mMediaInfo.type == 0) {
		return mMediaInfo.url;
	} else {
		return display ? Scheme.FILE.wrap(mMediaInfo.filePath)
				: mMediaInfo.filePath;
	}
}
 
Example #8
Source File: LoadAndDisplayImageTask.java    From WliveTV 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 #9
Source File: BaseImageDecoder.java    From WliveTV with Apache License 2.0 5 votes vote down vote up
protected ExifInfo defineExifOrientation(String imageUri) {
	int rotation = 0;
	boolean flip = false;
	try {
		ExifInterface exif = new ExifInterface(Scheme.FILE.crop(imageUri));
		int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
		switch (exifOrientation) {
			case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
				flip = true;
			case ExifInterface.ORIENTATION_NORMAL:
				rotation = 0;
				break;
			case ExifInterface.ORIENTATION_TRANSVERSE:
				flip = true;
			case ExifInterface.ORIENTATION_ROTATE_90:
				rotation = 90;
				break;
			case ExifInterface.ORIENTATION_FLIP_VERTICAL:
				flip = true;
			case ExifInterface.ORIENTATION_ROTATE_180:
				rotation = 180;
				break;
			case ExifInterface.ORIENTATION_TRANSPOSE:
				flip = true;
			case ExifInterface.ORIENTATION_ROTATE_270:
				rotation = 270;
				break;
		}
	} catch (IOException e) {
		L.w("Can't read EXIF tags from file [%s]", imageUri);
	}
	return new ExifInfo(rotation, flip);
}
 
Example #10
Source File: LoadAndDisplayImageTask.java    From Android-Universal-Image-Loader-Modify 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()) {
		//构建图片尺寸size对象
		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 #11
Source File: BaseImageDecoder.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
protected ExifInfo defineExifOrientation(String imageUri) {
	int rotation = 0;
	boolean flip = false;
	try {
		ExifInterface exif = new ExifInterface(Scheme.FILE.crop(imageUri));
		int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
		switch (exifOrientation) {
			case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
				flip = true;
			case ExifInterface.ORIENTATION_NORMAL:
				rotation = 0;
				break;
			case ExifInterface.ORIENTATION_TRANSVERSE:
				flip = true;
			case ExifInterface.ORIENTATION_ROTATE_90:
				rotation = 90;
				break;
			case ExifInterface.ORIENTATION_FLIP_VERTICAL:
				flip = true;
			case ExifInterface.ORIENTATION_ROTATE_180:
				rotation = 180;
				break;
			case ExifInterface.ORIENTATION_TRANSPOSE:
				flip = true;
			case ExifInterface.ORIENTATION_ROTATE_270:
				rotation = 270;
				break;
		}
	} catch (IOException e) {
		L.w("Can't read EXIF tags from file [%s]", imageUri);
	}
	return new ExifInfo(rotation, flip);
}
 
Example #12
Source File: BaseImageDownloaderTest.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeHttp() throws Exception {
	String uri = "http://image.com/1.png";
	Scheme result = Scheme.ofUri(uri);
	Scheme expected = Scheme.HTTP;
	Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #13
Source File: BaseImageDownloaderTest.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeHttps() throws Exception {
	String uri = "https://image.com/1.png";
	Scheme result = Scheme.ofUri(uri);
	Scheme expected = Scheme.HTTPS;
	Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #14
Source File: BaseImageDownloaderTest.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeContent() throws Exception {
	String uri = "content://path/to/content";
	Scheme result = Scheme.ofUri(uri);
	Scheme expected = Scheme.CONTENT;
	Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #15
Source File: AdapterGridAdd.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	ViewHolder holder = null;
	if (convertView == null) {
		holder = new ViewHolder();
		convertView = inflate.inflate(R.layout.zg_adapter_item_grid_add,
				null);
		holder.imageView = (ImageView) convertView
				.findViewById(R.id.imageview);
		convertView.setTag(holder);
	} else {
		holder = (ViewHolder) convertView.getTag();
	}
	ViewGroup.LayoutParams params = holder.imageView.getLayoutParams();
	params.height = getImageWidth(parent);
	holder.imageView.setLayoutParams(params);
	MediaInfo info = getItem(position);
	if (info != null && "Add".equals(info.filePath)) {
		holder.imageView.setBackgroundColor(Color.parseColor("#41D0A4"));
		holder.imageView.setScaleType(ScaleType.CENTER);
		mImageLoader.displayImageAndCached(
				Scheme.DRAWABLE.wrap("" + R.drawable.zg_default_add),
				holder.imageView);
	} else if (info != null) {
		holder.imageView.setScaleType(ScaleType.CENTER_CROP);
		if (info.type == 0) {
			mImageLoader.displayImageAndCached(info.url, holder.imageView);
		} else {
			mImageLoader.displayImageAndCached(
					Scheme.FILE.wrap(info.filePath), holder.imageView);
		}
	}
	return convertView;
}
 
Example #16
Source File: BaseImageDownloaderTest.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeDrawables() throws Exception {
	String uri = "drawable://123456890";
	Scheme result = Scheme.ofUri(uri);
	Scheme expected = Scheme.DRAWABLE;
	Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #17
Source File: BaseImageDownloaderTest.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeFile() throws Exception {
	String uri = "file://path/on/the/device/1.png";
	Scheme result = Scheme.ofUri(uri);
	Scheme expected = Scheme.FILE;
	Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #18
Source File: BaseImageDownloaderTest.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeUnknown() throws Exception {
	String uri = "other://image.com/1.png";
	Scheme result = Scheme.ofUri(uri);
	Scheme expected = Scheme.UNKNOWN;
	Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #19
Source File: LoadAndDisplayImageTask.java    From android-open-project-demo 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 #20
Source File: BaseImageDecoder.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
protected ExifInfo defineExifOrientation(String imageUri) {
	int rotation = 0;
	boolean flip = false;
	try {
		ExifInterface exif = new ExifInterface(Scheme.FILE.crop(imageUri));
		int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
		switch (exifOrientation) {
			case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
				flip = true;
			case ExifInterface.ORIENTATION_NORMAL:
				rotation = 0;
				break;
			case ExifInterface.ORIENTATION_TRANSVERSE:
				flip = true;
			case ExifInterface.ORIENTATION_ROTATE_90:
				rotation = 90;
				break;
			case ExifInterface.ORIENTATION_FLIP_VERTICAL:
				flip = true;
			case ExifInterface.ORIENTATION_ROTATE_180:
				rotation = 180;
				break;
			case ExifInterface.ORIENTATION_TRANSPOSE:
				flip = true;
			case ExifInterface.ORIENTATION_ROTATE_270:
				rotation = 270;
				break;
		}
	} catch (IOException e) {
		L.w("Can't read EXIF tags from file [%s]", imageUri);
	}
	return new ExifInfo(rotation, flip);
}
 
Example #21
Source File: BaseImageDownloaderTest.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeHttp() throws Exception {
	String uri = "http://image.com/1.png";
	Scheme result = Scheme.ofUri(uri);
	Scheme expected = Scheme.HTTP;
	Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #22
Source File: BaseImageDownloaderTest.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeHttps() throws Exception {
	String uri = "https://image.com/1.png";
	Scheme result = Scheme.ofUri(uri);
	Scheme expected = Scheme.HTTPS;
	Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #23
Source File: BaseImageDownloaderTest.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeContent() throws Exception {
	String uri = "content://path/to/content";
	Scheme result = Scheme.ofUri(uri);
	Scheme expected = Scheme.CONTENT;
	Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #24
Source File: BaseImageDownloaderTest.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeAssets() throws Exception {
	String uri = "assets://folder/1.png";
	Scheme result = Scheme.ofUri(uri);
	Scheme expected = Scheme.ASSETS;
	Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #25
Source File: BaseImageDownloaderTest.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeDrawables() throws Exception {
	String uri = "drawable://123456890";
	Scheme result = Scheme.ofUri(uri);
	Scheme expected = Scheme.DRAWABLE;
	Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #26
Source File: BaseImageDownloaderTest.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeFile() throws Exception {
	String uri = "file://path/on/the/device/1.png";
	Scheme result = Scheme.ofUri(uri);
	Scheme expected = Scheme.FILE;
	Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #27
Source File: BaseImageDownloaderTest.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeUnknown() throws Exception {
	String uri = "other://image.com/1.png";
	Scheme result = Scheme.ofUri(uri);
	Scheme expected = Scheme.UNKNOWN;
	Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #28
Source File: BaseImageDownloaderTest.java    From candybar with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeContent() throws Exception {
    String uri = "content://path/to/content";
    Scheme result = Scheme.ofUri(uri);
    Scheme expected = Scheme.CONTENT;
    Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #29
Source File: BaseImageDownloaderTest.java    From candybar with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchemeUnknown() throws Exception {
    String uri = "other://image.com/1.png";
    Scheme result = Scheme.ofUri(uri);
    Scheme expected = Scheme.UNKNOWN;
    Assertions.assertThat(result).isEqualTo(expected);
}
 
Example #30
Source File: ImageLoaderConfiguration.java    From letv with Apache License 2.0 5 votes vote down vote up
public InputStream getStream(String imageUri, Object extra) throws IOException {
    switch (Scheme.ofUri(imageUri)) {
        case HTTP:
        case HTTPS:
            throw new IllegalStateException();
        default:
            return this.wrappedDownloader.getStream(imageUri, extra);
    }
}