Esempio n. 1
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((user == null) ? 0 : user.hashCode());
   return result;
 }
Esempio n. 2
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   Data other = (Data) obj;
   if (user == null) {
     if (other.user != null) return false;
   } else if (!user.equals(other.user)) return false;
   return true;
 }
Esempio n. 3
0
  private void parseJson(String json) {
    // TODO Auto-generated method stub
    JSONObject jsonObject = null;
    try {
      jsonObject = new JSONObject(json);
      this.state = jsonObject.getInt("state");
      this.errorCode = jsonObject.getInt("errorCode");
      this.errorMessage = jsonObject.getString("errorMessage");
      this.version = jsonObject.getString("version");
      this.confVersion = jsonObject.getString("confVersion");
      this.currentTime = jsonObject.getLong("currentTime");
      this.datas = new ArrayList<Data>();
      JSONArray array1 = jsonObject.getJSONArray("data");
      if (array1 == null || array1.length() == 0) return;

      JSONArray array2 = null;
      //////////////////////////
      JSONObject O = array1.getJSONObject(0);

      String result = O.getString("result");
      if (result != null && !"null".equals(result)) {
        this.final_id = O.getInt("final_id");
        array2 = O.getJSONArray("result");
        //////////////////////////////
        /*if(mode==1){
        	array2=array1;
        }else{
        	array2=array1.getJSONArray(0);
        }*/
        if (array2 == null || array2.length() == 0) return;
        JSONObject jb = null;
        JSONObject jb1 = null;
        Data data = null;
        MyUser user = null;
        for (int i = 0; i < array2.length(); i++) {
          jb = array2.getJSONObject(i);
          jb1 = jb.getJSONObject("user");
          data = new Data();
          user = new MyUser();
          data.user = user;
          if (json.contains("usr_id")) {
            user.userId = jb1.getInt("usr_id");
          }

          if (json.contains("name")) {
            user.pet_nickName = jb1.getString("name");
          }

          if (json.contains("gender")) {
            user.a_gender = jb1.getInt("gender");
          }

          if (json.contains("tx")) {
            user.pet_iconUrl = jb1.getString("tx");
          }

          if (json.contains("age")) {
            user.a_age = "" + jb1.getInt("age");
          }

          if (json.contains("type")) {
            user.race = jb1.getString("type");
          }

          if (json.contains("code")) {
            user.code = jb1.getString("code");
          }

          if (json.contains("inviter")) {
            user.inviter = jb1.getInt("inviter");
          }

          if (json.contains("create_time")) {
            user.create_time = jb1.getString("create_time");
          }

          if (json.contains("update_time")) {
            user.update_time = jb1.getString("update_time");
          }

          if (json.contains("isFriend")) {
            data.isFriend = jb.getBoolean("isFriend");
          }
          datas.add(data);
        }
      }

    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }