Beispiel #1
0
 public static TagWapper constructTagWapper(Response res) {
   try {
     JSONArray tags = res.asJSONArray();
     List<Tag> tagList = new ArrayList<Tag>();
     for (int i = 0; i < tags.getJSONObject(0).getJSONArray("tags").length(); i++) {
       tagList.add(new Tag(tags.getJSONObject(0).getJSONArray("tags").getJSONObject(i)));
     }
     String id = tags.getJSONObject(0).getString("id");
     return new TagWapper(tagList, id);
   } catch (JSONException e) {
     e.printStackTrace();
   } catch (WeiboException e) {
     e.printStackTrace();
   }
   return null;
 }
Beispiel #2
0
 /**
  * @param res
  * @return
  * @throws WeiboException
  */
 static List<User> constructResult(Response res) throws WeiboException {
   JSONArray list = res.asJSONArray();
   try {
     int size = list.length();
     List<User> users = new ArrayList<User>(size);
     for (int i = 0; i < size; i++) {
       users.add(new User(list.getJSONObject(i)));
     }
     return users;
   } catch (JSONException e) {
   }
   return null;
 }
Beispiel #3
0
 static List<Count> constructCounts(Response res) throws WeiboException {
   try {
     JSONArray list = res.asJSONArray();
     int size = list.length();
     List<Count> counts = new ArrayList<Count>(size);
     for (int i = 0; i < size; i++) {
       counts.add(new Count(list.getJSONObject(i)));
     }
     return counts;
   } catch (JSONException jsone) {
     throw new WeiboException(jsone);
   } catch (WeiboException te) {
     throw te;
   }
 }
Beispiel #4
0
 public static List<FavoritesTag> constructTag(Response res) throws WeiboException {
   try {
     JSONArray list = res.asJSONObject().getJSONArray("tags");
     int size = list.length();
     List<FavoritesTag> tags = new ArrayList<FavoritesTag>(size);
     for (int i = 0; i < size; i++) {
       tags.add(new FavoritesTag(list.getJSONObject(i)));
     }
     return tags;
   } catch (JSONException jsone) {
     throw new WeiboException(jsone);
   } catch (WeiboException te) {
     throw te;
   }
 }
Beispiel #5
0
 public static List<User> constructUsers(Response res) throws WeiboException {
   try {
     JSONArray list = res.asJSONArray();
     int size = list.length();
     List<User> users = new ArrayList<User>(size);
     for (int i = 0; i < size; i++) {
       users.add(new User(list.getJSONObject(i)));
     }
     return users;
   } catch (JSONException jsone) {
     throw new WeiboException(jsone);
   } catch (WeiboException te) {
     throw te;
   }
 }
 public static List<SchoolSearch> constructSchoolSearch(Response res) throws WeiboException {
   try {
     JSONArray list = res.asJSONArray();
     int size = list.length();
     List<SchoolSearch> schools = new ArrayList<SchoolSearch>(size);
     for (int i = 0; i < size; i++) {
       schools.add(new SchoolSearch(list.getJSONObject(i)));
     }
     return schools;
   } catch (JSONException jsone) {
     throw new WeiboException(jsone);
   } catch (WeiboException te) {
     throw te;
   }
 }
Beispiel #7
0
 /**
  * @param res
  * @return
  * @throws WeiboException
  */
 public static UserWapper constructWapperUsers(Response res) throws WeiboException {
   JSONObject jsonUsers = res.asJSONObject(); // asJSONArray();
   try {
     JSONArray user = jsonUsers.getJSONArray("users");
     int size = user.length();
     List<User> users = new ArrayList<User>(size);
     for (int i = 0; i < size; i++) {
       users.add(new User(user.getJSONObject(i)));
     }
     long previousCursor = jsonUsers.getLong("previous_curosr");
     long nextCursor = jsonUsers.getLong("next_cursor");
     if (nextCursor == -1) { // 兼容不同标签名称
       nextCursor = jsonUsers.getLong("nextCursor");
     }
     return new UserWapper(users, previousCursor, nextCursor);
   } catch (JSONException jsone) {
     throw new WeiboException(jsone);
   }
 }
Beispiel #8
0
  public static List<User> constructUser(Response res) throws WeiboException {

    JSONObject json = res.asJSONObject();
    JSONArray list = null;
    try {
      if (!json.isNull("users")) {
        list = json.getJSONArray("users");
      } else {
        list = res.asJSONArray();
      }
      int size = list.length();
      List<User> users = new ArrayList<User>(size);
      for (int i = 0; i < size; i++) {
        users.add(new User(list.getJSONObject(i)));
      }
      return users;
    } catch (JSONException je) {
      throw new WeiboException(je);
    }
  }
 public static StatusWapper constructWapperStatus(Response res) throws WeiboException {
   JSONObject jsonStatus = res.asJSONObject(); // asJSONArray();
   JSONArray statuses = null;
   try {
     if (!jsonStatus.isNull("statuses")) {
       statuses = jsonStatus.getJSONArray("statuses");
     }
     if (!jsonStatus.isNull("reposts")) {
       statuses = jsonStatus.getJSONArray("reposts");
     }
     int size = statuses.length();
     List<Status> status = new ArrayList<Status>(size);
     for (int i = 0; i < size; i++) {
       status.add(new Status(statuses.getJSONObject(i)));
     }
     long previousCursor = jsonStatus.getLong("previous_curosr");
     long nextCursor = jsonStatus.getLong("next_cursor");
     long totalNumber = jsonStatus.getLong("total_number");
     String hasvisible = jsonStatus.getString("hasvisible");
     return new StatusWapper(status, previousCursor, nextCursor, totalNumber, hasvisible);
   } catch (JSONException jsone) {
     throw new WeiboException(jsone);
   }
 }