react-native android module for crosswire's sword
npm install react-native-swordzA simple wrapper for JNI bindings of the Sword Project (http://crosswire.org/sword)
npm install --save react-native-swordzandroid/setting.gradle ``gradle`
...
include ':swordz'
project(':swordz').projectDir = new File(settingsDir, '../node-modules/swordz/android/')
3. In android/app/build.gradle
`gradle`
...
dependencies {
...
compile project(':swordz')
}
4. Register module (in MainActivity.java) → React Native >= 0.19
With RN >= 0.19.0
`java
import org.crosswire.android.sword.SwordZPackage; // <----- import
public class MainActivity extends ReactActivity {
...
@Override
protected List
return Arrays.
new MainReactPackage(),
new SwordZPackage() // <------ add here
);
}
}
`
`js
var mSwordZ = require('NativeModules').SwordZ;
...
mSwordZ.SWMgr_reInit();
mSwordZ.SWMgr_getModInfoList((modules) => {
console.log("MODULES: ", modules); //outputs an array of the local installed modules
});
`
android/src/main/java/org/crosswire/android/sword/SwordZModule.java`. Most of the API calls take a callback.You have to call
`mSwordZ.SWMgr_reInit();`` first to init the native C++ library!