diff --git a/README.md b/README.md index bf78798..b3d2bb2 100644 --- a/README.md +++ b/README.md @@ -79,19 +79,19 @@ public class MainApplication extends Application implements ReactApplication { import * as CacheManager from 'react-native-http-cache'; // invoke API directly when in need -CacheManager.clear(); +CacheManager.clearCache(); ``` ## API Documentation -#### clear() +#### clearCache() Clear cache for all type. Return a promise which indicate the clear state. -#### getSize() +#### getCacheSize() Get cache size for all type. diff --git a/android/src/main/java/cn/reactnative/httpcache/HttpCacheModule.java b/android/src/main/java/cn/reactnative/httpcache/HttpCacheModule.java index fea1db7..1133717 100644 --- a/android/src/main/java/cn/reactnative/httpcache/HttpCacheModule.java +++ b/android/src/main/java/cn/reactnative/httpcache/HttpCacheModule.java @@ -66,7 +66,7 @@ private void updateCacheSize(DiskStorageCache cache) throws NoSuchMethodExceptio @ReactMethod public void getImageCacheSize(Promise promise){ - FileCache cache1 = ImagePipelineFactory.getInstance().getMainDiskStorageCache(); + FileCache cache1 = ImagePipelineFactory.getInstance().getMainFileCache(); long size1 = cache1.getSize(); if (size1 < 0){ try { @@ -77,7 +77,7 @@ public void getImageCacheSize(Promise promise){ } size1 = cache1.getSize(); } - FileCache cache2 = ImagePipelineFactory.getInstance().getSmallImageDiskStorageCache(); + FileCache cache2 = ImagePipelineFactory.getInstance().getSmallImageFileCache(); long size2 = cache2.getSize(); if (size2 < 0){ try { diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..96312ff --- /dev/null +++ b/index.d.ts @@ -0,0 +1,8 @@ +declare module "react-native-http-cache" { + export function clearHttpCache(): Promise; + export function getHttpCacheSize(): Promise; + export function clearImageCache(): Promise; + export function getImageCacheSize(): Promise; + export function getCacheSize(): Promise; + export function clearCache(): Promise; +} diff --git a/ios/RCTHttpCache/RCTHttpCache.m b/ios/RCTHttpCache/RCTHttpCache.m index b5fb64e..ac61222 100644 --- a/ios/RCTHttpCache/RCTHttpCache.m +++ b/ios/RCTHttpCache/RCTHttpCache.m @@ -7,9 +7,9 @@ // #import "RCTHttpCache.h" -//#import "RCTImageLoader.h" +#import "React/RCTImageLoader.h" #import "RCTImageCache.h" -//#import "RCTBridge.h" +#import "React/RCTBridge.h" @implementation RCTHttpCache