InitConfig.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package com.yyrh.constant;
  2. import android.text.TextUtils;
  3. import com.yyrh.utils.YYLog;
  4. import org.json.JSONArray;
  5. import org.json.JSONException;
  6. import org.json.JSONObject;
  7. public class InitConfig {
  8. public String fristShowPage = "";
  9. public String agreement_privacy = "";
  10. public String service_center = "";
  11. public String access_token = "";
  12. public String agreement_user = "";
  13. public JSONObject links = null;
  14. public JSONArray reg_tabs = null;
  15. public int sdk_login = 1;
  16. public int bswitch = 0;
  17. public int rn_bh = 1800;
  18. public static InitConfig toBean(JSONObject json){
  19. if (TextUtils.isEmpty(json.toString())) {
  20. return null;
  21. }
  22. InitConfig initConfig = new InitConfig();
  23. initConfig.reg_tabs = json.optJSONArray("reg_tabs");
  24. initConfig.sdk_login = json.optInt("sdk_login", 100);
  25. initConfig.bswitch = json.optInt("bswitch");
  26. initConfig.access_token = json.optString("access_token");
  27. initConfig.rn_bh = json.optInt("rn_bh",1800);
  28. if (initConfig.reg_tabs != null){
  29. try {
  30. if (initConfig.reg_tabs.get(0).toString().equals("phone")){
  31. initConfig.fristShowPage = "phone";
  32. }
  33. } catch (JSONException e) {
  34. e.printStackTrace();
  35. }
  36. }
  37. initConfig.links = json.optJSONObject("links");
  38. if (initConfig.links != null){
  39. initConfig.agreement_privacy = initConfig.links.optString("agreement_privacy");
  40. initConfig.service_center = initConfig.links.optString("service_center");
  41. initConfig.agreement_user= initConfig.links.optString("agreement_user");
  42. }
  43. YYLog.i(initConfig.toString());
  44. return initConfig;
  45. }
  46. @Override
  47. public String toString() {
  48. return "InitConfig{" +
  49. "agreement_privacy='" + agreement_privacy + '\'' +
  50. ", service_center='" + service_center + '\'' +
  51. ", access_token='" + access_token + '\'' +
  52. ", agreement_user='" + agreement_user + '\'' +
  53. ", links=" + links +
  54. ", reg_tabs=" + reg_tabs +
  55. ", sdk_login=" + sdk_login +
  56. ", bswitch=" + bswitch +
  57. ", rn_bh=" + rn_bh +
  58. '}';
  59. }
  60. }