Java Code Examples for com.nostra13.universalimageloader.utils.IoUtils#CopyListener
The following examples show how to use
com.nostra13.universalimageloader.utils.IoUtils#CopyListener .
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: LruDiskCache.java From BigApp_WordPress_Android with Apache License 2.0 | 6 votes |
@Override public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException { DiskLruCache.Editor editor = cache.edit(getKey(imageUri)); if (editor == null) { return false; } OutputStream os = new BufferedOutputStream(editor.newOutputStream(0), bufferSize); boolean copied = false; try { copied = IoUtils.copyStream(imageStream, os, listener, bufferSize); } finally { IoUtils.closeSilently(os); if (copied) { editor.commit(); } else { editor.abort(); } } return copied; }
Example 2
Source File: LruDiskCache.java From Android-Universal-Image-Loader-Modify with Apache License 2.0 | 6 votes |
/** * 把图片流数据保存到缓存中 * @param imageUri Original image URI 图像URL连接地址 * @param imageStream Input stream of image (shouldn't be closed in this method) 图片流 * @param listener 图片流拷贝监听器 * Listener for saving progress, can be ignored if you don't use * {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener * progress listener} in ImageLoader calls * @return * @throws IOException */ @Override public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException { DiskLruCache.Editor editor = cache.edit(getKey(imageUri)); if (editor == null) { return false; } //流写入文件 OutputStream os = new BufferedOutputStream(editor.newOutputStream(0), bufferSize); boolean copied = false; try { copied = IoUtils.copyStream(imageStream, os, listener, bufferSize); } finally { IoUtils.closeSilently(os); if (copied) { editor.commit(); } else { editor.abort(); } } return copied; }
Example 3
Source File: BaseDiskCache.java From Android-Universal-Image-Loader-Modify with Apache License 2.0 | 6 votes |
/** * 根据文件流进行保存到缓存文件中 * @param imageUri Original image URI 原图片URL地址作为生成缓存文件的文件名 * @param imageStream Input stream of image (shouldn't be closed in this method) 图片流 * @param listener 用于监听流保存本地的进度 * Listener for saving progress, can be ignored if you don't use * {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener * progress listener} in ImageLoader calls * @return * @throws IOException */ @Override public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException { File imageFile = getFile(imageUri); File tmpFile = new File(imageFile.getAbsolutePath() + TEMP_IMAGE_POSTFIX); boolean loaded = false; try { OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile), bufferSize); try { loaded = IoUtils.copyStream(imageStream, os, listener, bufferSize); } finally { IoUtils.closeSilently(os); } } finally { if (loaded && !tmpFile.renameTo(imageFile)) { loaded = false; } if (!loaded) { tmpFile.delete(); } } return loaded; }
Example 4
Source File: BaseDiscCache.java From android-open-project-demo with Apache License 2.0 | 6 votes |
@Override public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException { File imageFile = getFile(imageUri); File tmpFile = new File(imageFile.getAbsolutePath() + TEMP_IMAGE_POSTFIX); boolean loaded = false; try { OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile), bufferSize); try { loaded = IoUtils.copyStream(imageStream, os, listener, bufferSize); } finally { IoUtils.closeSilently(os); } } finally { IoUtils.closeSilently(imageStream); if (loaded && !tmpFile.renameTo(imageFile)) { loaded = false; } if (!loaded) { tmpFile.delete(); } } return loaded; }
Example 5
Source File: BaseDiskCache.java From WliveTV with Apache License 2.0 | 6 votes |
@Override public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException { File imageFile = getFile(imageUri); File tmpFile = new File(imageFile.getAbsolutePath() + TEMP_IMAGE_POSTFIX); boolean loaded = false; try { OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile), bufferSize); try { loaded = IoUtils.copyStream(imageStream, os, listener, bufferSize); } finally { IoUtils.closeSilently(os); } } finally { if (loaded && !tmpFile.renameTo(imageFile)) { loaded = false; } if (!loaded) { tmpFile.delete(); } } return loaded; }
Example 6
Source File: LruDiscCache.java From android-open-project-demo with Apache License 2.0 | 6 votes |
@Override public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException { DiskLruCache.Editor editor = cache.edit(getKey(imageUri)); if (editor == null) { return false; } OutputStream os = new BufferedOutputStream(editor.newOutputStream(0), bufferSize); boolean copied = false; try { copied = IoUtils.copyStream(imageStream, os, listener, bufferSize); } finally { IoUtils.closeSilently(os); if (copied) { editor.commit(); } else { editor.abort(); } } return copied; }
Example 7
Source File: LruDiscCache.java From mobile-manager-tool with MIT License | 6 votes |
@Override public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException { DiskLruCache.Editor editor = cache.edit(getKey(imageUri)); if (editor == null) { return false; } OutputStream os = new BufferedOutputStream(editor.newOutputStream(0), bufferSize); boolean copied = false; try { copied = IoUtils.copyStream(imageStream, os, listener, bufferSize); } finally { IoUtils.closeSilently(os); if (copied) { editor.commit(); } else { editor.abort(); } } return copied; }
Example 8
Source File: BaseDiskCache.java From candybar with Apache License 2.0 | 6 votes |
@Override public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException { File imageFile = getFile(imageUri); File tmpFile = new File(imageFile.getAbsolutePath() + TEMP_IMAGE_POSTFIX); boolean loaded = false; try { OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile), bufferSize); try { loaded = IoUtils.copyStream(imageStream, os, listener, bufferSize); } finally { IoUtils.closeSilently(os); } } finally { if (loaded && !tmpFile.renameTo(imageFile)) { loaded = false; } if (!loaded) { tmpFile.delete(); } } return loaded; }
Example 9
Source File: GifCache.java From Slide with GNU General Public License v3.0 | 5 votes |
public static void writeGif(String url, InputStream stream, IoUtils.CopyListener listener) { try { LogUtil.v(discCache.save(url, stream, listener) + "DONE "); } catch (Exception e) { e.printStackTrace(); } finally { IoUtils.closeSilently(stream); } }
Example 10
Source File: LimitedAgeDiskCache.java From BigApp_WordPress_Android with Apache License 2.0 | 4 votes |
@Override public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException { boolean saved = super.save(imageUri, imageStream, listener); rememberUsage(imageUri); return saved; }
Example 11
Source File: LimitedAgeDiscCache.java From mobile-manager-tool with MIT License | 4 votes |
@Override public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException { boolean saved = super.save(imageUri, imageStream, listener); rememberUsage(imageUri); return saved; }
Example 12
Source File: LimitedAgeDiskCache.java From candybar with Apache License 2.0 | 4 votes |
@Override public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException { boolean saved = super.save(imageUri, imageStream, listener); rememberUsage(imageUri); return saved; }
Example 13
Source File: LimitedAgeDiskCache.java From WliveTV with Apache License 2.0 | 4 votes |
@Override public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException { boolean saved = super.save(imageUri, imageStream, listener); rememberUsage(imageUri); return saved; }
Example 14
Source File: LimitedAgeDiscCache.java From android-open-project-demo with Apache License 2.0 | 4 votes |
@Override public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException { boolean saved = super.save(imageUri, imageStream, listener); rememberUsage(imageUri); return saved; }
Example 15
Source File: LimitedAgeDiskCache.java From Android-Universal-Image-Loader-Modify with Apache License 2.0 | 3 votes |
/** * 进行保存图片到本地缓存路径中 --使用图片流 * @param imageUri 图片的URL地址 * @param imageStream 图片流 * @param listener 图片流拷贝完成进度回调接口 * @return * @throws IOException */ @Override public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException { boolean saved = super.save(imageUri, imageStream, listener); //时间保存 rememberUsage(imageUri); return saved; }
Example 16
Source File: DiskCache.java From Android-Universal-Image-Loader-Modify with Apache License 2.0 | 2 votes |
/** * 进行保存图片流到缓存中 * Saves image stream in disk cache. * Incoming image stream shouldn't be closed in this method. * * @param imageUri Original image URI * @param imageStream Input stream of image (shouldn't be closed in this method) * @param listener Listener for saving progress, can be ignored if you don't use * {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener * progress listener} in ImageLoader calls * @return <b>true</b> - if image was saved successfully; <b>false</b> - if image wasn't saved in disk cache. * @throws java.io.IOException */ boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException;
Example 17
Source File: DiskCache.java From BigApp_WordPress_Android with Apache License 2.0 | 2 votes |
/** * Saves image stream in disk cache. * Incoming image stream shouldn't be closed in this method. * * @param imageUri Original image URI * @param imageStream Input stream of image (shouldn't be closed in this method) * @param listener Listener for saving progress, can be ignored if you don't use * {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener * progress listener} in ImageLoader calls * @return <b>true</b> - if image was saved successfully; <b>false</b> - if image wasn't saved in disk cache. * @throws java.io.IOException */ boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException;
Example 18
Source File: DiscCacheAware.java From mobile-manager-tool with MIT License | 2 votes |
/** * Saves image stream in disk cache. * * @param imageUri Original image URI * @param imageStream Input stream of image * @param listener Listener for saving progress, can be ignored if you don't use * {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener * progress listener} in ImageLoader calls * @return <b>true</b> - if image was saved successfully; <b>false</b> - if image wasn't saved in disk cache. * @throws java.io.IOException */ boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException;
Example 19
Source File: DiskCache.java From candybar with Apache License 2.0 | 2 votes |
/** * Saves image stream in disk cache. * Incoming image stream shouldn't be closed in this method. * * @param imageUri Original image URI * @param imageStream Input stream of image (shouldn't be closed in this method) * @param listener Listener for saving progress, can be ignored if you don't use * {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener * progress listener} in ImageLoader calls * @return <b>true</b> - if image was saved successfully; <b>false</b> - if image wasn't saved in disk cache. * @throws java.io.IOException */ boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException;
Example 20
Source File: DiskCache.java From WliveTV with Apache License 2.0 | 2 votes |
/** * Saves image stream in disk cache. * Incoming image stream shouldn't be closed in this method. * * @param imageUri Original image URI * @param imageStream Input stream of image (shouldn't be closed in this method) * @param listener Listener for saving progress, can be ignored if you don't use * {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener * progress listener} in ImageLoader calls * @return <b>true</b> - if image was saved successfully; <b>false</b> - if image wasn't saved in disk cache. * @throws java.io.IOException */ boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException;