Beispiel #1
0
 public static Video parse(JSONObject o) throws NumberFormatException, JSONException {
   Video v = new Video();
   if (o.has("vid")) v.vid = o.getLong("vid");
   if (o.has("id")) // video.getUserVideos
   v.vid = Long.parseLong(o.getString("id"));
   v.owner_id = o.getLong("owner_id");
   v.title = Api.unescape(o.getString("title"));
   v.duration = o.getLong("duration");
   v.description = Api.unescape(o.optString("description"));
   if (o.has("image")) v.image = o.optString("image");
   v.image_big = o.optString("image_medium");
   if (o.has("thumb")) // video.getUserVideos
   v.image = o.optString("thumb");
   v.link = o.optString("link");
   v.date = o.optLong("date");
   v.player = o.optString("player");
   if (o.has("views")) {
     v.views = o.getLong("views");
   }
   JSONObject files = o.optJSONObject("files");
   if (files != null) {
     v.external = files.optString("external");
     v.mp4_240 = files.optString("mp4_240");
     v.mp4_360 = files.optString("mp4_360");
     v.mp4_480 = files.optString("mp4_480");
     v.mp4_720 = files.optString("mp4_720");
     v.flv_320 = files.optString("flv_320");
   }
   return v;
 }
Beispiel #2
0
 public static WallMessage parse(JSONObject o) throws JSONException {
   WallMessage wm = new WallMessage();
   wm.id = o.getLong("id");
   wm.from_id = o.getLong("from_id");
   wm.to_id = o.getLong("to_id");
   wm.date = o.getLong("date");
   wm.online = o.optString("online");
   wm.text = Api.unescape(o.getString("text"));
   if (o.has("likes")) {
     JSONObject jlikes = o.getJSONObject(NewsJTags.LIKES);
     wm.like_count = jlikes.getInt("count");
     wm.user_like = jlikes.getInt("user_likes") == 1;
     wm.can_like = jlikes.getInt("can_like") == 1;
     wm.like_can_publish = jlikes.getInt("can_publish") == 1;
   }
   wm.copy_owner_id = o.optLong("copy_owner_id");
   JSONArray attachments = o.optJSONArray("attachments");
   JSONObject geo_json = o.optJSONObject("geo");
   // владельцем опроса является to_id. Даже если добавить опрос в группу от своего имени, то
   // from_id буду я, но опрос всё-равно будет принадлежать группе.
   wm.attachments = Attachment.parseAttachments(attachments, wm.to_id, wm.copy_owner_id, geo_json);
   if (o.has("comments")) {
     JSONObject jcomments = o.getJSONObject("comments");
     wm.comment_count = jcomments.getInt("count");
     wm.comment_can_post = jcomments.getInt("can_post") == 1;
   }
   return wm;
 }
Beispiel #3
0
 public static Video parseForAttachments(JSONObject o)
     throws NumberFormatException, JSONException {
   Video v = new Video();
   if (o.has("vid")) v.vid = o.getLong("vid");
   if (o.has("id")) // video.getUserVideos
   v.vid = Long.parseLong(o.getString("id"));
   v.owner_id = o.getLong("owner_id");
   v.title = Api.unescape(o.getString("title"));
   v.duration = o.getLong("duration");
   v.description = Api.unescape(o.optString("description"));
   if (o.has("image")) v.image = o.optString("image");
   v.image_big = o.optString("image_big");
   if (o.has("thumb")) // video.getUserVideos
   v.image = o.optString("thumb");
   v.link = o.optString("link");
   v.date = o.optLong("date");
   v.player = o.optString("player");
   if (o.has("views")) {
     v.views = o.getLong("views");
   }
   return v;
 }
Beispiel #4
0
 public static WallMessage parseForNotifications(JSONObject o) throws JSONException {
   WallMessage wm = new WallMessage();
   wm.id = o.getLong("id");
   wm.from_id = Long.parseLong(o.getString("owner_id"));
   wm.text = Api.unescape(o.getString("text"));
   // likes is there but I don't parse it because I don't need it
   // if (o.has("likes")){
   //    JSONObject jlikes = o.getJSONObject(NewsJTags.LIKES);
   //    wm.like_count = jlikes.getInt("count");
   //    wm.user_like = jlikes.getInt("user_likes")==1;
   //    wm.can_like = jlikes.getInt("can_like")==1;
   //    wm.like_can_publish = jlikes.getInt("can_publish")==1;
   // }
   JSONArray attachments = o.optJSONArray("attachments");
   JSONObject geo_json = o.optJSONObject("geo");
   wm.attachments = Attachment.parseAttachments(attachments, wm.to_id, wm.copy_owner_id, geo_json);
   return wm;
 }
  public static Note parse(JSONObject o) throws NumberFormatException, JSONException {
    Note note = new Note();
    note.nid = o.optLong("id");

    // в новости "добавил заметку" заметка приходит по-старому - баг в API
    if (!o.has("id") && o.has("nid")) note.nid = o.optLong("nid");

    note.owner_id = o.getLong("owner_id");
    note.title = Api.unescape(o.getString("title"));
    note.ncom = o.optLong("comments");

    // в новости "добавил заметку" заметка приходит по-старому - баг в API
    if (!o.has("comments") && o.has("ncom")) note.ncom = o.optLong("ncom");

    // note.read_ncom = o.optLong("read_comments");
    note.text = o.optString("text");
    note.date = o.optLong("date");
    return note;
  }