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; @@ -3,12 +3,11 @@ package com.yh_vendor;
3 import com.facebook.react.ReactActivity; 3 import com.facebook.react.ReactActivity;
4 import com.facebook.react.ReactPackage; 4 import com.facebook.react.ReactPackage;
5 import com.facebook.react.shell.MainReactPackage; 5 import com.facebook.react.shell.MainReactPackage;
  6 +import com.learnium.RNDeviceInfo.RNDeviceInfo;
6 7
7 import java.util.Arrays; 8 import java.util.Arrays;
8 import java.util.List; 9 import java.util.List;
9 10
10 -import com.learnium.RNDeviceInfo.RNDeviceInfo;  
11 -  
12 public class MainActivity extends ReactActivity { 11 public class MainActivity extends ReactActivity {
13 12
14 /** 13 /**
@@ -36,6 +35,7 @@ public class MainActivity extends ReactActivity { @@ -36,6 +35,7 @@ public class MainActivity extends ReactActivity {
36 @Override 35 @Override
37 protected List<ReactPackage> getPackages() { 36 protected List<ReactPackage> getPackages() {
38 return Arrays.<ReactPackage>asList( 37 return Arrays.<ReactPackage>asList(
  38 + new RNNativeConfig(),
39 new RNDeviceInfo(), 39 new RNDeviceInfo(),
40 new MainReactPackage() 40 new MainReactPackage()
41 ); 41 );
  1 +package com.yh_vendor;
  2 +
  3 +import com.facebook.react.ReactPackage;
  4 +import com.facebook.react.bridge.JavaScriptModule;
  5 +import com.facebook.react.bridge.NativeModule;
  6 +import com.facebook.react.bridge.ReactApplicationContext;
  7 +import com.facebook.react.uimanager.ViewManager;
  8 +
  9 +import java.util.ArrayList;
  10 +import java.util.Collections;
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * <Description> <br>
  15 + *
  16 + * @author yewanwan<br>
  17 + * @version 1.0<br>
  18 + * @taskId <br>
  19 + * @CreateDate 16/6/3 <br>
  20 + */
  21 +public class RNNativeConfig implements ReactPackage {
  22 + @Override
  23 + public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) {
  24 + List<NativeModule> modules = new ArrayList<>();
  25 +
  26 + modules.add(new RNNativeConfigModule(reactApplicationContext));
  27 +
  28 + return modules;
  29 + }
  30 +
  31 + @Override
  32 + public List<Class<? extends JavaScriptModule>> createJSModules() {
  33 + return Collections.emptyList();
  34 + }
  35 +
  36 + @Override
  37 + public List<ViewManager> createViewManagers(ReactApplicationContext reactApplicationContext) {
  38 + return Collections.emptyList();
  39 + }
  40 +}
  1 +package com.yh_vendor;
  2 +
  3 +import com.facebook.react.bridge.ReactApplicationContext;
  4 +import com.facebook.react.bridge.ReactContextBaseJavaModule;
  5 +
  6 +import java.util.HashMap;
  7 +import java.util.Map;
  8 +
  9 +import javax.annotation.Nullable;
  10 +
  11 +/**
  12 + * <Description> <br>
  13 + *
  14 + * @author yewanwan<br>
  15 + * @version 1.0<br>
  16 + * @taskId <br>
  17 + * @CreateDate 16/6/3 <br>
  18 + */
  19 +public class RNNativeConfigModule extends ReactContextBaseJavaModule {
  20 + private final ReactApplicationContext mContext;
  21 +
  22 + public RNNativeConfigModule(ReactApplicationContext reactContext) {
  23 + super(reactContext);
  24 + this.mContext = reactContext;
  25 + }
  26 +
  27 + @Override
  28 + public String getName() {
  29 + return "RNNativeConfig";
  30 + }
  31 +
  32 + @Nullable
  33 + @Override
  34 + public Map<String, Object> getConstants() {
  35 + HashMap<String, Object> constants = new HashMap<String, Object>();
  36 + constants.put("privateKey", "fd4ad5fcfa0de589ef238c0e7331b585");
  37 + constants.put("echartsPath", "file:///android_asset/echarts.min.js");
  38 + return constants;
  39 + }
  40 +}
@@ -27,11 +27,10 @@ export default class ChartView extends Component { @@ -27,11 +27,10 @@ export default class ChartView extends Component {
27 }); 27 });
28 } 28 }
29 29
30 - let jsPath = 'http://cdn.bootcss.com/echarts/3.0.0/echarts.min.js';  
31 - if (Platform.OS === 'ios') {  
32 - jsPath = NativeModules.RNNativeConfig.echartsPath; 30 + let jsPath = NativeModules.RNNativeConfig.echartsPath;
  31 + if (jsPath === undefined || jsPath === '') {
  32 + jsPath = 'http://cdn.bootcss.com/echarts/3.0.0/echarts.min.js';
33 } 33 }
34 -  
35 const HTML = getHTMLString(xString, this.props.yData.toString(), jsPath); 34 const HTML = getHTMLString(xString, this.props.yData.toString(), jsPath);
36 35
37 return( 36 return(
@@ -2,13 +2,11 @@ module.exports = { @@ -2,13 +2,11 @@ module.exports = {
2 dev: { 2 dev: {
3 // baseUrl: 'http://testapi.yoho.cn:28077', 3 // baseUrl: 'http://testapi.yoho.cn:28077',
4 baseUrl: 'http://192.168.102.205:8080', 4 baseUrl: 'http://192.168.102.205:8080',
5 - androidPrivateKey: 'fd4ad5fcfa0de589ef238c0e7331b585',  
6 httpTimeout: 30000, //毫秒 5 httpTimeout: 30000, //毫秒
7 6
8 }, 7 },
9 prd: { 8 prd: {
10 baseUrl: 'http://192.168.102.205:8080', 9 baseUrl: 'http://192.168.102.205:8080',
11 - androidPrivateKey: 'fd4ad5fcfa0de589ef238c0e7331b585',  
12 HTTPTimeout: 30000, //毫秒 10 HTTPTimeout: 30000, //毫秒
13 11
14 }, 12 },
@@ -14,7 +14,6 @@ export default class MessageService { @@ -14,7 +14,6 @@ export default class MessageService {
14 body: { 14 body: {
15 shopsId: shopsId, 15 shopsId: shopsId,
16 method: 'app.shopInbox.getList', 16 method: 'app.shopInbox.getList',
17 - debug: 'XYZ',  
18 } 17 }
19 }) 18 })
20 .then(json => { 19 .then(json => {
@@ -32,7 +31,6 @@ export default class MessageService { @@ -32,7 +31,6 @@ export default class MessageService {
32 shopsId: shopsId, 31 shopsId: shopsId,
33 ids: ids, 32 ids: ids,
34 method: 'app.shopInbox.batchSetIsRead', 33 method: 'app.shopInbox.batchSetIsRead',
35 - debug: 'XYZ',  
36 } 34 }
37 }) 35 })
38 .then(json => { 36 .then(json => {
@@ -50,7 +48,6 @@ export default class MessageService { @@ -50,7 +48,6 @@ export default class MessageService {
50 shopsId: shopsId, 48 shopsId: shopsId,
51 isRead: isRead, 49 isRead: isRead,
52 method: 'app.shopInbox.getShopInboxTotal', 50 method: 'app.shopInbox.getShopInboxTotal',
53 - debug: 'XYZ',  
54 } 51 }
55 }) 52 })
56 .then(json => { 53 .then(json => {
@@ -16,12 +16,7 @@ export default class Request { @@ -16,12 +16,7 @@ export default class Request {
16 16
17 this.baseUrl= this.config.baseUrl; 17 this.baseUrl= this.config.baseUrl;
18 18
19 - this.privateKey = '';  
20 - if (Platform.OS === 'ios') {  
21 this.privateKey = RNNativeConfig.getPrivateKey(); 19 this.privateKey = RNNativeConfig.getPrivateKey();
22 - } else {  
23 - this.privateKey = this.config.androidPrivateKey;  
24 - }  
25 20
26 this.timeout = this.config.HTTPTimeout; 21 this.timeout = this.config.HTTPTimeout;
27 } 22 }