From 2f034bf58dc1cba200920b560e5e09e337ffea2e Mon Sep 17 00:00:00 2001 From: wukui Date: Mon, 14 Aug 2017 11:44:39 +0800 Subject: [PATCH 1/3] Support RN 0.40+ --- .../main/java/cn/reactnative/httpcache/HttpCacheModule.java | 4 ++-- ios/RCTHttpCache/RCTHttpCache.m | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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/ios/RCTHttpCache/RCTHttpCache.m b/ios/RCTHttpCache/RCTHttpCache.m index a1b1260..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 From ab311156affba4f7a18f56a902a5a5f8452ec81b Mon Sep 17 00:00:00 2001 From: wukui Date: Mon, 14 Aug 2017 11:44:58 +0800 Subject: [PATCH 2/3] Add index.d.ts --- index.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 index.d.ts 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; +} From 49839f602df09bcb4311aca7fe798c2edb448ea5 Mon Sep 17 00:00:00 2001 From: wukui Date: Mon, 14 Aug 2017 11:45:07 +0800 Subject: [PATCH 3/3] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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.