๐Ÿ“ฆ Anthonyzou / react-native-image-cache

Image caching for Android

โ˜… 12 stars โ‘‚ 3 forks ๐Ÿ‘ 12 watching
๐Ÿ“ฅ Clone https://github.com/Anthonyzou/react-native-image-cache.git
HTTPS git clone https://github.com/Anthonyzou/react-native-image-cache.git
SSH git clone git@github.com:Anthonyzou/react-native-image-cache.git
CLI gh repo clone Anthonyzou/react-native-image-cache
Anthony Ou Anthony Ou Updated readme with example f4c2f99 9 years ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ android
๐Ÿ“ example
๐Ÿ“„ .gitignore
๐Ÿ“„ .npmignore
๐Ÿ“„ index.js
๐Ÿ“„ package.json
๐Ÿ“„ README.md
๐Ÿ“„ README.md

Image caching for Android

Props:
PropertyTypeDefaultDescription
srcstringnullhttp source of the image
tintColorstringnulloptional tintColor
onLoadfunctionnulloptional onLoad function
borderRadiusnumbernulloptional borderRadius number

Example

import Image from 'react-native-image-cache'


<Image onLoad={()=>{
  ToastAndroid.show(`OnLoad`, ToastAndroid.LONG)
}} borderRadius={2} style={styles.image} src={"http://placehold.it/500"}></Image>

Include in your App

Installation


Install the npm package react-native-image-cache. Inside your React Native project, run (example):

npm install --save react-native-image-cache

In android/settings.gradle add the following lines

include :react-native-image-cache'
project(':react-native-image-cache').projectDir = file('../node_modules/react-native-image-cache/android')

NOTE : If you have included other libraries in your project, the include line will contain the other dependencies too.

In android/app/build.gradle, add a dependency to ':react-native-image-cache'

dependencies {
    compile project(':react-native-image-cache')
}

Next, you need to change the MainActivity of your app to register ReactImageCache :

import com.image.cache.ReactImageCache; // add this import

public class MainActivity extends ReactActivity {
    //...

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new ReactImageCache() // add this manager
      );
    }


TeamLockr image caching Team Lockr image caching for react native

These are functions created by the TeamLockr Team created for the TeamLockr platform.