|
15 | 15 | *******************************************************************************/
|
16 | 16 | package com.nostra13.universalimageloader.cache.disc;
|
17 | 17 |
|
| 18 | +import android.graphics.Bitmap; |
| 19 | +import com.nostra13.universalimageloader.utils.IoUtils; |
| 20 | + |
18 | 21 | import java.io.File;
|
| 22 | +import java.io.IOException; |
| 23 | +import java.io.InputStream; |
19 | 24 |
|
20 | 25 | /**
|
21 |
| - * Interface for disc cache |
| 26 | + * Interface for disk cache |
22 | 27 | *
|
23 | 28 | * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
|
24 | 29 | * @since 1.0.0
|
25 | 30 | */
|
26 | 31 | public interface DiscCacheAware {
|
| 32 | + |
| 33 | + /** |
| 34 | + * Returns root directory of disk cache |
| 35 | + * |
| 36 | + * @return Root directory of disk cache |
| 37 | + */ |
| 38 | + File getDirectory(); |
| 39 | + |
| 40 | + /** |
| 41 | + * Returns file of cached image |
| 42 | + * |
| 43 | + * @param imageUri Original image URI |
| 44 | + * @return File of cached image or <b>null</b> if image wasn't cached |
| 45 | + */ |
| 46 | + File get(String imageUri); |
| 47 | + |
| 48 | + /** |
| 49 | + * Saves image stream in disk cache. |
| 50 | + * |
| 51 | + * @param imageUri Original image URI |
| 52 | + * @param imageStream Input stream of image |
| 53 | + * @param listener Listener for saving progress, can be ignored if you don't use |
| 54 | + * {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener |
| 55 | + * progress listener} in ImageLoader calls |
| 56 | + * @return <b>true</b> - if image was saved successfully; <b>false</b> - if image wasn't saved in disk cache. |
| 57 | + * @throws IOException |
| 58 | + */ |
| 59 | + boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException; |
| 60 | + |
27 | 61 | /**
|
28 |
| - * This method must not to save file on file system in fact. It is called after image was cached in cache directory |
29 |
| - * and it was decoded to bitmap in memory. Such order is required to prevent possible deletion of file after it was |
30 |
| - * cached on disc and before it was tried to decode to bitmap. |
| 62 | + * Saves image bitmap in disk cache. |
| 63 | + * |
| 64 | + * @param imageUri Original image URI |
| 65 | + * @param bitmap Image bitmap |
| 66 | + * @return <b>true</b> - if bitmap was saved successfully; <b>false</b> - if bitmap wasn't saved in disk cache. |
| 67 | + * @throws IOException |
31 | 68 | */
|
32 |
| - void put(String key, File file); |
| 69 | + boolean save(String imageUri, Bitmap bitmap) throws IOException; |
33 | 70 |
|
34 | 71 | /**
|
35 |
| - * Returns {@linkplain File file object} appropriate incoming key.<br /> |
36 |
| - * <b>NOTE:</b> Must <b>not to return</b> a null. Method must return specific {@linkplain File file object} for |
37 |
| - * incoming key whether file exists or not. |
| 72 | + * Removes image file associated with incoming URI |
| 73 | + * |
| 74 | + * @param imageUri Image URI |
| 75 | + * @return <b>true</b> - if image file is deleted successfully; <b>false</b> - if image file doesn't exist for |
| 76 | + * incoming URI or image file can't be deleted. |
38 | 77 | */
|
39 |
| - File get(String key); |
| 78 | + boolean remove(String imageUri); |
| 79 | + |
| 80 | + /** Closes disk cache, releases resources. */ |
| 81 | + void close(); |
40 | 82 |
|
41 |
| - /** Clears cache directory */ |
| 83 | + /** Clears disk cache. */ |
42 | 84 | void clear();
|
43 | 85 | }
|
0 commit comments