-
Notifications
You must be signed in to change notification settings - Fork 18
/
WebPImageManager.h
72 lines (59 loc) · 2.21 KB
/
WebPImageManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// WebPImageManager.h
// ImageButter
//
// Created by Dalton Cherry on 9/1/15.
//
#import <Foundation/Foundation.h>
#import "WebPImage.h"
typedef void (^WebPImageFinished)(WebPImage*);
typedef void (^WebPImageProgress)(CGFloat);
typedef void (^WebPPreloadFinished)(BOOL);
@interface WebPImageManager : NSObject
/**
Singleton to share webp image access.
*/
+ (instancetype)sharedManager;
/**
The time to cache an image on disk. The default is 24 hours.
*/
@property(nonatomic)NSInteger maxCacheAge;
/**
Get an image for a url (on disk or remotely)
@param url is the location to fetch the image from.
@param progress is the block that reports how the total progress length. This is decode time of the image + network request if required.
@param finished is the block that reports once the image is done being fetch,cached, and decoded (it is ready to be displayed).
@return a sessionId to identify this specific session of closures. Is to be used for cancellation if needed.
*/
- (NSInteger)imageForUrl:(NSURL*)url progress:(WebPImageProgress)progress finished:(WebPImageFinished)finished;
/**
"cancel" an image so the caller will no longer get the block callbacks.
@param the session id returned from imageForUrl.
@param the url that was orginally requested.
*/
- (void)cancelImageForSession:(NSInteger)session url:(NSURL*)url;
/**
Clears the in memory cache
*/
- (void)clearCache;
/**
Clears the in memory cache for a specific url.
*/
- (void)clearUrlFromCache:(NSURL*)url;
/**
Cleans the cache directory of old files.
This runs on a background thread, so it is recommend to run on each launch of your app.
*/
- (void)cleanDisk;
/**
Just checks the in memory cache for an image.
@param the url is used to check the in memory cache since images are cached and stored based on their urls.
*/
- (WebPImage*)imageFromCache:(NSURL*)url;
/**
Preloads the image by downloading the image straight to disk instead of putting it in memory.
@param the url is used to check the in memory cache since images are cached and stored based on their urls.
@param finished is the block that reports once the image is done being fetch and cached to disk.
*/
- (void)preloadImage:(NSURL*)url finished:(WebPPreloadFinished)finished;
@end