Пример #1
0
  public static StatusList parse(String jsonString) {
    if (TextUtils.isEmpty(jsonString)) {
      return null;
    }

    StatusList statuses = new StatusList();
    try {
      JSONObject jsonObject = new JSONObject(jsonString);
      statuses.hasvisible = jsonObject.optBoolean("hasvisible", false);
      statuses.previous_cursor = jsonObject.optString("previous_cursor", "0");
      statuses.next_cursor = jsonObject.optString("next_cursor", "0");
      statuses.total_number = jsonObject.optInt("total_number", 0);

      JSONArray jsonArray = jsonObject.optJSONArray("statuses");
      if (jsonArray != null && jsonArray.length() > 0) {
        int length = jsonArray.length();
        statuses.statusList = new ArrayList<Status>(length);
        for (int ix = 0; ix < length; ix++) {
          statuses.statusList.add(Status.parse(jsonArray.getJSONObject(ix)));
        }
      }
    } catch (JSONException e) {
      e.printStackTrace();
    }

    return statuses;
  }
Пример #2
0
 @Override
 public void onComplete(String json) {
   StatusList statusList = StatusList.parse(json);
   onComplete(statusList.statusList);
 }