An extension for the React Native ImageStore object for Android to add in the "removeImageForTag" functionality.
- Edit
android/settings.gradle
and add the following:
include ':react-native-image-store-ext'
project(':react-native-image-store-ext').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-store-ext/app')
- Edit
android/app/build.gradle
and add the following:
project(':react-native-image-store-ext')
- Edit your
MainActivity.java
(deep inandroid/app/src/main/java/...
) to look like this (note two places to edit):
+ import dev.sekt.react_native_image_store_ext.ImageStoreExtPackage;
...
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
...
+ new ImageStoreExtPackage()
);
}
- Then just add...
var ImageStore, ImageStoreManager, ImageStoreManagerExt, NativeModules, ref;
ref = require('react-native'), NativeModules = ref.NativeModules, ImageStore = ref.ImageStore;
ImageStoreManagerExt = NativeModules.ImageStoreManagerExt;
ImageStoreManager = NativeModules.ImageStoreManager;
ImageStore.removeImageForTag = function(uri) {
if (ImageStoreManager.removeImageForTag) {
return ImageStoreManager.removeImageForTag(uri);
} else if (ImageStoreManagerExt && ImageStoreManagerExt.removeImageForTag) {
return ImageStoreManagerExt.removeImageForTag(uri);
} else {
return console.warn('removeImageForTag() not implemented');
}
};
- To your app to patch the current image store.