Skip to content

seancunningham/react-native-image-store-ext

Repository files navigation

react-native-image-store-ext

An extension for the React Native ImageStore object for Android to add in the "removeImageForTag" functionality.

Installation

  • 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 in android/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.

About

An extension for the React Native ImageStore object for Android

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages