Authored by 叶弯弯

read private key & echarts path from native. reviewed by yuliang.

This diff could not be displayed because it is too large.
... ... @@ -3,12 +3,11 @@ package com.yh_vendor;
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import java.util.Arrays;
import java.util.List;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
public class MainActivity extends ReactActivity {
/**
... ... @@ -36,6 +35,7 @@ public class MainActivity extends ReactActivity {
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new RNNativeConfig(),
new RNDeviceInfo(),
new MainReactPackage()
);
... ...
package com.yh_vendor;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* <Description> <br>
*
* @author yewanwan<br>
* @version 1.0<br>
* @taskId <br>
* @CreateDate 16/6/3 <br>
*/
public class RNNativeConfig implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new RNNativeConfigModule(reactApplicationContext));
return modules;
}
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactApplicationContext) {
return Collections.emptyList();
}
}
... ...
package com.yh_vendor;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
/**
* <Description> <br>
*
* @author yewanwan<br>
* @version 1.0<br>
* @taskId <br>
* @CreateDate 16/6/3 <br>
*/
public class RNNativeConfigModule extends ReactContextBaseJavaModule {
private final ReactApplicationContext mContext;
public RNNativeConfigModule(ReactApplicationContext reactContext) {
super(reactContext);
this.mContext = reactContext;
}
@Override
public String getName() {
return "RNNativeConfig";
}
@Nullable
@Override
public Map<String, Object> getConstants() {
HashMap<String, Object> constants = new HashMap<String, Object>();
constants.put("privateKey", "fd4ad5fcfa0de589ef238c0e7331b585");
constants.put("echartsPath", "file:///android_asset/echarts.min.js");
return constants;
}
}
... ...
... ... @@ -27,11 +27,10 @@ export default class ChartView extends Component {
});
}
let jsPath = 'http://cdn.bootcss.com/echarts/3.0.0/echarts.min.js';
if (Platform.OS === 'ios') {
jsPath = NativeModules.RNNativeConfig.echartsPath;
let jsPath = NativeModules.RNNativeConfig.echartsPath;
if (jsPath === undefined || jsPath === '') {
jsPath = 'http://cdn.bootcss.com/echarts/3.0.0/echarts.min.js';
}
const HTML = getHTMLString(xString, this.props.yData.toString(), jsPath);
return(
... ...
... ... @@ -2,13 +2,11 @@ module.exports = {
dev: {
// baseUrl: 'http://testapi.yoho.cn:28077',
baseUrl: 'http://192.168.102.205:8080',
androidPrivateKey: 'fd4ad5fcfa0de589ef238c0e7331b585',
httpTimeout: 30000, //毫秒
},
prd: {
baseUrl: 'http://192.168.102.205:8080',
androidPrivateKey: 'fd4ad5fcfa0de589ef238c0e7331b585',
HTTPTimeout: 30000, //毫秒
},
... ...
... ... @@ -14,7 +14,6 @@ export default class MessageService {
body: {
shopsId: shopsId,
method: 'app.shopInbox.getList',
debug: 'XYZ',
}
})
.then(json => {
... ... @@ -32,7 +31,6 @@ export default class MessageService {
shopsId: shopsId,
ids: ids,
method: 'app.shopInbox.batchSetIsRead',
debug: 'XYZ',
}
})
.then(json => {
... ... @@ -50,7 +48,6 @@ export default class MessageService {
shopsId: shopsId,
isRead: isRead,
method: 'app.shopInbox.getShopInboxTotal',
debug: 'XYZ',
}
})
.then(json => {
... ...
... ... @@ -16,12 +16,7 @@ export default class Request {
this.baseUrl= this.config.baseUrl;
this.privateKey = '';
if (Platform.OS === 'ios') {
this.privateKey = RNNativeConfig.getPrivateKey();
} else {
this.privateKey = this.config.androidPrivateKey;
}
this.timeout = this.config.HTTPTimeout;
}
... ...