InitConfig.java 2.0 KB

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