public ArrayList<JuickMessage> parseAPIPostAndReplies(String jsonStr) {
   ArrayList<JuickMessage> retval = new ArrayList<JuickMessage>();
   try {
     JSONObject jo = new JSONObject(new JSONTokener(new FastStringReader(jsonStr)));
     JSONObject post = jo.getJSONObject("post");
     PointMessage msg = new PointMessage();
     parsePointAPIMessagePost(msg, post);
     retval.add(msg);
     JSONArray comments = jo.getJSONArray("comments");
     for (int i = 0; i < comments.length(); i++) {
       JSONObject comment = comments.getJSONObject(i);
       PointMessage comm = new PointMessage();
       try {
         parsePointAPIComment(comment, comm, msg);
         retval.add(comm);
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   } catch (JSONException e) {
     e.printStackTrace();
   } catch (ParseException e) {
     e.printStackTrace();
   }
   return retval;
 }
 @Override
 public void getChildren(
     MessageID mid,
     Utils.Notification notification,
     Utils.Function<Void, ArrayList<JuickMessage>> cont) {
   String midString = ((BnwMessageID) mid).getId();
   final String jsonStr =
       httpClientService
           .getJSON(
               "http://ipv4.bnw.im/api/show?message=" + midString + "&replies=1", notification)
           .getResult();
   if (jsonStr != null) {
     try {
       JSONObject fullThread = new JSONObject(jsonStr);
       JSONObject root = fullThread.getJSONObject("message");
       ArrayList<BNWMessage> msgs = new ArrayList<BNWMessage>();
       msgs.add(initFromJSON(root));
       JSONArray replies = fullThread.getJSONArray("replies");
       HashMap<String, Integer> numbersRemap = new HashMap<String, Integer>();
       int replyNo = 1;
       for (int i = 0; i < replies.length(); i++) {
         BNWMessage reply = initFromJSON(replies.getJSONObject(i));
         msgs.add(reply);
         reply.setRID(replyNo);
         numbersRemap.put(reply.getRIDString(), replyNo);
         replyNo++;
       }
       for (int i = 1; i < msgs.size(); i++) {
         BNWMessage msg = msgs.get(i);
         String replyToString = msg.getReplyToString();
         if (replyToString == null) {
           msg.setReplyTo(0);
         } else {
           Integer prevComment = numbersRemap.get(replyToString);
           if (prevComment == null) prevComment = 0;
           msg.setReplyTo(prevComment);
         }
       }
       cont.apply(new ArrayList<JuickMessage>(msgs));
     } catch (JSONException e) {
       cont.apply(new ArrayList<JuickMessage>());
     }
   } else {
     cont.apply(new ArrayList<JuickMessage>());
   }
 }
 public ArrayList<JuickMessage> parseJSONpure(String jsonStr, boolean storeSource) {
   ArrayList<JuickMessage> messages = new ArrayList<JuickMessage>();
   if (jsonStr != null) {
     try {
       JSONObject objMessages = new JSONObject(jsonStr);
       JSONArray json = objMessages.getJSONArray("messages");
       int cnt = json.length();
       for (int i = 0; i < cnt; i++) {
         JSONObject jsonObject = json.getJSONObject(i);
         JuickMessage msg = initFromJSON(jsonObject);
         messages.add(msg);
         if (!storeSource) msg.source = null;
       }
     } catch (Exception e) {
       e.printStackTrace();
       // Log.e("initOpinionsAdapter", e.toString());
     }
   }
   return messages;
 }
 public ArrayList<JuickMessage> parseAPIMessageListPure(String jsonStr) {
   ArrayList<JuickMessage> retval = new ArrayList<JuickMessage>();
   try {
     JSONObject jo = new JSONObject(new JSONTokener(new FastStringReader(jsonStr)));
     JSONArray posts = jo.getJSONArray("posts");
     for (int i = 0; i < posts.length(); i++) {
       JSONObject post = posts.getJSONObject(i);
       PointMessage msg = new PointMessage();
       try {
         parsePointAPIMessage(post, msg);
         retval.add(msg);
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   } catch (JSONException e) {
     e.printStackTrace();
   }
   return retval;
 }